diff options
author | 卜部昌平 <[email protected]> | 2019-07-31 23:00:15 +0900 |
---|---|---|
committer | 卜部昌平 <[email protected]> | 2019-08-01 16:00:59 +0900 |
commit | 5d33f787169bcc3594d2264726695d58c4a06899 (patch) | |
tree | f3a4fb4c67a22571d8dd632d4f77c452ecfa8863 /gc.c | |
parent | d2f8e03f346424553f3081896c91dd7d6fdf5db0 (diff) |
fix tracepoint + backtrace SEGV
PC modification in gc_event_hook_body was careless. There are (so
to say) abnormal iseqs stored in the cfp. We have to check sanity
before we touch the PC.
This has not been fixed because there was no way to (ab)use the
setup from pure-Ruby. However by using our official C APIs it is
possible to touch such frame(s), resulting in SEGV.
Fixes [Bug #14834].
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -1925,8 +1925,11 @@ rb_objspace_set_event_hook(const rb_event_flag_t event) static void gc_event_hook_body(rb_execution_context_t *ec, rb_objspace_t *objspace, const rb_event_flag_t event, VALUE data) { - /* increment PC because source line is calculated with PC-1 */ - const VALUE *pc = ec->cfp->pc++; + const VALUE *pc = ec->cfp->pc; + if (VM_FRAME_RUBYFRAME_P(ec->cfp)) { + /* increment PC because source line is calculated with PC-1 */ + ec->cfp->pc++; + } EXEC_EVENT_HOOK(ec, event, ec->cfp->self, 0, 0, 0, data); ec->cfp->pc = pc; } |