[ruby-cvs:72733] shyouhei:r65633 (trunk): gc.c: avoid integer overflow at process exit

shyouhei at ruby-lang.org shyouhei at ruby-lang.org
Thu Nov 8 18:46:10 JST 2018


shyouhei	2018-11-08 18:46:09 +0900 (Thu, 08 Nov 2018)

  New Revision: 65633

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65633

  Log:
    gc.c: avoid integer overflow at process exit
    
    This is rather nitpicking but at the moment the process terminates,
    heap_pages_final_slots overflows.
    
    (lldb) bt
    * thread #1: tid = 0xc0903, 0x00000001002b3bf7 miniruby`finalize_list(objspace=0x0000000101c09240, zombie=4329149840) + 999 at gc.c:2946, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
      * frame #0: 0x00000001002b3bf7 miniruby`finalize_list(objspace=0x0000000101c09240, zombie=4329149840) + 999 at gc.c:2946
        frame #1: 0x000000010026a69e miniruby`rb_objspace_call_finalizer(objspace=0x0000000101c09240) + 7118 at gc.c:3092
        frame #2: 0x0000000100268ac5 miniruby`rb_gc_call_finalizer_at_exit + 149 at gc.c:3015
        frame #3: 0x00000001002272bc miniruby`ruby_finalize_1 + 156 at eval.c:146
        frame #4: 0x00000001002282b6 miniruby`ruby_cleanup(ex=0) + 4070 at eval.c:238
        frame #5: 0x0000000100228785 miniruby`ruby_run_node(n=0x0000000102060ad8) + 85 at eval.c:317
        frame #6: 0x0000000100000b9c miniruby`main(argc=2, argv=0x00007fff5fbfdc38) + 124 at main.c:42
        frame #7: 0x00007fff9966a5ad libdyld.dylib`start + 1
        frame #8: 0x00007fff9966a5ad libdyld.dylib`start + 1
    (lldb) p objspace->heap_pages
    (rb_objspace::(anonymous struct)) $0 = {
      sorted = 0x0000000101c070b0
      allocated_pages = 24
      allocatable_pages = 0
      sorted_length = 24
      range = {
        [0] = 0x0000000102020028
        [1] = 0x00000001020dbfd0
      }
      freeable_pages = 0
      final_slots = 0
      deferred_final = 4329149840
    }
    (lldb)

  Modified files:
    trunk/gc.c


More information about the ruby-cvs mailing list