eventmachine/eventmachine — Issue #281: Segmentation Fault for ruby 1.9.3 via bundler
Author: cactus
Created: 2011-11-23 23:12:27+00:00
State: open

Mac OSX 10.7.2

ruby installed via homebrew
~~~
$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
~~~

Using EM from current HEAD (tried a few other versions. all similar behavior)
~~~
* em-http-request (1.0.0 1a4123d)
* em-synchrony (1.0.0 f07b2a1)
* eventmachine (1.0.0.beta.4 69151c3)
~~~

trace output after segfault (with paths pruned of local junk)

~~~

-- Control frame information -----------------------------------------------
c:0007 p:---- s:0037 b:0037 l:000036 d:000036 CFUNC :call
c:0006 p:---- s:0035 b:0035 l:000034 d:000034 CFUNC :run_machine
c:0005 p:0325 s:0032 b:0032 l:000031 d:000031 METHOD vendor/bundle/ruby/1.9.1/bundler/gems/eventmachine-69151c3ebb3e/lib/eventmachine.rb
c:0004 p:0056 s:0025 b:0025 l:0015c8 d:0015c8 METHOD vendor/bundle/ruby/1.9.1/bundler/gems/em-synchrony-f07b2a139ba0/lib/em-synchrony.rb
c:0003 p:0633 s:0018 b:0018 l:000d88 d:001958 EVAL bin/myscript:97
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:000d88 d:000d88 TOP

