Last active
December 27, 2015 09:49
-
-
Save benweint/7307051 to your computer and use it in GitHub Desktop.
Demonstration of a segfault when parsing deeply-nested JSON arrays with yajl-ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'yajl' | |
| depth = ARGV[0].to_i | |
| root = [] | |
| a = root | |
| depth.times { a << []; a = a[0] } | |
| puts Yajl::Encoder.encode(root) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Process: ruby [49834] | |
| Path: /Users/USER/*/ruby | |
| Identifier: ruby | |
| Version: 0 | |
| Code Type: X86-64 (Native) | |
| Parent Process: bash [17666] | |
| User ID: 502 | |
| Date/Time: 2013-11-04 10:29:01.581 -0800 | |
| OS Version: Mac OS X 10.8.5 (12F45) | |
| Report Version: 10 | |
| Crashed Thread: 0 Dispatch queue: com.apple.main-thread | |
| Exception Type: EXC_BAD_ACCESS (SIGABRT) | |
| Exception Codes: KERN_INVALID_ADDRESS at 0x00007fe481211c6c | |
| VM Regions Near 0x7fe481211c6c: | |
| MALLOC_TINY 00007fe084800000-00007fe084900000 [ 1024K] rw-/rwx SM=PRV | |
| --> | |
| Stack 00007fff57bc3000-00007fff5b3c3000 [ 56.0M] ---/rwx SM=NUL | |
| Application Specific Information: | |
| abort() called | |
| Thread 0 Crashed:: Dispatch queue: com.apple.main-thread | |
| 0 libsystem_kernel.dylib 0x00007fff85f05212 __pthread_kill + 10 | |
| 1 libsystem_c.dylib 0x00007fff8b9e2b24 pthread_kill + 90 | |
| 2 libsystem_c.dylib 0x00007fff8ba26f61 abort + 143 | |
| 3 ruby 0x000000010407f3b4 rb_bug + 212 | |
| 4 ruby 0x000000010415a9ce sigsegv + 190 | |
| 5 libsystem_c.dylib 0x00007fff8b9cf90a _sigtramp + 26 | |
| 6 yajl.bundle 0x00000001044f0464 yajl_gen_array_close + 20 (yajl_gen.c:320) | |
| 7 yajl.bundle 0x00000001044eee99 yajl_encode_part + 1129 (yajl_ext.c:160) | |
| 8 yajl.bundle 0x00000001044eef27 rb_yajl_encoder_encode + 71 (yajl_ext.c:663) | |
| 9 ruby 0x00000001041c6bd9 vm_call_cfunc_with_frame + 761 | |
| 10 ruby 0x00000001041e017c vm_call_method + 828 | |
| 11 ruby 0x00000001041cb5c3 vm_exec_core + 9443 | |
| 12 ruby 0x00000001041d2771 vm_exec + 2737 | |
| 13 ruby 0x00000001041d2c45 rb_iseq_eval_main + 357 | |
| 14 ruby 0x0000000104085f52 ruby_exec_internal + 178 | |
| 15 ruby 0x000000010408852c ruby_run_node + 60 | |
| 16 ruby 0x000000010403dddf main + 79 | |
| 17 libdyld.dylib 0x00007fff838ca7e1 start + 1 | |
| Thread 1: | |
| 0 libsystem_kernel.dylib 0x00007fff85f05f96 poll + 10 | |
| 1 ruby 0x00000001041f0607 thread_timer + 503 | |
| 2 libsystem_c.dylib 0x00007fff8b9e1772 _pthread_start + 327 | |
| 3 libsystem_c.dylib 0x00007fff8b9ce1a1 thread_start + 13 | |
| Thread 0 crashed with X86 Thread State (64-bit): | |
| rax: 0x0000000000000000 rbx: 0x0000000000000006 rcx: 0x00007fe0808ebd08 rdx: 0x0000000000000000 | |
| rdi: 0x0000000000000f07 rsi: 0x0000000000000006 rbp: 0x00007fe0808ebd30 rsp: 0x00007fe0808ebd08 | |
| r8: 0x00007fff7370d278 r9: 0x00007fe0808ebb90 r10: 0x0000000020000000 r11: 0x0000000000000206 | |
| r12: 0x00007fe081209e10 r13: 0x00007fe0812112e0 r14: 0x00007fff7370e180 r15: 0x0000000000000008 | |
| rip: 0x00007fff85f05212 rfl: 0x0000000000000206 cr2: 0x00007fff73706ff0 | |
| Logical CPU: 0 | |
| Binary Images: | |
| 0x10403d000 - 0x10429bfef +ruby (0) <303D9F59-5946-3708-9E45-24B93B82E6E0> /Users/USER/*/ruby | |
| 0x104492000 - 0x104493ff7 +encdb.bundle (0) <A141D7BD-099C-3416-BBAB-7A3B6682C03D> /Users/USER/*/encdb.bundle | |
| 0x1044c6000 - 0x1044c7ff7 +transdb.bundle (0) <6413EA56-C534-3353-BEC0-7FB87CED9E68> /Users/USER/*/transdb.bundle | |
| 0x1044ec000 - 0x1044f5ff7 +yajl.bundle (0) <687670CF-EDB7-3CA0-A5DB-B318C87D63E3> /Users/USER/*/yajl.bundle | |
| 0x7fff63c3d000 - 0x7fff63c7193f dyld (210.2.3) <A40597AA-5529-3337-8C09-D8A014EB1578> /usr/lib/dyld | |
| 0x7fff82561000 - 0x7fff8256fff7 libsystem_network.dylib (77.10) <0D99F24E-56FE-380F-B81B-4A4C630EE587> /usr/lib/system/libsystem_network.dylib | |
| 0x7fff838c8000 - 0x7fff838cbff7 libdyld.dylib (210.2.3) <F59367C9-C110-382B-A695-9035A6DD387E> /usr/lib/system/libdyld.dylib | |
| 0x7fff84243000 - 0x7fff8428fff7 libauto.dylib (185.4) <AD5A4CE7-CB53-313C-9FAE-673303CC2D35> /usr/lib/libauto.dylib | |
| 0x7fff845c2000 - 0x7fff845f0ff7 libsystem_m.dylib (3022.6) <B434BE5C-25AB-3EBD-BAA7-5304B34E3441> /usr/lib/system/libsystem_m.dylib | |
| 0x7fff84c10000 - 0x7fff84c25ff7 libdispatch.dylib (228.23) <D26996BF-FC57-39EB-8829-F63585561E09> /usr/lib/system/libdispatch.dylib | |
| 0x7fff84c85000 - 0x7fff84c86ff7 libsystem_sandbox.dylib (220.3) <B739DA63-B675-387A-AD84-412A651143C0> /usr/lib/system/libsystem_sandbox.dylib | |
| 0x7fff8567c000 - 0x7fff85681fff libcache.dylib (57) <65187C6E-3FBF-3EB8-A1AA-389445E2984D> /usr/lib/system/libcache.dylib | |
| 0x7fff85ef3000 - 0x7fff85f0eff7 libsystem_kernel.dylib (2050.48.12) <4B7993C3-F62D-3AC1-AF92-414A0D6EED5E> /usr/lib/system/libsystem_kernel.dylib | |
| 0x7fff85f0f000 - 0x7fff8602792f libobjc.A.dylib (532.2) <90D31928-F48D-3E37-874F-220A51FD9E37> /usr/lib/libobjc.A.dylib | |
| 0x7fff86d7d000 - 0x7fff86d7eff7 libSystem.B.dylib (169.3) <365477AB-D641-389D-B8F4-A1FAE9657EEE> /usr/lib/libSystem.B.dylib | |
| 0x7fff8791d000 - 0x7fff87925ff7 libsystem_dnssd.dylib (379.38.1) <BDCB8566-0189-34C0-9634-35ABD3EFE25B> /usr/lib/system/libsystem_dnssd.dylib | |
| 0x7fff87967000 - 0x7fff87969fff libquarantine.dylib (52.1) <143B726E-DF47-37A8-90AA-F059CFD1A2E4> /usr/lib/system/libquarantine.dylib | |
| 0x7fff87c06000 - 0x7fff87c07ff7 libdnsinfo.dylib (453.19) <14202FFB-C3CA-3FCC-94B0-14611BF8692D> /usr/lib/system/libdnsinfo.dylib | |
| 0x7fff87c08000 - 0x7fff87c09fff libDiagnosticMessagesClient.dylib (8) <8548E0DC-0D2F-30B6-B045-FE8A038E76D8> /usr/lib/libDiagnosticMessagesClient.dylib | |
| 0x7fff884d3000 - 0x7fff884d5ff7 libunc.dylib (25) <92805328-CD36-34FF-9436-571AB0485072> /usr/lib/system/libunc.dylib | |
| 0x7fff88c60000 - 0x7fff88c61fff libsystem_blocks.dylib (59) <D92DCBC3-541C-37BD-AADE-ACC75A0C59C8> /usr/lib/system/libsystem_blocks.dylib | |
| 0x7fff88d1a000 - 0x7fff88d82ff7 libc++.1.dylib (65.1) <20E31B90-19B9-3C2A-A9EB-474E08F9FE05> /usr/lib/libc++.1.dylib | |
| 0x7fff897bf000 - 0x7fff897e4ff7 libc++abi.dylib (26) <D86169F3-9F31-377A-9AF3-DB17142052E4> /usr/lib/libc++abi.dylib | |
| 0x7fff89827000 - 0x7fff89849ff7 libxpc.dylib (140.43) <70BC645B-6952-3264-930C-C835010CCEF9> /usr/lib/system/libxpc.dylib | |
| 0x7fff89999000 - 0x7fff899a1fff liblaunch.dylib (442.26.2) <2F71CAF8-6524-329E-AC56-C506658B4C0C> /usr/lib/system/liblaunch.dylib | |
| 0x7fff899a2000 - 0x7fff899a3ff7 libremovefile.dylib (23.2) <6763BC8E-18B8-3AD9-8FFA-B43713A7264F> /usr/lib/system/libremovefile.dylib | |
| 0x7fff8a9d8000 - 0x7fff8aa0efff libsystem_info.dylib (406.17) <4FFCA242-7F04-365F-87A6-D4EFB89503C1> /usr/lib/system/libsystem_info.dylib | |
| 0x7fff8aff6000 - 0x7fff8b045ff7 libcorecrypto.dylib (106.2) <CE0C29A3-C420-339B-ADAA-52F4683233CC> /usr/lib/system/libcorecrypto.dylib | |
| 0x7fff8b04d000 - 0x7fff8b05bfff libcommonCrypto.dylib (60027) <BAAFE0C9-BB86-3CA7-88C0-E3CBA98DA06F> /usr/lib/system/libcommonCrypto.dylib | |
| 0x7fff8b36c000 - 0x7fff8b377fff libsystem_notify.dylib (98.5) <C49275CC-835A-3207-AFBA-8C01374927B6> /usr/lib/system/libsystem_notify.dylib | |
| 0x7fff8b450000 - 0x7fff8b457fff libcopyfile.dylib (89) <876573D0-E907-3566-A108-577EAD1B6182> /usr/lib/system/libcopyfile.dylib | |
| 0x7fff8b9cc000 - 0x7fff8b9ccfff libkeymgr.dylib (25) <CC9E3394-BE16-397F-926B-E579B60EE429> /usr/lib/system/libkeymgr.dylib | |
| 0x7fff8b9cd000 - 0x7fff8ba99ff7 libsystem_c.dylib (825.40.1) <543B05AE-CFA5-3EFE-8E58-77225411BA6B> /usr/lib/system/libsystem_c.dylib | |
| 0x7fff8bec3000 - 0x7fff8bec9fff libmacho.dylib (829) <BF332AD9-E89F-387E-92A4-6E1AB74BD4D9> /usr/lib/system/libmacho.dylib | |
| 0x7fff8c71f000 - 0x7fff8c725ff7 libunwind.dylib (35.1) <21703D36-2DAB-3D8B-8442-EAAB23C060D3> /usr/lib/system/libunwind.dylib | |
| 0x7fff8d1cd000 - 0x7fff8d1d2fff libcompiler_rt.dylib (30) <08F8731D-5961-39F1-AD00-4590321D24A9> /usr/lib/system/libcompiler_rt.dylib | |
| External Modification Summary: | |
| Calls made by other processes targeting this process: | |
| task_for_pid: 0 | |
| thread_create: 0 | |
| thread_set_state: 0 | |
| Calls made by this process: | |
| task_for_pid: 0 | |
| thread_create: 0 | |
| thread_set_state: 0 | |
| Calls made by all processes on this machine: | |
| task_for_pid: 230145 | |
| thread_create: 2 | |
| thread_set_state: 3801 | |
| VM Region Summary: | |
| ReadOnly portion of Libraries: Total=59.8M resident=59.1M(99%) swapped_out_or_unallocated=672K(1%) | |
| Writable regions: Total=76.9M written=4796K(6%) resident=8220K(10%) swapped_out=0K(0%) unallocated=68.9M(90%) | |
| REGION TYPE VIRTUAL | |
| =========== ======= | |
| MALLOC 68.5M | |
| MALLOC guard page 32K | |
| STACK GUARD 4K | |
| Stack 64.0M | |
| VM_ALLOCATE 4K | |
| __DATA 824K | |
| __LINKEDIT 52.8M | |
| __TEXT 7128K | |
| shared memory 12K | |
| =========== ======= | |
| TOTAL 193.1M | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ ./test.rb 130 | |
| /Users/ben/.gem/ruby/2.0.0/gems/yajl-ruby-1.1.0/lib/yajl.rb:72: [BUG] Segmentation fault | |
| ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0] | |
| -- Crash Report log information -------------------------------------------- | |
| See Crash Report log file under the one of following: | |
| * ~/Library/Logs/CrashReporter | |
| * /Library/Logs/CrashReporter | |
| * ~/Library/Logs/DiagnosticReports | |
| * /Library/Logs/DiagnosticReports | |
| the more detail of. | |
| -- Control frame information ----------------------------------------------- | |
| c:0004 p:---- s:0020 e:000019 CFUNC :encode | |
| c:0003 p:0048 s:0015 e:000014 METHOD /Users/ben/.gem/ruby/2.0.0/gems/yajl-ruby-1.1.0/lib/yajl.rb:72 | |
| c:0002 p:0058 s:0007 E:000600 EVAL ./test.rb:10 [FINISH] | |
| c:0001 p:0000 s:0002 E:001158 TOP [FINISH] | |
| ./test.rb:10:in `<main>' | |
| /Users/ben/.gem/ruby/2.0.0/gems/yajl-ruby-1.1.0/lib/yajl.rb:72:in `encode' | |
| /Users/ben/.gem/ruby/2.0.0/gems/yajl-ruby-1.1.0/lib/yajl.rb:72:in `encode' | |
| -- C level backtrace information ------------------------------------------- | |
| -- Other runtime information ----------------------------------------------- | |
| * Loaded script: ./test.rb | |
| * Loaded features: | |
| 0 enumerator.so | |
| 1 /Users/ben/.rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin12.4.0/enc/encdb.bundle | |
| 2 /Users/ben/.rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin12.4.0/enc/trans/transdb.bundle | |
| 3 /Users/ben/.rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin12.4.0/rbconfig.rb | |
| 4 /Users/ben/.rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/compatibility.rb | |
| 5 /Users/ben/.rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/defaults.rb | |
| 6 /Users/ben/.rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/deprecate.rb | |
| 7 /Users/ben/.rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/errors.rb | |
| 8 /Users/ben/.rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/version.rb | |
| 9 /Users/ben/.rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/requirement.rb | |
| 10 /Users/ben/.rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/platform.rb | |
| 11 /Users/ben/.rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/specification.rb | |
| 12 /Users/ben/.rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/exceptions.rb | |
| 13 /Users/ben/.rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb | |
| 14 /Users/ben/.rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb | |
| 15 /Users/ben/.rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems.rb | |
| 16 /Users/ben/.rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/path_support.rb | |
| 17 /Users/ben/.rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/dependency.rb | |
| 18 /Users/ben/.gem/ruby/2.0.0/gems/yajl-ruby-1.1.0/lib/yajl/yajl.bundle | |
| 19 /Users/ben/.gem/ruby/2.0.0/gems/yajl-ruby-1.1.0/lib/yajl.rb | |
| [NOTE] | |
| You may have encountered a bug in the Ruby interpreter or extension libraries. | |
| Bug reports are welcome. | |
| For details: http://www.ruby-lang.org/bugreport.html | |
| Abort trap: 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment