Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Root globals in toplevel exprs #54433

Merged
merged 6 commits into from
Sep 25, 2024
Merged

Root globals in toplevel exprs #54433

merged 6 commits into from
Sep 25, 2024

Conversation

gbaraldi
Copy link
Member

This fixes #54422, the code here assumes that top level exprs are always rooted, but I don't see that referenced anywhere else, or guaranteed, so conservatively always root objects that show up in code.

@gbaraldi gbaraldi requested a review from vtjnash May 10, 2024 16:20
@gbaraldi gbaraldi changed the title Always root the contents in expression, regardless if they are top level or not. Always root the contents in expressions, regardless if they are top level or not. May 10, 2024
test/gc.jl Outdated Show resolved Hide resolved
@KristofferC
Copy link
Sponsor Member

@vtjnash, what does the 👎 mean here? Should that be taken as an objection to merging this?

@vtjnash
Copy link
Sponsor Member

vtjnash commented May 13, 2024

Toplevel exprs are supposed to be rooted

@gbaraldi
Copy link
Member Author

Right, basically this fixes this bug, but it seems there's another bug somewhere that's causing this.

@gbaraldi
Copy link
Member Author

gbaraldi commented May 16, 2024

So there are a couple things with this code, the correct solution here would be to special case globals from top level expressions in codegen to be assumed not to always have a root so having them trigger write barriers. IMO that is a lot of complexity for a corner case (compiled top level expressions) to save rooting a couple of extra values.
@vtjnash what do you think?

@gbaraldi gbaraldi changed the title Always root the contents in expressions, regardless if they are top level or not. Move globals in top level exprs to the old generation of the GC. May 17, 2024
@giordano giordano added the GC Garbage collector label Sep 23, 2024
src/gc-stock.c Outdated Show resolved Hide resolved
src/gc-stock.c Outdated Show resolved Hide resolved
@gbaraldi gbaraldi changed the title Move globals in top level exprs to the old generation of the GC. Root globals in toplevel exprs Sep 24, 2024
@gbaraldi gbaraldi added backport 1.10 Change should be backported to the 1.10 release backport 1.11 Change should be backported to release-1.11 labels Sep 24, 2024
@giordano giordano added compiler:codegen Generation of LLVM IR and native code and removed GC Garbage collector labels Sep 24, 2024
@giordano
Copy link
Contributor

Is this PR good to go now?

@gbaraldi gbaraldi merged commit 6e5e87b into master Sep 25, 2024
12 checks passed
@gbaraldi gbaraldi deleted the gb/toplevel-root branch September 25, 2024 12:40
giordano pushed a commit that referenced this pull request Sep 25, 2024
This fixes #54422, the code here assumes that top level exprs are always
rooted, but I don't see that referenced anywhere else, or guaranteed, so
conservatively always root objects that show up in code.
@giordano giordano removed the backport 1.10 Change should be backported to the 1.10 release label Sep 26, 2024
KristofferC pushed a commit that referenced this pull request Sep 30, 2024
This fixes #54422, the code here assumes that top level exprs are always
rooted, but I don't see that referenced anywhere else, or guaranteed, so
conservatively always root objects that show up in code.

(cherry picked from commit 6e5e87b)
@KristofferC KristofferC mentioned this pull request Sep 30, 2024
39 tasks
KristofferC added a commit that referenced this pull request Oct 1, 2024
Backported PRs:
- [x] #55849 <!-- Mmap: fix grow! for non file IOs -->
- [x] #55863 <!-- Update TaskLocalRNG docstring according to #49110 -->
- [x] #54433 <!-- Root globals in toplevel exprs -->
- [x] #55828 <!-- Fix some corner cases of `isapprox` with unsigned
integers -->
- [x] #55890 <!-- Profile: fix order of fields in heapsnapshot & improve
formatting -->
- [x] #55884 <!-- inference: add missing `TypeVar` handling for
`instanceof_tfunc` -->
- [x] #55881 <!-- Install terminfo data under /usr/share/julia -->
- [x] #55909 <!-- do not intentionally suppress errors in precompile
script from being reported or failing the result -->
- [x] #55355 <!-- relocation: account for trailing path separator in
depot paths -->
- [x] #55917 <!-- fix rawbigints OOB issues -->
- [x] #55892 <!-- TOML: Avoid type-pirating `Base.TOML.Parser` -->
- [x] #55798 <!-- Broadcast binary ops involving strided triangular -->
- [x] #55919 <!-- Limit `@inbounds` to indexing in the dual-iterator
branch in `copyto_unaliased!` -->

Contains multiple commits, manual intervention needed:
- [ ] #54009 <!-- allow extensions to trigger from packages in [deps]
-->
- [ ] #55509 <!-- Fix cong implementation to be properly random and not
just cycling. -->
- [ ] #55569 <!-- Add a docs section about loading/precomp/ttfx time
tuning -->
- [ ] #55824 <!-- Replace regex package module checks with actual code
checks -->

Non-merged PRs with backport label:
- [ ] #55932 <!-- REPL: make UndefVarError aware of imported modules -->
- [ ] #55910 <!-- Prevent extensions from blocking parallel
pre-compilation -->
- [ ] #55908 <!-- add logic to prefer loading modules that are already
loaded -->
- [ ] #55886 <!-- irrationals: restrict assume effects annotations to
known types -->
- [ ] #55871 <!-- lowering: don't reverse handler order in
`(pop-handler-list ...)` -->
- [ ] #55870 <!-- fix infinite recursion in `promote_type` for
`Irrational` -->
- [ ] #55867 <!-- update `hash` doc string: `widen` not required any
more -->
- [ ] #55851 <!-- [REPL] Fix #55850 by using `safe_realpath` instead of
`abspath` in `projname` -->
- [ ] #55813 <!-- Check for conflicting `@ccallable` name before JIT
registration -->
- [ ] #55743 <!-- doc: heap snapshot viewing -->
- [ ] #55741 <!-- Change annotations to use a NamedTuple -->
- [ ] #55534 <!-- Set stdlib sources as read-only during installation
-->
- [ ] #55499 <!-- propagate the terminal's `displaysize` to the
`IOContext` used by the REPL -->
- [ ] #55458 <!-- Allow for generically extracting unannotated string
-->
- [ ] #55457 <!-- Make AnnotateChar equality consider annotations -->
- [ ] #55220 <!-- `isfile_casesensitive` fixes on Windows -->
- [ ] #55169 <!-- `propertynames` for SVD respects private argument -->
- [ ] #54457 <!-- Make `String(::Memory)` copy -->
- [ ] #53957 <!-- tweak how filtering is done for what packages should
be precompiled -->
- [ ] #51479 <!-- prevent code loading from lookin in the versioned
environment when building Julia -->
- [ ] #50813 <!-- More doctests for Sockets and capitalization fix -->
- [ ] #50157 <!-- improve docs for `@inbounds` and
`Base.@propagate_inbounds` -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.11 Change should be backported to release-1.11 compiler:codegen Generation of LLVM IR and native code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Basic use of StaticArrays and begin ... end leads to GC error (probable corruption)
5 participants