-- Ruby level backtrace information ----------------------------------------
bin/myscript:97:in `

'
vendor/bundle/ruby/1.9.1/bundler/gems/em-synchrony-f07b2a139ba0/lib/em-synchrony.rb:28:in `synchrony'
vendor/bundle/ruby/1.9.1/bundler/gems/eventmachine-69151c3ebb3e/lib/eventmachine.rb:186:in `run'
vendor/bundle/ruby/1.9.1/bundler/gems/eventmachine-69151c3ebb3e/lib/eventmachine.rb:186:in `run_machine'
vendor/bundle/ruby/1.9.1/bundler/gems/eventmachine-69151c3ebb3e/lib/eventmachine.rb:186:in `call'

-- C level backtrace information -------------------------------------------

See Crash Report log file under ~/Library/Logs/CrashReporter or
/Library/Logs/CrashReporter, for the more detail of.
~~~

crash reporter output
~~~

Process: ruby [36104]
Path: /Users/USER/*/ruby
Identifier: ruby
Version: ??? (???)
Code Type: X86-64 (Native)
Parent Process: bash [33973]

Date/Time: 2011-11-23 14:48:53.555 -0800
OS Version: Mac OS X 10.7.2 (11C74)
Report Version: 9

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGABRT)
Exception Codes: KERN_PROTECTION_FAILURE at 0x000000010da811aa

VM Regions Near 0x10da811aa:
MALLOC metadata 000000010d934000-000000010d935000 [ 4K] rw-/rwx SM=PRV
--> __TEXT 000000010d935000-000000010db15000 [ 1920K] r-x/rwx SM=COW /Users/USER/*/*.dylib
__DATA 000000010db15000-000000010db34000 [ 124K] rw-/rwx SM=PRV /Users/USER/*/*.dylib

Application Specific Information:
objc[36104]: garbage collection is OFF
abort() called

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib	0x00007fff8a691ce2 __pthread_kill + 10
1 libsystem_c.dylib	0x00007fff8d9917d2 pthread_kill + 95
2 libsystem_c.dylib	0x00007fff8d982a7a abort + 143
3 libruby.1.9.1.dylib	0x000000010d968ff9 rb_bug + 185
4 libruby.1.9.1.dylib	0x000000010da0dae9 sigbus + 57
5 libsystem_c.dylib	0x00007fff8d9e3cfa _sigtramp + 26
6 libruby.1.9.1.dylib	0x000000010da719ff vm_exec + 111
7 libruby.1.9.1.dylib	0x000000010da6a961 rb_vm_invoke_proc + 161
8 libruby.1.9.1.dylib	0x000000010d96f1f0 proc_call + 112
9 libruby.1.9.1.dylib	0x000000010da65d06 call_cfunc + 102
10 libruby.1.9.1.dylib	0x000000010da73811 vm_call0 + 641
11 libruby.1.9.1.dylib	0x000000010da690c7 rb_funcall + 231
12 rubyeventmachine.bundle	0x000000010df0f5a8 _ZL22event_callback_wrappermiPKcm + 56
13 rubyeventmachine.bundle	0x000000010df03d97 EventMachine_t::_RunTimers() + 103
14 rubyeventmachine.bundle	0x000000010df074be EventMachine_t::Run() + 126
15 rubyeventmachine.bundle	0x000000010defbb1d evma_run_machine + 45
16 rubyeventmachine.bundle	0x000000010df0ea09 _ZL29t_run_machine_without_threadsm + 9
17 libruby.1.9.1.dylib	0x000000010da65d10 call_cfunc + 112
18 libruby.1.9.1.dylib	0x000000010da6a0af vm_call_method + 767
19 libruby.1.9.1.dylib	0x000000010da6d86e vm_exec_core + 11966
20 libruby.1.9.1.dylib	0x000000010da719ee vm_exec + 94
21 libruby.1.9.1.dylib	0x000000010da72143 rb_iseq_eval_main + 275
22 libruby.1.9.1.dylib	0x000000010d96b65f ruby_exec_internal + 111
23 libruby.1.9.1.dylib	0x000000010d96c642 ruby_run_node + 82
24 ruby	0x000000010d930ecf main + 79
25 ruby	0x000000010d930e74 start + 52

Thread 1:
0 libsystem_kernel.dylib	0x00007fff8a691df2 __select + 10
1 libruby.1.9.1.dylib	0x000000010da78c21 thread_timer + 417
2 libsystem_c.dylib	0x00007fff8d98f8bf _pthread_start + 335
3 libsystem_c.dylib	0x00007fff8d992b75 thread_start + 13

Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x0000000000000006 rcx: 0x000000010de3f938 rdx: 0x0000000000000000
rdi: 0x000000000000250b rsi: 0x0000000000000006 rbp: 0x000000010de3f960 rsp: 0x000000010de3f938
r8: 0x00007fff7a08dfb8 r9: 0x000000010de3f4e8 r10: 0x00007fff8a691d0a r11: 0xffffff80002d8220
r12: 0x000000010dc01b20 r13: 0x0000000000000000 r14: 0x00007fff7a090960 r15: 0x00007fb70d47dad0
rip: 0x00007fff8a691ce2 rfl: 0x0000000000000246 cr2: 0x000000010de3eb00
Logical CPU: 0

Binary Images:
0x10d930000 - 0x10d930ff7 +ruby (??? - ???) <2EE701C2-AAB5-328A-92CC-49EBAA952D18> /Users/USER/*/ruby
0x10d935000 - 0x10db14ff7 +libruby.1.9.1.dylib (1.9.1 - compatibility 1.9.1) /Users/USER/*/libruby.1.9.1.dylib
0x10dbe4000 - 0x10dbe5ff7 +encdb.bundle (??? - ???) /Users/USER/*/encdb.bundle
0x10dbe8000 - 0x10dbe9fff +transdb.bundle (??? - ???) /Users/USER/*/transdb.bundle
0x10dbec000 - 0x10dbf2ff7 +pathname.bundle (??? - ???) <400DEAA9-51A2-3CA5-ADFA-BD928BCC0842> /Users/USER/*/pathname.bundle
0x10dbf7000 - 0x10dbf8ff7 +etc.bundle (??? - ???) <200F0519-12A5-3CD4-B18C-4A032C1BC8E4> /Users/USER/*/etc.bundle
0x10dbfc000 - 0x10dbfcfff +sha1.bundle (??? - ???) /Users/USER/*/sha1.bundle
0x10de40000 - 0x10de43ff7 +psych.bundle (??? - ???) <00FDD2C6-5240-33D8-85C7-6394A1DD1934> /Users/USER/*/psych.bundle
0x10de47000 - 0x10de62fff +libyaml-0.2.dylib (3.2.0 - compatibility 3.0.0) /Users/USER/*/libyaml-0.2.dylib
0x10de67000 - 0x10de6bff7 +stringio.bundle (??? - ???) /Users/USER/*/stringio.bundle
0x10de6f000 - 0x10de72ff7 +strscan.bundle (??? - ???) <288A161A-00B1-3941-87D8-B31E93D18B2F> /Users/USER/*/strscan.bundle
0x10de76000 - 0x10dea3ff7 +date_core.bundle (??? - ???) <20DCFE8F-784A-390C-8490-C35D494FD047> /Users/USER/*/date_core.bundle
0x10deb2000 - 0x10deb3ff7 +digest.bundle (??? - ???) /Users/USER/*/digest.bundle
0x10dee7000 - 0x10dee7fef +iso_8859_1.bundle (??? - ???) <25650A08-FF7E-3039-B0D8-98DF75E20660> /Users/USER/*/iso_8859_1.bundle
0x10deea000 - 0x10def4fff +zlib.bundle (??? - ???) /Users/USER/*/zlib.bundle
0x10defa000 - 0x10df1bff7 +rubyeventmachine.bundle (??? - ???) <4679BE7F-4A9F-35D6-8237-CCF20D5910AF> /Users/USER/*/rubyeventmachine.bundle
0x10df32000 - 0x10df51fff +socket.bundle (??? - ???) <0D932B50-C321-3312-A6F6-936CDC2FD8D0> /Users/USER/*/socket.bundle
0x10df5a000 - 0x10df5aff7 +fcntl.bundle (??? - ???) <4D89D3B6-12AA-3EC7-9D9A-3A3DA894F1FB> /Users/USER/*/fcntl.bundle
0x10df5d000 - 0x10df95ff7 +openssl.bundle (??? - ???) /Users/USER/*/openssl.bundle
0x10e2a4000 - 0x10e2a9fe7 +ruby_http_parser.bundle (??? - ???) /Users/USER/*/ruby_http_parser.bundle
0x10e2ad000 - 0x10e2adfff +fiber.bundle (??? - ???) /Users/USER/*/fiber.bundle
0x10e2b0000 - 0x10e2c2fff +nokogiri.bundle (??? - ???) <75EAF5B3-32D2-3F17-8D11-ADB7B981EABC> /Users/USER/*/nokogiri.bundle
0x10e2d5000 - 0x10e2d7ff7 +cparse.bundle (??? - ???) <7046B825-BFCF-30A5-A623-4EECE3A3429A> /Users/USER/*/cparse.bundle
0x10e2da000 - 0x10e2dbfff +unmixer_mri.bundle (??? - ???) <19063943-17C0-367C-8498-D1B12BC969CE> /Users/USER/*/unmixer_mri.bundle
0x10e2de000 - 0x10e2fdff7 +libxml_ruby.bundle (??? - ???) /Users/USER/*/libxml_ruby.bundle
0x10e30b000 - 0x10e331fef +nkf.bundle (??? - ???) <10F07590-1A95-3B2D-A359-86EF913FE3EF> /Users/USER/*/nkf.bundle
0x10e342000 - 0x10e343fff +euc_jp.bundle (??? - ???) /Users/USER/*/euc_jp.bundle
0x10e346000 - 0x10e347fef +shift_jis.bundle (??? - ???) <84C67156-C87B-3ED0-B4DE-581AD62074BD> /Users/USER/*/shift_jis.bundle
0x10e34a000 - 0x10e34afff +utf_16be.bundle (??? - ???) /Users/USER/*/utf_16be.bundle
0x10e34d000 - 0x10e34dfff +utf_32be.bundle (??? - ???) <41EB2719-A159-3BD8-B86B-A06227EE396E> /Users/USER/*/utf_32be.bundle
0x10e350000 - 0x10e351fe7 +utf_16_32.bundle (??? - ???) /Users/USER/*/utf_16_32.bundle
0x7fff6d530000 - 0x7fff6d564ac7 dyld (195.5 - ???) <4A6E2B28-C7A2-3528-ADB7-4076B9836041> /usr/lib/dyld
0x7fff89a17000 - 0x7fff89a1cfff libcache.dylib (47.0.0 - compatibility 1.0.0) /usr/lib/system/libcache.dylib
0x7fff89a69000 - 0x7fff89a6afff libsystem_sandbox.dylib (??? - ???) <8D14139B-B671-35F4-9E5A-023B4C523C38> /usr/lib/system/libsystem_sandbox.dylib
0x7fff89e65000 - 0x7fff89e6bfff libmacho.dylib (800.0.0 - compatibility 1.0.0) /usr/lib/system/libmacho.dylib
0x7fff89f78000 - 0x7fff89f7cfff libmathCommon.A.dylib (2026.0.0 - compatibility 1.0.0) /usr/lib/system/libmathCommon.A.dylib
0x7fff8a3e8000 - 0x7fff8a4ccdef libobjc.A.dylib (228.0.0 - compatibility 1.0.0) /usr/lib/libobjc.A.dylib
0x7fff8a4cd000 - 0x7fff8a5cfff7 libxml2.2.dylib (10.3.0 - compatibility 10.0.0) /usr/lib/libxml2.2.dylib
0x7fff8a5d0000 - 0x7fff8a5d7fff libcopyfile.dylib (85.1.0 - compatibility 1.0.0) <172B1985-F24A-34E9-8D8B-A2403C9A0399> /usr/lib/system/libcopyfile.dylib
0x7fff8a67b000 - 0x7fff8a69bfff libsystem_kernel.dylib (1699.22.73 - compatibility 1.0.0) <69F2F501-72D8-3B3B-8357-F4418B3E1348> /usr/lib/system/libsystem_kernel.dylib
0x7fff8a716000 - 0x7fff8a717fff libdnsinfo.dylib (395.6.0 - compatibility 1.0.0) <718A135F-6349-354A-85D5-430B128EFD57> /usr/lib/system/libdnsinfo.dylib
0x7fff8b579000 - 0x7fff8b5a6fe7 libSystem.B.dylib (159.1.0 - compatibility 1.0.0) <095FDD3C-3961-3865-A59B-A5B0A4B8B923> /usr/lib/libSystem.B.dylib
0x7fff8bbcf000 - 0x7fff8bbd0ff7 libsystem_blocks.dylib (53.0.0 - compatibility 1.0.0) <8BCA214A-8992-34B2-A8B9-B74DEACA1869> /usr/lib/system/libsystem_blocks.dylib
0x7fff8bdde000 - 0x7fff8be20ff7 libcommonCrypto.dylib (55010.0.0 - compatibility 1.0.0) /usr/lib/system/libcommonCrypto.dylib
0x7fff8c0bc000 - 0x7fff8c0f5fe7 libssl.0.9.8.dylib (44.0.0 - compatibility 0.9.8) <79AAEC98-1258-3DA4-B1C0-4120049D390B> /usr/lib/libssl.0.9.8.dylib
0x7fff8c801000 - 0x7fff8c803fff com.apple.TrustEvaluationAgent (2.0 - 1) <1F31CAFF-C1C6-33D3-94E9-11B721761DDF> /System/Library/PrivateFrameworks/TrustEvaluationAgent.framework/Versions/A/TrustEvaluationAgent
0x7fff8d212000 - 0x7fff8d287ff7 libc++.1.dylib (19.0.0 - compatibility 1.0.0) /usr/lib/libc++.1.dylib
0x7fff8d45a000 - 0x7fff8d477ff7 libxpc.dylib (77.17.0 - compatibility 1.0.0) <72A16104-2F23-3C22-B474-1953F06F9376> /usr/lib/system/libxpc.dylib
0x7fff8d5a1000 - 0x7fff8d6adfff libcrypto.0.9.8.dylib (44.0.0 - compatibility 0.9.8) <3A8E1F89-5E26-3C8B-B538-81F5D61DBF8A> /usr/lib/libcrypto.0.9.8.dylib
0x7fff8d7df000 - 0x7fff8d7eaff7 libc++abi.dylib (14.0.0 - compatibility 1.0.0) <8FF3D766-D678-36F6-84AC-423C878E6D14> /usr/lib/libc++abi.dylib
0x7fff8d905000 - 0x7fff8d940ff7 libsystem_info.dylib (??? - ???) <9C8C2DCB-96DB-3471-9DCE-ADCC26BE2DD4> /usr/lib/system/libsystem_info.dylib
0x7fff8d941000 - 0x7fff8da1efef libsystem_c.dylib (763.12.0 - compatibility 1.0.0) /usr/lib/system/libsystem_c.dylib
0x7fff8dafb000 - 0x7fff8db6efff libstdc++.6.dylib (52.0.0 - compatibility 7.0.0) <6BDD43E4-A4B1-379E-9ED5-8C713653DFF2> /usr/lib/libstdc++.6.dylib
0x7fff8dd4a000 - 0x7fff8dd4afff libkeymgr.dylib (23.0.0 - compatibility 1.0.0) <61EFED6A-A407-301E-B454-CD18314F0075> /usr/lib/system/libkeymgr.dylib
0x7fff8ea11000 - 0x7fff8eb06fff libiconv.2.dylib (7.0.0 - compatibility 7.0.0) <5C40E880-0706-378F-B864-3C2BD922D926> /usr/lib/libiconv.2.dylib
0x7fff8ec94000 - 0x7fff8ec96fff libquarantine.dylib (36.0.0 - compatibility 1.0.0) <4C3BFBC7-E592-3939-B376-1C2E2D7C5389> /usr/lib/system/libquarantine.dylib
0x7fff8ece8000 - 0x7fff8ecedfff libcompiler_rt.dylib (6.0.0 - compatibility 1.0.0) <98ECD5F6-E85C-32A5-98CD-8911230CB66A> /usr/lib/system/libcompiler_rt.dylib
0x7fff8f81a000 - 0x7fff8f827fff libexslt.0.dylib (9.13.0 - compatibility 9.0.0) /usr/lib/libexslt.0.dylib
0x7fff8fc63000 - 0x7fff8fc6cff7 libsystem_notify.dylib (80.1.0 - compatibility 1.0.0) /usr/lib/system/libsystem_notify.dylib
0x7fff910a9000 - 0x7fff910b1fff libsystem_dnssd.dylib (??? - ???) <7749128E-D0C5-3832-861C-BC9913F774FA> /usr/lib/system/libsystem_dnssd.dylib
0x7fff910b2000 - 0x7fff912b4fff libicucore.A.dylib (46.1.0 - compatibility 1.0.0) <38CD6ED3-C8E4-3CCD-89AC-9C3198803101> /usr/lib/libicucore.A.dylib
0x7fff9222f000 - 0x7fff9227dfff libauto.dylib (??? - ???) /usr/lib/libauto.dylib
0x7fff928e0000 - 0x7fff9290bff7 libxslt.1.dylib (3.24.0 - compatibility 3.0.0) <8051A3FC-7385-3EA9-9634-78FC616C3E94> /usr/lib/libxslt.1.dylib
0x7fff93953000 - 0x7fff93965ff7 libz.1.dylib (1.2.5 - compatibility 1.0.0) <30CBEF15-4978-3DED-8629-7109880A19D4> /usr/lib/libz.1.dylib
0x7fff94215000 - 0x7fff9421bff7 libunwind.dylib (30.0.0 - compatibility 1.0.0) <1E9C6C8C-CBE8-3F4B-A5B5-E03E3AB53231> /usr/lib/system/libunwind.dylib
0x7fff95ee9000 - 0x7fff95ef3ff7 liblaunch.dylib (392.18.0 - compatibility 1.0.0) <39EF04F2-7F0C-3435-B785-BF283727FFBD> /usr/lib/system/liblaunch.dylib
0x7fff96009000 - 0x7fff9600eff7 libsystem_network.dylib (??? - ???) <5DE7024E-1D2D-34A2-80F4-08326331A75B> /usr/lib/system/libsystem_network.dylib
0x7fff960c2000 - 0x7fff960c3fff libunc.dylib (24.0.0 - compatibility 1.0.0) /usr/lib/system/libunc.dylib
0x7fff96228000 - 0x7fff9622cfff libdyld.dylib (195.5.0 - compatibility 1.0.0) /usr/lib/system/libdyld.dylib
0x7fff9648e000 - 0x7fff9648fff7 libremovefile.dylib (21.0.0 - compatibility 1.0.0) /usr/lib/system/libremovefile.dylib
0x7fff96490000 - 0x7fff9649efff libdispatch.dylib (187.7.0 - compatibility 1.0.0) <712AAEAC-AD90-37F7-B71F-293FF8AE8723> /usr/lib/system/libdispatch.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: 79758
thread_create: 0
thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=61.7M resident=37.0M(60%) swapped_out_or_unallocated=24.7M(40%)
Writable regions: Total=54.3M written=21.2M(39%) resident=32.9M(61%) swapped_out=0K(0%) unallocated=21.5M(39%)

REGION TYPE VIRTUAL
=========== =======
MALLOC 45.8M
MALLOC guard page 32K
STACK GUARD 4K
Stack 64.0M
VM_ALLOCATE 4K
__DATA 1216K
__LINKEDIT 48.3M
__TEXT 13.4M
shared memory 12K
=========== =======
TOTAL 172.7M
~~~

If I run this, i get 'made it here 1' in the output before the segfault
~~~
EM.synchrony do
LOG.debug('made it here 1')
apps = EM::Synchrony::Iterator.new(apps, 2).map do |app, iter|
LOG.debug('made it here 2')
end
EM.stop
pbar.finish
end
~~~

[Related em::synchrony code for iterator](https://github.com/igrigorik/em-synchrony/blob/f07b2a139b/lib/em-synchrony/iterator.rb)

If this is an em::synchrony bug and not an actual EM bug, then I apologize. The segfault trace led me to believe it that EM was the root cause, but it may be that the iterator is simply being used improperly at some abstraction layer between my app and EM (eg. in em:synchrony).

Thanks.