Further fix for CowArray to prevent using the refcount from GC#10788
Merged
kinke merged 1 commit intodlang:stablefrom May 22, 2025
Merged
Further fix for CowArray to prevent using the refcount from GC#10788kinke merged 1 commit intodlang:stablefrom
kinke merged 1 commit intodlang:stablefrom
Conversation
destroyed from a GC finalizer.
Contributor
|
Thanks for your pull request, @schveiguy! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "stable + phobos#10788" |
Contributor
|
All that RCness appears to be that it can go away. Along with this alias: https://github.com/dlang/phobos/blob/e3e5d35d9b9ed5ef596e2396037631a72be4e6ba/std/uni/package.d#L1913C7-L1913C18 Nothing can trigger it. |
rikkimax
approved these changes
May 22, 2025
kinke
approved these changes
May 22, 2025
kinke
pushed a commit
to symmetryinvestments/phobos
that referenced
this pull request
May 22, 2025
…ang#10788) destroyed from a GC finalizer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While in a GC finalizer:
See #10785 for the first fix, which did some of this, but not for the refcount.
technically, we really should just ban use of the array from inside a finalizer. But this should be enough to get past the segfaults we are seeing.
This does mean that any
CowArray!GcPolicywhich has a reference from a finalized block, will have extra references that never go away. This is OK, because, if you write to the array, you will make a copy. And then there is now a refcount of 1 again, and the original can truly become garbage. If you read from it, nothing is different.In general, we should probably examine why we need the complication of this scheme here. Obviously, it has not been fully understood in the context of how the GC works, and It's an internal type, which is only used in std.uni...