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

(Re)move some GC pushes to be defensive about #35708 #38355

Merged
merged 1 commit into from
Nov 13, 2020
Merged

Conversation

Keno
Copy link
Member

@Keno Keno commented Nov 9, 2020

Somebody sent me a (Julia 1.4) trace that turned out to have the
same root cause as #35708. I took a look around just to be sure
that there was no other instance of this pattern and while I
didn't see any, I did see a useless push/pull pair as well
as a GC_PUSH of an uninitialized struct. While neither are a
problem by themselves, they will prevent the GC analyzer from
giving an error if any of the function in between ever become
safepoints (since the GC analyzer doesn't track initilized-ness).
I think it as a rule of thumb, we should never push uninitialized
values into a GC frame. Doing so assumes that there are no safepoints
before the value is fully initialized, but if that is the case,
the GC_PUSH may also be delayed until after initialization and if
the assumption ever changes, at least the GC analyzer will catch it.

for (size_t i = 0; i < na; i++) {
set_nth_field(type, (void*)jv, i, args[i]);
}
init_struct_tail(type, jv, na);
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this still needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sorry this got dropped in rebase. I have it fixed locally, but didn't push the version yet.

Somebody sent me a (Julia 1.4) trace that turned out to have the
same root cause as #35708. I took a look around just to be sure
that there was no other instance of this pattern and while I
didn't see any, I did see a useless push/pull pair as well
as a GC_PUSH of an unitialized struct. While neither are a
problem by themselves, they will prevent the GC analyzer from
giving an error if any of the function in between ever become
safepoints (since the GC analyzer doesn't track initilized-ness).
I think it as a rule of thumb, we should never push uninitialized
values into a GC frame. Doing so assumes that there are no safepoints
before the value is fully initialized, but if that is the case,
the GC_PUSH may also be delayed until after initialization and if
the assumption ever changes, at least the GC analyzer will catch it.
@kshyatt kshyatt added the GC Garbage collector label Nov 10, 2020
@Keno
Copy link
Member Author

Keno commented Nov 12, 2020

@JeffBezanson good to go?

@Keno Keno merged commit 3dc54a2 into master Nov 13, 2020
@Keno Keno deleted the kf/defensive35708 branch November 13, 2020 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GC Garbage collector
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants