Skip to content

Remove assertion from jl_sig_throw#33259

Merged
vchuravy merged 1 commit intomasterfrom
vc/signal
Sep 15, 2019
Merged

Remove assertion from jl_sig_throw#33259
vchuravy merged 1 commit intomasterfrom
vc/signal

Conversation

@vchuravy
Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member

@c42f c42f left a comment

Choose a reason for hiding this comment

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

I need some more context here. In what circumstances can we have bt_size == 0? I assume this is valid (or at least unavoidable) in come cases?

I'd argue that we should be preserving the exception on the stack, even if we couldn't capture the backtrace.

@vchuravy
Copy link
Copy Markdown
Member Author

I need some more context here. In what circumstances can we have bt_size == 0? I assume this is valid (or at least unavoidable) in come cases?

Fair enough the context I have encountered this in is #33255. Looking at it again it originates from:

#0  jl_throw_in_ctx (ptls=0x7f8d01b124a0, e=0x7f8cfd246690 <jl_system_image_data+45685008>, sig=11, sigctx=0x7f8d00b649c0) at /home/vchuravy/src/julia/src/signals-unix.c:176
#1  0x00007f8d08f8c424 in segv_handler (sig=11, info=0x7f8d00b64af0, context=0x7f8d00b649c0) at /home/vchuravy/src/julia/src/signals-unix.c:254
#2  <signal handler called>
#3  0x00007f8d08f8266f in gc_scrub_range (low=0x7f8cee09b000 "", high=0x7f8cee49b000 "") at /home/vchuravy/src/julia/src/gc-debug.c:553
#4  0x00007f8d08f8294c in gc_scrub_task (ta=0x7f8cf608a710) at /home/vchuravy/src/julia/src/gc-debug.c:602
#5  0x00007f8d08f829a3 in gc_scrub () at /home/vchuravy/src/julia/src/gc-debug.c:608
#6  0x00007f8d08f7efd2 in _jl_gc_collect (ptls=0x7f8d01b124a0, full=0) at /home/vchuravy/src/julia/src/gc.c:2812
$1 = (jl_value_t *) 0x7f8cfd246690 <jl_system_image_data+45685008>
(rr) p jl_(e)
StackOverflowError()

julia/src/signals-unix.c

Lines 253 to 255 in 3f5d56a

if (ptls->safe_restore || is_addr_on_stack(ptls, info->si_addr)) { // stack overflow, or restarting jl_
jl_throw_in_ctx(ptls, jl_stackovf_exception, sig, context);
}

Which is a safe_restore.

@vchuravy vchuravy requested a review from c42f September 14, 2019 18:15
@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #33259 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #33259   +/-   ##
=======================================
  Coverage   75.78%   75.78%           
=======================================
  Files         380      380           
  Lines       66452    66452           
=======================================
  Hits        50359    50359           
  Misses      16093    16093

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3f5d56a...50e8da9. Read the comment docs.

Copy link
Copy Markdown
Member

@c42f c42f left a comment

Choose a reason for hiding this comment

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

Oh, I see. I did follow your xref originally but I somehow failed to see your comment and I got confused. Sorry about that!

So this is the safe_restore codepath... yes, the assert is invalid in that case. I'm fine with just removing it, though it would probably make a tad more sense to change it to

assert((e && ptls->bt_size != 0) || ptls->safe_restore);

if you can be bothered. Either way I'm happy.

@vchuravy
Copy link
Copy Markdown
Member Author

So this is the safe_restore codepath... yes, the assert is invalid in that case. I'm fine with just removing it, though it would probably make a tad more sense to change it to

I was thinking about that, but it would make more sense to me to add this invariant close to where it is needed.

@vchuravy vchuravy merged commit 1b0510d into master Sep 15, 2019
@delete-merged-branch delete-merged-branch bot deleted the vc/signal branch September 15, 2019 13:45
@c42f
Copy link
Copy Markdown
Member

c42f commented Sep 16, 2019

Good point. The tricky thing is that this was trying to check an invariant on data coming out of the signal handlers. Hence having it in sig throw is the first place it could intercept that program state. But I messed it up for the exact reason you describe!

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.

3 participants