Project

General

Profile

« Previous | Next » 

Revision 9aabe5a5

Added by shyouhei (Shyouhei Urabe) about 6 years ago

fix SEGV touching uninitialized memory

This function can be called from Init_VM().
No assumption can be made about object internals.

(lldb) run
Process 15734 launched: './miniruby' (x86_64)
Process 15734 stopped

  • thread #1: tid = 0x1441d4, 0x00000001000bdfcb minirubyrb_raw_iseq_info(buff="0x0000000100f61f48 [0 ] T_IMEMO iseq", buff_size=256, iseq=0x0000000100f61f48) + 27 at gc.c:9273, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x50) frame #0: 0x00000001000bdfcb minirubyrb_raw_iseq_info(buff="0x0000000100f61f48 [0 ] T_IMEMO iseq", buff_size=256, iseq=0x0000000100f61f48) + 27 at gc.c:9273
    9270 static void
    9271 rb_raw_iseq_info(char *buff, const int buff_size, const rb_iseq_t *iseq)
    9272 {
    -> 9273 if (iseq->body->location.label) {
    9274 VALUE path = rb_iseq_path(iseq);
    9275 snprintf(buff, buff_size, "%s %s@%s:%d", buff,
    9276 RSTRING_PTR(iseq->body->location.label),
    (lldb) p *iseq
    (rb_iseq_t) $0 = {
    flags = 28698
    reserved1 = 0
    body = 0x0000000000000000
    aux = {
    compile_data = 0x0000000000000000
    loader = (obj = 0, index = 0)
    trace_events = 0
    }
    }
    (lldb) bt
  • thread #1: tid = 0x1441d4, 0x00000001000bdfcb miniruby`rb_raw_iseq_info(buff="0x0000000100f61f48 [0 ] T_IMEMO iseq", buff_size=256, iseq=0x0000000100f61f48) + 27 at gc.c:9273, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x50)
    • frame #0: 0x00000001000bdfcb minirubyrb_raw_iseq_info(buff="0x0000000100f61f48 [0 ] T_IMEMO iseq", buff_size=256, iseq=0x0000000100f61f48) + 27 at gc.c:9273 frame #1: 0x00000001000bde72 minirubyrb_raw_obj_info(buff="0x0000000100f61f48 [0 ] T_IMEMO iseq", buff_size=256, obj=4311097160) + 2786 at gc.c:9396
      frame #2: 0x00000001000b7c5f minirubyobj_info(obj=4311097160) + 95 at gc.c:9428 frame #3: 0x00000001000c16a8 minirubynewobj_init(klass=0, flags=28698, v1=0, v2=0, v3=0, wb_protected=1, objspace=0x00000001007ee280, obj=4311097160) + 424 at gc.c:1887
      frame #4: 0x00000001000b44c9 minirubynewobj_of(klass=0, flags=28698, v1=0, v2=0, v3=0, wb_protected=1) + 217 at gc.c:1970 frame #5: 0x00000001000b464b minirubyrb_imemo_new(type=imemo_iseq, v1=0, v2=0, v3=0, v0=0) + 75 at gc.c:2017
      frame #6: 0x00000001000fd914 minirubyiseq_imemo_alloc + 36 at iseq.h:156 frame #7: 0x00000001000f6e1d minirubyiseq_alloc + 13 at iseq.c:211
      frame #8: 0x00000001000f6bf8 minirubyrb_iseq_new_with_opt(node=0x0000000000000000, name=4311097200, path=4311097200, realpath=8, first_lineno=1, parent=0x0000000000000000, type=ISEQ_TYPE_TOP, option=0x0000000100335c30) + 56 at iseq.c:519 frame #9: 0x00000001000f6bb6 minirubyrb_iseq_new(node=0x0000000000000000, name=4311097200, path=4311097200, realpath=8, parent=0x0000000000000000, type=ISEQ_TYPE_TOP) + 86 at iseq.c:480
      frame #10: 0x0000000100284bb0 minirubyInit_VM + 1040 at vm.c:3022 frame #11: 0x00000001000d4f7d minirubyrb_call_inits + 189 at inits.c:55
      frame #12: 0x000000010009fe06 minirubyruby_setup + 198 at eval.c:61 frame #13: 0x000000010009fe5d minirubyruby_init + 13 at eval.c:78
      frame #14: 0x00000001000009ed minirubymain(argc=2, argv=0x00007fff5fbfdbf0) + 93 at main.c:41 frame #15: 0x00007fff88eda5ad libdyld.dylibstart + 1
      (lldb)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e