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

Fix gc rooting in exception throwing #28770

Merged
merged 1 commit into from
Aug 20, 2018
Merged

Fix gc rooting in exception throwing #28770

merged 1 commit into from
Aug 20, 2018

Conversation

Keno
Copy link
Member

@Keno Keno commented Aug 19, 2018

Most paths to throw_internal assume that e may be unrooted. However, the static analyzer complains that a transition from gc-safe to gc-unsafe (jl_gc_unsafe_enter) is a safepoint, so e may have been collected there before it gets assigned to exception_in_transit (which is a root). Switch the order of operations to fix that.

Most paths to `throw_internal` assume that `e` may be unrooted. However, the static analyzer complains that a transition from gc-safe to gc-unsafe (`jl_gc_unsafe_enter`) is a safepoint, so `e` may have been collected there before it gets assigned to `exception_in_transit` (which is a root). Switch the order of operations to fix that.
@Keno Keno requested a review from yuyichao August 19, 2018 20:00
Copy link
Contributor

@yuyichao yuyichao left a comment

Choose a reason for hiding this comment

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

The change looks valid though I don't think there's actually a bug here before.

The goal of the unsafe enter is to make sure the GC state is always unsafe (managed) in the catch frame, it should not affect the liveness of e. In fact, if the state was GC safe before entering the function (allowed but probably not used yet), e had better be rooted somewhere or another thread can free it. If it wasn't rooted, the state should have been unsafe and the unsafe_enter should be a no-op.

In any case, the change is still fine. Maybe worth add a comment if you want.

@Keno
Copy link
Member Author

Keno commented Aug 19, 2018

Unrelatedly, can we rename these from safe/unsafe to unmanaged/managed? I always mess up which is which.

@yuyichao
Copy link
Contributor

Unrelatedly, can we rename these from safe/unsafe to unmanaged/managed? I always mess up which is which.

That was the original name until #14190 (comment)
I'm fine either way so whatever you and Jeff prefer.......................

@vtjnash
Copy link
Member

vtjnash commented Aug 19, 2018

I propose enter/leave managed

@yuyichao
Copy link
Contributor

Fine with me too...

I don't like naming things and I hate renaming things so I'm not going to vote or make a decision on this.................

@Keno Keno merged commit 57b3497 into master Aug 20, 2018
@martinholters martinholters deleted the kf/throwroot branch August 20, 2018 03:59
@KristofferC
Copy link
Member

Backport candidate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants