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

Julia GC: fix stack marking #3199

Merged
merged 1 commit into from
Jan 21, 2019

Conversation

rbehrends
Copy link
Contributor

@rbehrends rbehrends commented Jan 20, 2019

This pull request fixes two separate bugs, related to #3114.

  1. The processor stack was not being marked correctly, as Julia
    made wrong assumptions about the end of the processor stack;
    we now use the value of stack_bottom that is being supplied
    to InitBags().
  2. CHANGED_BAG() was not being called on CurrLVars when a collection
    was initiated, unlike for the GASMAN implementation, where this
    happens in VarsBeforeCollectBags().

Fixes #3114

This commit fixes two separate issues.

1. The processor stack was not being marked correctly, as Julia
   made wrong assumptions about the end of the processor stack;
   we now use the value of `stack_bottom` that is being supplied
   to InitBags().
2. CHANGED_BAG() was not being called on CurrLVars when a collection
   was initiated, unlike for the GASMAN implementation, where this
   happens in VarsBeforeCollectBags().
src/julia_gc.c Outdated Show resolved Hide resolved
// is only called when the current lvars bag is being changed. Thus,
// we have to add a write barrier at the start of the GC, too.
if (STATE(CurrLVars))
CHANGED_BAG(STATE(CurrLVars));
Copy link
Member

Choose a reason for hiding this comment

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

It's OK to have this in here for now, to get a quick fix; but on the long run, I prefer to fix this properly, by providing a generic "pre-gc hook" in both GASMAN (which already has one) and Julia GC, and then setting that to VarsBeforeCollectBags. Also, this "optimization" for lvars needs to be documented in a better place. But neither of these are change request for this PR; me or somebody else can take care of it in a future PR.

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 agree. My goal here was to get the fix out ASAP. As the code is identical to VarsBeforeCollectBags(), this should be unified.

@@ -527,6 +528,9 @@ void GapRootScanner(int full)
// current_task != root_task.
char * stackend = (char *)jl_task_stack_buffer(task, &size, &tid);
stackend += size;
if (JuliaTLS->tid == 0 && JuliaTLS->root_task == task) {
stackend = (char *)GapStackBottom;
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, but note that this only will work right if GAP is the main process, loading Julia later. If, however, one is starting Julia and from there loading GAP, then GapStackBottom may not be at the base of the stack frame.

This is closely related to (part of) the discussion on issue #3089 ; see also PR #3096

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, and GapTaskScanner() may also need an update. That said, it should properly be handled so that Julia gets to know the proper end of the stack for task switching.

Copy link
Contributor

Choose a reason for hiding this comment

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

ISTM there needs to be a SetStackBottomBags (as in #3096) for Julia GC as well.

Copy link
Member

Choose a reason for hiding this comment

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

Possible, but this code is very much in flux, so it doesn't really matter at this stage.

@rbehrends rbehrends force-pushed the julia-gc-stack-scanning branch from e9ba8c7 to 45905ca Compare January 20, 2019 11:14
@codecov
Copy link

codecov bot commented Jan 20, 2019

Codecov Report

Merging #3199 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #3199      +/-   ##
==========================================
+ Coverage   84.76%   84.76%   +<.01%     
==========================================
  Files         688      688              
  Lines      335862   335866       +4     
==========================================
+ Hits       284685   284689       +4     
  Misses      51177    51177
Impacted Files Coverage Δ
src/julia_gc.c 87.54% <100%> (+0.24%) ⬆️
src/stats.c 95.29% <0%> (-0.01%) ⬇️

@fingolfin fingolfin changed the title Julia GC: fix stack marking. Julia GC: fix stack marking Jan 20, 2019
@fingolfin fingolfin added kind: bug: crash Issues describing bugs that cause GAP to crash, and PRs fixing them (used for release notes) topic: kernel topic: julia Julia GC integration and related matters labels Jan 20, 2019
@fingolfin
Copy link
Member

I can confirm that this fixes #3114 for me; I hope @ThomasBreuer can confirm that as well (and then check which of the other crashes he was getting are also fixed; hopefully all.... ;-)

@coveralls
Copy link

coveralls commented Jan 20, 2019

Coverage Status

Coverage increased (+0.0002%) to 84.642% when pulling 45905ca on rbehrends:julia-gc-stack-scanning into 3822353 on gap-system:master.

Copy link
Contributor

@ThomasBreuer ThomasBreuer left a comment

Choose a reason for hiding this comment

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

Yes, the problem from #3114 disappears in the changed version.
Thanks for the fix.

@ThomasBreuer ThomasBreuer merged commit a80fe12 into gap-system:master Jan 21, 2019
@fingolfin fingolfin deleted the julia-gc-stack-scanning branch February 13, 2019 14:42
@fingolfin
Copy link
Member

Backported to stable-4.10 in af3bb41

@olexandr-konovalov olexandr-konovalov added this to the GAP 4.10.1 milestone Feb 23, 2019
@olexandr-konovalov olexandr-konovalov added the release notes: added PRs introducing changes that have since been mentioned in the release notes label Feb 23, 2019
@fingolfin fingolfin added the kind: bug Issues describing general bugs, and PRs fixing them label Mar 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-to-4.10-DONE kind: bug: crash Issues describing bugs that cause GAP to crash, and PRs fixing them (used for release notes) kind: bug Issues describing general bugs, and PRs fixing them release notes: added PRs introducing changes that have since been mentioned in the release notes topic: julia Julia GC integration and related matters topic: kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when computing irreducibles of a permutation group
6 participants