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

Inhibit finalizers during codegen #11991

Merged
merged 1 commit into from
Jul 20, 2015
Merged

Inhibit finalizers during codegen #11991

merged 1 commit into from
Jul 20, 2015

Conversation

tkelman
Copy link
Contributor

@tkelman tkelman commented Jul 2, 2015

Might close #11956, if I followed @carnaval's idea correctly. Will see if this helps at all with #11818 or #7942.

@tkelman tkelman added compiler:codegen Generation of LLVM IR and native code GC Garbage collector labels Jul 2, 2015
@tkelman
Copy link
Contributor Author

tkelman commented Jul 2, 2015

It looks like this doesn't fix #7942 which is primarily a startup problem, but it might fix #11818 which looks like it might be more of a shutdown problem.

@vtjnash
Copy link
Member

vtjnash commented Jul 2, 2015

this seems reasonable to me. why did you mark it as WIP?

@tkelman tkelman changed the title WIP: Inhibit finalizers during codegen Inhibit finalizers during codegen Jul 2, 2015
@tkelman
Copy link
Contributor Author

tkelman commented Jul 2, 2015

because testing it locally takes a while, to see if it helps with intermittent freezes

@tkelman
Copy link
Contributor Author

tkelman commented Jul 2, 2015

Sadly I'm still able to reproduce freezes on win64 on this branch in the spawn test (even running tests in serial). This may be fixing a legit problem, but not the Windows one we've been hitting. If anyone can reliably reproduce the Linux segfaults that look related to finalizers running during codegen and this fixes it, then that would at least be a useful data point.

@JeffBezanson
Copy link
Member

This change seems prudent, even if it doesn't fix our immediate problems.

@vtjnash
Copy link
Member

vtjnash commented Jul 15, 2015

this lgtm. when someone gets a chance to fix the merge conflicts, i think it can be merged.

@tkelman
Copy link
Contributor Author

tkelman commented Jul 15, 2015

I'm traveling at a conference for the next few days so won't really get a chance to do that. If anyone else wants to do it, be my guest.

@tkelman
Copy link
Contributor Author

tkelman commented Jul 16, 2015

Just kidding, that wasn't that bad. Rebased.

JeffBezanson added a commit that referenced this pull request Jul 20, 2015
@JeffBezanson JeffBezanson merged commit 8566c4c into master Jul 20, 2015
@tkelman tkelman deleted the tk/inhibitfinalizers branch July 20, 2015 22:06
void jl_gc_inhibit_finalizers(int state)
{
if (jl_gc_finalizers_inhibited && !state && !jl_in_gc) {
jl_in_gc = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remind me why do we need to set jl_in_gc when running finalizers? There doesn't seem to be a problem to enable GC since the arguments are rooted. Is this just for consistency for not allowing task switch in them?

I'm asking mainly because requiring no GC during finalizer runs doesn't look like a trival synchronization to do.

c.c. @carnaval

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it was a concern that finalizers could need to be codegenned which might trigger gc again

Copy link
Member

Choose a reason for hiding this comment

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

the problem with running finalizers during codegen is that we may be currently trying to generate code for that function or some other required function when the finalizer tries to run. this patch re-introduces that possibility, but just makes it slightly rarer.

for inference, we can check the in-inference flag and if set, we instead run a non-inferred version. the equivalent that would be required here is to the in-compile flag and run a non-compiled version of the function.

i'm not sure of the issue with recursively running finalizers, since that has been allowed in the past.

the jl_in_gc flag was introduced to inhibit calls to yield inside finalizers, which would allow fairly unpredictable task switching to occur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:codegen Generation of LLVM IR and native code GC Garbage collector
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delay finalizers until after codegen is done
4 participants