summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-08-18 06:10:46 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-08-18 06:10:46 +0000
commite1d3b318fb3ac090aa72619ec649d875d05ede08 (patch)
tree48b4115a59b44b64a4a4cefb35d5294dac4ee7db /gc.c
parentfb8c28d3903c6efa15f8b1d2842219666f72982f (diff)
merge revision(s) 5d33f787169bcc3594d2264726695d58c4a06899,8b162ce9d1003e4e469d8f48cb9a2076fd45b47c: [Backport #14834]
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]. Fix assertion failure when VM_CHECK_MODE Some VM frames (dummy and top pushed by `rb_vm_call_cfunc`) has iseq but has no pc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/gc.c b/gc.c
index 71a3f032ad..0df7189191 100644
--- a/gc.c
+++ b/gc.c
@@ -1800,8 +1800,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 (pc && 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;
}