1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

vm_backtrace.c: pos can be zero

(lldb) target create "./miniruby"
Current executable set to './miniruby' (x86_64).
(lldb) settings set -- target.run-args  "-e0"
(lldb) run
Process 97005 launched: './miniruby' (x86_64)
./miniruby(rb_print_backtrace+0x15) [0x10024f7d5] vm_dump.c:715
./miniruby(rb_vm_get_sourceline+0x85) [0x10024c4f5] vm_backtrace.c:43
./miniruby(rb_vm_make_binding+0x146) [0x100236976] vm.c:941
./miniruby(Init_VM+0x592) [0x100249f02] vm.c:3091
./miniruby(rb_call_inits+0xc2) [0x1000c5a72] inits.c:58
./miniruby(ruby_setup+0xcb) [0x100098c6b] eval.c:74
./miniruby(ruby_init+0x9) [0x100098c99] eval.c:91
./miniruby(main+0x4d) [0x10025ddbd] addr2line.c:246
Process 97005 stopped
* thread #1: tid = 0x639bb, 0x000000010024c4f5 miniruby`rb_vm_get_sourceline(cfp=<unavailable>) + 133 at vm_backtrace.c:44, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
    frame #0: 0x000000010024c4f5 miniruby`rb_vm_get_sourceline(cfp=<unavailable>) + 133 at vm_backtrace.c:44
   41       else {
   42           /* SDR() is not possible; that causes infinite loop. */
   43           rb_print_backtrace();
-> 44           __builtin_trap();
   45       }
   46   #endif
   47       return rb_iseq_line_no(iseq, pos);
(lldb)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shyouhei 2018-11-07 08:04:33 +00:00
parent 0f36bc093f
commit 3f6a4be3a4
2 changed files with 13 additions and 2 deletions

View file

@ -1993,6 +1993,7 @@ AS_IF([test x$rb_cv_builtin___builtin_choose_expr = xyes], [
])
])
RUBY_CHECK_BUILTIN_FUNC(__builtin_types_compatible_p, [__builtin_types_compatible_p(int, int)])
RUBY_CHECK_BUILTIN_FUNC(__builtin_trap, [__builtin_trap()])
AS_IF([test "$ac_cv_func_qsort_r" != no], [
AC_CACHE_CHECK(whether qsort_r is GNU version, rb_cv_gnu_qsort_r,

View file

@ -33,8 +33,18 @@ inline static int
calc_lineno(const rb_iseq_t *iseq, const VALUE *pc)
{
size_t pos = (size_t)(pc - iseq->body->iseq_encoded);
/* use pos-1 because PC points next instruction at the beginning of instruction */
return rb_iseq_line_no(iseq, pos - 1);
if (LIKELY(pos)) {
/* use pos-1 because PC points next instruction at the beginning of instruction */
pos--;
}
#if VMDEBUG && defined(HAVE_BUILTIN___BUILTIN_TRAP)
else {
/* SDR() is not possible; that causes infinite loop. */
rb_print_backtrace();
__builtin_trap();
}
#endif
return rb_iseq_line_no(iseq, pos);
}
int