views:

1708

answers:

5

I'm not exactly sure how to properly debug this but have tried a few different approaches that have chewed up time, but not solved the problem. At least 4 other people in my office can execute this code on identical machines with the same version of ruby and rubygems installed with no error.

Here is the code that I'm executing:

status = Open4::popen4( "swfmill simple stdin stdout" ) do | pid, stdin, stdout, stderr |
  stdin.write( config )
  stdin.close
  bytes = stdout.read
  errors = stderr.read
end

I am getting a "bus error" on this line:

errors = stderr.read

If I comment that line, I get a "Segementation Fault" on this line:

bytes = stdout.read

I'm obviously using the Open4 library and executing an external process. This external process works perfectly when executed directly from the terminal, and also when this Ruby code is run outside of this particular Rails application, even in a different, simpler Rails application.

To reproduce the error, I need only to execute my particular test method like this:

ruby test/unit/swf_generator_test.rb --name test_get_bytes

I am running Snow Leopard Mac OS X 10.6.2 (10C540) on a MacBook Pro with Intel Core 2 Duo 2.53 GHz and 8GB of RAM.

ruby -v && gem -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.2.0]
1.3.5

I executed this code inside of GDB and discovered that my libxml and libxslt libraries were both improperly installed. I was able to get both of these libraries installed and now GDB no longer tells me anything that I can see as helpful. Here is the current output from GDB:

gdb ruby

GNU gdb 6.3.50-20050815 (Apple version gdb-1344) (Fri Jul  3 01:19:56 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .... done

(gdb) run test/unit/swf_generator_test.rb --name test_get_bytes
Starting program: /usr/local/bin/ruby test/unit/swf_generator_test.rb --name test_get_bytes
Reading symbols for shared libraries +++... done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries .. done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries ... done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries .. done
Reading symbols for shared libraries . done
Reading symbols for shared libraries .. done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries .... done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries ... done
Loaded suite test/unit/swf_generator_test
Started
Reading symbols for shared libraries .. done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00007fff81973e90
0x0000000100045bf1 in gc_mark ()
(gdb) 

I have also rebuilt/reinstalled all of my gems after updating my libxml and libxslt libraries. I did this by running:

sudo gem pristine --all

And finally, here is my console log entry for this particular exception:

Process:         ruby [5059]
Path:            /usr/local/bin/ruby
Identifier:      ruby
Version:         ??? (???)
Code Type:       X86-64 (Native)
Parent Process:  bash [5050]

Date/Time:       2010-01-21 11:31:45.468 -0800
OS Version:      Mac OS X 10.6.2 (10C540)
Report Version:  6

Exception Type:  EXC_BAD_ACCESS (SIGABRT)
Exception Codes: KERN_INVALID_ADDRESS at 0x000000000000000e
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Application Specific Information:
abort() called

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   libSystem.B.dylib               0x00007fff819befe6 __kill + 10
1   libSystem.B.dylib               0x00007fff81a5fe32 abort + 83
2   libruby.dylib                   0x000000010001b887 rb_check_type + 0
3   libruby.dylib                   0x00000001000a5427 sigsegv + 84
4   libSystem.B.dylib               0x00007fff819d0eaa _sigtramp + 26
5   ???                             0x00007fff5fbd7410 0 + 140734799639568
6   libruby.dylib                   0x0000000100045a50 mark_tbl + 44
7   libruby.dylib                   0x0000000100045a71 rb_mark_tbl + 31
8   libruby.dylib                   0x0000000100059286 mark_load_arg + 40
9   libruby.dylib                   0x000000010004635f gc_mark_children + 1687
10  libruby.dylib                   0x0000000100045c74 gc_mark + 221
11  libruby.dylib                   0x0000000100045882 mark_locations_array + 61
12  libruby.dylib                   0x00000001000459fc rb_gc_mark_locations + 59
13  libruby.dylib                   0x0000000100047620 garbage_collect + 389
14  libruby.dylib                   0x0000000100044c2d ruby_xmalloc + 107
15  libruby.dylib                   0x0000000100033a76 scope_dup + 100
16  libruby.dylib                   0x000000010002ab7d rb_yield_0 + 2646
17  libruby.dylib                   0x0000000100034dbd proc_invoke + 1020
18  libruby.dylib                   0x0000000100034f73 rb_proc_call + 39
19  libruby.dylib                   0x000000010002e061 call_cfunc + 252
20  libruby.dylib                   0x000000010002d16a rb_call0 + 1548
21  libruby.dylib                   0x000000010002ebca rb_call + 711
22  libruby.dylib                   0x0000000100025dc4 rb_eval + 9919
23  libruby.dylib                   0x00000001000251d0 rb_eval + 6859
24  libruby.dylib                   0x000000010002dc1b rb_call0 + 4285
25  libruby.dylib                   0x000000010002ebca rb_call + 711
26  libruby.dylib                   0x0000000100025dc4 rb_eval + 9919
27  libruby.dylib                   0x00000001000249fc rb_eval + 4855
28  libruby.dylib                   0x000000010002716e rb_eval + 14953
29  libruby.dylib                   0x000000010002a8f8 rb_yield_0 + 2001
30  libruby.dylib                   0x0000000100034dbd proc_invoke + 1020
31  libruby.dylib                   0x0000000100034f73 rb_proc_call + 39
32  libruby.dylib                   0x000000010002e061 call_cfunc + 252
33  libruby.dylib                   0x000000010002d16a rb_call0 + 1548
34  libruby.dylib                   0x000000010002ebca rb_call + 711
35  libruby.dylib                   0x0000000100025dc4 rb_eval + 9919
36  libruby.dylib                   0x00000001000251d0 rb_eval + 6859
37  libruby.dylib                   0x000000010002dc1b rb_call0 + 4285
38  libruby.dylib                   0x000000010002ebca rb_call + 711
39  libruby.dylib                   0x0000000100025dc4 rb_eval + 9919
40  libruby.dylib                   0x00000001000249fc rb_eval + 4855
41  libruby.dylib                   0x000000010002dc1b rb_call0 + 4285
42  libruby.dylib                   0x000000010002ebca rb_call + 711
43  libruby.dylib                   0x00000001000260fb rb_eval + 10742
44  libruby.dylib                   0x0000000100025617 rb_eval + 7954
45  libruby.dylib                   0x000000010002dc1b rb_call0 + 4285
46  libruby.dylib                   0x000000010002ebca rb_call + 711
47  libruby.dylib                   0x0000000100025dc4 rb_eval + 9919
48  libruby.dylib                   0x00000001000270e5 rb_eval + 14816
49  libruby.dylib                   0x000000010002dc1b rb_call0 + 4285
50  libruby.dylib                   0x000000010002ebca rb_call + 711
51  libruby.dylib                   0x000000010002ed88 rb_f_send + 170
52  libruby.dylib                   0x000000010002e080 call_cfunc + 283
53  libruby.dylib                   0x000000010002d16a rb_call0 + 1548
54  libruby.dylib                   0x000000010002ebca rb_call + 711
55  libruby.dylib                   0x00000001000260fb rb_eval + 10742
56  libruby.dylib                   0x0000000100024f5a rb_eval + 6229
57  libruby.dylib                   0x00000001000251d0 rb_eval + 6859
58  libruby.dylib                   0x00000001000251d0 rb_eval + 6859
59  libruby.dylib                   0x000000010002dc1b rb_call0 + 4285
60  libruby.dylib                   0x000000010002ebca rb_call + 711
61  libruby.dylib                   0x0000000100025dc4 rb_eval + 9919
62  libruby.dylib                   0x0000000100035764 block_pass + 460
63  libruby.dylib                   0x000000010002473a rb_eval + 4149
64  libruby.dylib                   0x000000010002a8f8 rb_yield_0 + 2001
65  libruby.dylib                   0x000000010002ad2f rb_yield + 42
66  libruby.dylib                   0x00000001000061e4 rb_ary_each + 100
67  libruby.dylib                   0x000000010002e098 call_cfunc + 307
68  libruby.dylib                   0x000000010002d16a rb_call0 + 1548
69  libruby.dylib                   0x000000010002ebca rb_call + 711
70  libruby.dylib                   0x0000000100025dc4 rb_eval + 9919
71  libruby.dylib                   0x00000001000249fc rb_eval + 4855
72  libruby.dylib                   0x000000010002dc1b rb_call0 + 4285
73  libruby.dylib                   0x000000010002ebca rb_call + 711
74  libruby.dylib                   0x0000000100025dc4 rb_eval + 9919
75  libruby.dylib                   0x0000000100035764 block_pass + 460
76  libruby.dylib                   0x000000010002473a rb_eval + 4149
77  libruby.dylib                   0x000000010002a8f8 rb_yield_0 + 2001
78  libruby.dylib                   0x000000010002ad2f rb_yield + 42
79  libruby.dylib                   0x00000001000061e4 rb_ary_each + 100
80  libruby.dylib                   0x000000010002e098 call_cfunc + 307
81  libruby.dylib                   0x000000010002d16a rb_call0 + 1548
82  libruby.dylib                   0x000000010002ebca rb_call + 711
83  libruby.dylib                   0x0000000100025dc4 rb_eval + 9919
84  libruby.dylib                   0x00000001000249fc rb_eval + 4855
85  libruby.dylib                   0x000000010002dc1b rb_call0 + 4285
86  libruby.dylib                   0x000000010002ebca rb_call + 711
87  libruby.dylib                   0x0000000100025dc4 rb_eval + 9919
88  libruby.dylib                   0x00000001000249fc rb_eval + 4855
89  libruby.dylib                   0x000000010002dc1b rb_call0 + 4285
90  libruby.dylib                   0x000000010002ebca rb_call + 711
91  libruby.dylib                   0x0000000100025dc4 rb_eval + 9919
92  libruby.dylib                   0x0000000100025617 rb_eval + 7954
93  libruby.dylib                   0x000000010002dc1b rb_call0 + 4285
94  libruby.dylib                   0x000000010002ebca rb_call + 711
95  libruby.dylib                   0x000000010002614c rb_eval + 10823
96  libruby.dylib                   0x0000000100025617 rb_eval + 7954
97  libruby.dylib                   0x000000010002dc1b rb_call0 + 4285
98  libruby.dylib                   0x000000010002ebca rb_call + 711
99  libruby.dylib                   0x0000000100025dc4 rb_eval + 9919
100 libruby.dylib                   0x0000000100025617 rb_eval + 7954
101 libruby.dylib                   0x000000010002dc1b rb_call0 + 4285
102 libruby.dylib                   0x000000010002ebca rb_call + 711
103 libruby.dylib                   0x0000000100025dc4 rb_eval + 9919
104 libruby.dylib                   0x0000000100025b16 rb_eval + 9233
105 libruby.dylib                   0x000000010002dc1b rb_call0 + 4285
106 libruby.dylib                   0x000000010002ebca rb_call + 711
107 libruby.dylib                   0x0000000100025dc4 rb_eval + 9919
108 libruby.dylib                   0x000000010002dc1b rb_call0 + 4285
109 libruby.dylib                   0x000000010002ebca rb_call + 711
110 libruby.dylib                   0x0000000100025dc4 rb_eval + 9919
111 libruby.dylib                   0x0000000100025f54 rb_eval + 10319
112 libruby.dylib                   0x000000010002a8f8 rb_yield_0 + 2001
113 libruby.dylib                   0x0000000100034dbd proc_invoke + 1020
114 libruby.dylib                   0x0000000100032ba5 call_end_proc + 230
115 libruby.dylib                   0x0000000100032eea rb_exec_end_proc + 559
116 libruby.dylib                   0x000000010002051c ruby_finalize_0 + 170
117 libruby.dylib                   0x00000001000205ab ruby_cleanup + 57
118 libruby.dylib                   0x00000001000208c8 ruby_stop + 19
119 libruby.dylib                   0x0000000100020937 compile_error + 0
120 ruby                            0x0000000100000ebe dyld_stub_exit + 0
121 ruby                            0x0000000100000e74 start + 52

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x00007fff5fbd7318  rcx: 0x00007fff5fbd6a68  rdx: 0x0000000000000000
  rdi: 0x00000000000013c3  rsi: 0x0000000000000006  rbp: 0x00007fff5fbd6a80  rsp: 0x00007fff5fbd6a68
   r8: 0x0000000000000002   r9: 0x0000000000000000  r10: 0x00007fff819bb026  r11: 0x0000000000000202
  r12: 0x0000000000000000  r13: 0x0000000000000000  r14: 0x0000000000000000  r15: 0x0000000000000000
  rip: 0x00007fff819befe6  rfl: 0x0000000000000202  cr2: 0x00007fff702e71f0

Binary Images:
       0x100000000 -        0x100000fff +ruby ??? (???) <C71E7FFC-4129-BB10-8FCE-28CE6753E31E> /usr/local/bin/ruby
       0x100003000 -        0x1000fefef +libruby.dylib ??? (???) <A02414BE-9EFE-F690-D8C0-997BC2330549> /usr/local/lib/libruby.dylib
       0x1001e1000 -        0x1001e4fff +thread.bundle ??? (???) <CB4AF257-267F-182F-66B6-8A56E01A3843> /usr/local/lib/ruby/1.8/i686-darwin10.0.0/thread.bundle
       0x1001e8000 -        0x1001e9ff7 +etc.bundle ??? (???) <356F8541-C0F9-1A34-2C0A-A24035D55960> /usr/local/lib/ruby/1.8/i686-darwin10.0.0/etc.bundle
       0x1001ed000 -        0x1001f1ff7 +stringio.bundle ??? (???) <5890BE07-0D66-D7E5-B87B-37A0B06A901D> /usr/local/lib/ruby/1.8/i686-darwin10.0.0/stringio.bundle
       0x1001f5000 -        0x1001f9ff7 +strscan.bundle ??? (???) <E6F3DCE7-603E-9472-9C6D-99CD225C494C> /usr/local/lib/ruby/1.8/i686-darwin10.0.0/strscan.bundle
       0x1001fd000 -        0x1001fdfff +fcntl.bundle ??? (???) <0F2B8F5B-9F5F-0F82-D1B8-7AB339B5ADA3> /usr/local/lib/ruby/1.8/i686-darwin10.0.0/fcntl.bundle
       0x1004b0000 -        0x1004d0fff +syck.bundle ??? (???) <D34A7A9E-C28F-77A5-F95E-5F8A22F19676> /usr/local/lib/ruby/1.8/i686-darwin10.0.0/syck.bundle
       0x1004d8000 -        0x1004e5ff7 +bigdecimal.bundle ??? (???) <D9C91EF5-3814-8624-6601-23BF6AD032A3> /usr/local/lib/ruby/1.8/i686-darwin10.0.0/bigdecimal.bundle
       0x1004e9000 -        0x1004eaff7 +fast_xs.bundle ??? (???) <7A793C27-7A68-F8E2-DFAB-9F4ABADBBC14> /usr/local/lib/ruby/gems/1.8/gems/hpricot-0.8.2/lib/fast_xs.bundle
       0x1004ed000 -        0x1004f5ff7 +zlib.bundle ??? (???) <83CB4E6E-F717-CB1F-D410-BC6F305B4AF4> /usr/local/lib/ruby/1.8/i686-darwin10.0.0/zlib.bundle
       0x1004fa000 -        0x1004fafff +md5.bundle ??? (???) <71A83C69-A0CB-3682-18E2-09B644E687D5> /usr/local/lib/ruby/1.8/i686-darwin10.0.0/digest/md5.bundle
       0x1004fd000 -        0x1004fdfff +sha1.bundle ??? (???) <049D08F4-BC16-D2E7-04B9-CBB1E89CC01D> /usr/local/lib/ruby/1.8/i686-darwin10.0.0/digest/sha1.bundle
       0x10073d000 -        0x10076efff +nkf.bundle ??? (???) <CB4E2B49-D8D7-29B2-9215-67BECCD45AA3> /usr/local/lib/ruby/1.8/i686-darwin10.0.0/nkf.bundle
       0x100781000 -        0x10078bfff +socket.bundle ??? (???) <431898C6-794A-BF22-A125-B7D60D554CDA> /usr/local/lib/ruby/1.8/i686-darwin10.0.0/socket.bundle
       0x100790000 -        0x100791fff +digest.bundle ??? (???) <955B9322-A593-9926-110F-449CBDA89DF9> /usr/local/lib/ruby/1.8/i686-darwin10.0.0/digest.bundle
       0x100795000 -        0x1007a1fff +bluecloth_ext.bundle ??? (???) <875327C8-E817-9F12-0EE4-6A49562C3F8E> /usr/local/lib/ruby/gems/1.8/gems/bluecloth-2.0.5/lib/bluecloth_ext.bundle
       0x1007a6000 -        0x1007e2ff7 +openssl.bundle ??? (???) <499510E9-913B-A675-3075-9A0AEC5634B8> /usr/local/lib/ruby/1.8/i686-darwin10.0.0/openssl.bundle
       0x10123a000 -        0x1012abfff +redcloth_scan.bundle ??? (???) <96734FEE-7F82-4F10-D8C2-DA1FDC433DAC> /usr/local/lib/ruby/gems/1.8/gems/RedCloth-4.2.2/lib/redcloth_scan.bundle
       0x1012af000 -        0x1012b2ff7 +cparse.bundle ??? (???) <EF75611D-1C93-CF58-C128-85D7CF8A061B> /usr/local/lib/ruby/1.8/i686-darwin10.0.0/racc/cparse.bundle
       0x1012b5000 -        0x1012b7ff7 +iconv.bundle ??? (???) <BDB48C60-66D8-036F-D6E9-F7669CBDA16C> /usr/local/lib/ruby/1.8/i686-darwin10.0.0/iconv.bundle
       0x1012bb000 -        0x1012bffff +parser.bundle ??? (???) <261FDCD0-29C8-8A3B-9B72-D4BC51715B67> /usr/local/lib/ruby/gems/1.8/gems/json-1.1.3/ext/json/ext/parser.bundle
       0x1012c3000 -        0x1012c7ff7 +generator.bundle ??? (???) <B354DFF3-AE88-AC13-2D6A-C8827C0033F2> /usr/local/lib/ruby/gems/1.8/gems/json-1.1.3/ext/json/ext/generator.bundle
       0x1012cb000 -        0x1012dafff +nokogiri.bundle ??? (???) <81F28AEC-FF97-8911-4728-9253F14205F3> /usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.4.1/lib/nokogiri/nokogiri.bundle
       0x1012eb000 -        0x1012f2ff7 +ruby_debug.bundle ??? (???) <2AA2B821-3C45-14A6-9573-38D651556B36> /Users/lbayes/.gem/ruby/1.8/gems/ruby-debug-base-0.10.3/lib/ruby_debug.bundle
       0x1012f7000 -        0x1012f9fff +trace_nums.bundle ??? (???) <70D184EC-461F-D2E6-8094-B56FB2BACE83> /Users/lbayes/.gem/ruby/1.8/gems/linecache-0.43/ext/trace_nums.bundle
       0x101802000 -        0x101815fe7 +libexslt.0.dylib ??? (???) <FD064ED5-7CC6-E58E-00DD-06775F1BBE72> /usr/local/lib/libexslt.0.dylib
       0x10181b000 -        0x10185bff7 +libxslt.1.dylib ??? (???) <8A989A1C-85AE-2CE9-068A-C6DCDF839566> /usr/local/lib/libxslt.1.dylib
       0x101867000 -        0x101869ff7 +readline.bundle ??? (???) <79F5B425-0C27-CF59-2EE6-E05AFE3EF850> /usr/local/lib/ruby/1.8/i686-darwin10.0.0/readline.bundle
       0x10186d000 -        0x101889ff7  libedit.2.dylib ??? (???) <F9D005F8-74B8-CC05-2697-24C49E0CC1EF> /usr/lib/libedit.2.dylib
       0x101898000 -        0x1018a6fff +sqlite3_api.bundle ??? (???) <50ED247E-9C93-8CA1-8E7E-18F715A60DE9> /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.5/lib/sqlite3_api.bundle
       0x103900000 -        0x103a83fe7 +libxml2.2.dylib ??? (???) <0B99B8DC-820C-FCE2-B37E-3D4B6BA67EDE> /usr/local/lib/libxml2.2.dylib
    0x7fff5fc00000 -     0x7fff5fc3bdef  dyld 132.1 (???) <B633F790-4DDB-53CD-7ACF-2A3682BCEA9F> /usr/lib/dyld
    0x7fff808d1000 -     0x7fff808d2ff7  com.apple.TrustEvaluationAgent 1.1 (1) <51867586-1C71-AE37-EAAD-535A58DD3550> /System/Library/PrivateFrameworks/TrustEvaluationAgent.framework/Versions/A/TrustEvaluationAgent
    0x7fff81877000 -     0x7fff8196ffe7  libiconv.2.dylib ??? (???) <ECEE3D93-B5E3-F0E0-803E-CA3DC3B33D57> /usr/lib/libiconv.2.dylib
    0x7fff81970000 -     0x7fff81b2eff7  libSystem.B.dylib ??? (???) <526DD3E5-2A8B-4512-ED97-01B832369959> /usr/lib/libSystem.B.dylib
    0x7fff833f5000 -     0x7fff834aefff  libsqlite3.dylib ??? (???) <5A15E12A-AE8F-1A36-BBC7-564E7D7AD0FB> /usr/lib/libsqlite3.dylib
    0x7fff85363000 -     0x7fff853e0fef  libstdc++.6.dylib ??? (???) <35ECA411-2C08-FD7D-11B1-1B7A04921A5C> /usr/lib/libstdc++.6.dylib
    0x7fff853e1000 -     0x7fff853f2fef  libz.1.dylib ??? (???) <3A7A4C48-A4C8-A78A-8B87-C0DDF6601AC8> /usr/lib/libz.1.dylib
    0x7fff85cf9000 -     0x7fff85d38fef  libncurses.5.4.dylib ??? (???) <E0A07C12-D912-DF26-9E38-C50484D96EB0> /usr/lib/libncurses.5.4.dylib
    0x7fff86662000 -     0x7fff86783fe7  libcrypto.0.9.8.dylib ??? (???) <32F2A87F-B146-BBF2-3AD1-494C686F1EE3> /usr/lib/libcrypto.0.9.8.dylib
    0x7fff87f25000 -     0x7fff87f5ffff  libssl.0.9.8.dylib ??? (???) <0714FA32-C193-CD96-80D1-6FCF06A0ED2E> /usr/lib/libssl.0.9.8.dylib
    0x7fff886ad000 -     0x7fff886f9fff  libauto.dylib ??? (???) <072804DF-36AD-2DBE-7EF8-639CFB79077F> /usr/lib/libauto.dylib
    0x7fff88894000 -     0x7fff8894afff  libobjc.A.dylib ??? (???) <F206BE6D-8777-AE6C-B367-7BEA76C14241> /usr/lib/libobjc.A.dylib
    0x7fff88c99000 -     0x7fff88c9dff7  libmathCommon.A.dylib ??? (???) <95718673-FEEE-B6ED-B127-BCDBDB60D4E5> /usr/lib/system/libmathCommon.A.dylib
    0x7fffffe00000 -     0x7fffffe01fff  libSystem.B.dylib ??? (???) <526DD3E5-2A8B-4512-ED97-01B832369959> /usr/lib/libSystem.B.dylib
A: 

It sounds like these are hardware errors rather than software errors. Get your machine checked out, especially the memory.

Mick Sharpe
Thanks for the response Mick. I could be mistaken here, but if it were a problem with physical memory wouldn't it be more inconsistent or intermittent? Wouldn't I also experience even worse crashes in other environments? Wouldn't restarting the machine likely make it go away for awhile?As it stands, the error occurs every single time I execute this particular line of code in this particular environment, even after multiple restarts - but not in any other application.
Luke Bayes
A: 

Sounds like you have the wrong gem version, or it's incompatible with MacOS. From the RDoc:

Users of Linux, Unix, BSD, etc., will want the unix package. Ara’s Open4 gem is a dependency. Users of the Ruby One-Click Installer (OCI) will want to select the gem appropriate their version of Ruby. The real issue here is compiler version. The wrong version will SEGFAULT due to some incompatibility somewhere in the VC++ compiler or libraries

klochner
It turns out, I'm not using the POpen4 gem (it's not installed either), I am using Ara Howard's Open4 gem and calling popen4 on that. Based on your response, I tried uninstalling and reinstalling the open4 gem which did upgrade the version number I had installed (from 0.9.6 to 1.0.1). Alas - still crashing.
Luke Bayes
Does the gem work with other commands (besides swfmill)?
klochner
Yes, the Open.popen4 code works great with other executables and it _even_ works with swfmill when run outside of this Rails application. Even with the exact same values being sent to it.I'm starting to suspect some dynamically linked library interacting across loaded/activated gems?
Luke Bayes
What do you get with /usr/local/bin/ruby -v
klochner
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.2.0]
Luke Bayes
My next move would be to make sure the gem is ok with your 64 bit processor. c extensions can run into trouble if they're compiled for the wrong architecture. I suggest you check out the project page and contact the gem author - http://rubyforge.org/projects/codeforpeople/ sorry i couldn't be of more help, but this is a nasty one
klochner
+1  A: 

I don't have a solution, but I've identified a way to reproduce this issue.

After installing the ruby-debug-0.10.3 gem today, my Rails 2.1.1 test that calls 'stderr.read' within an

Open4::popen4( "FOO" ) do | pid, stdin, stdout, stderr |
    stderr.read
end

block has started throwing same '[BUG] Bus Error ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.2.0]' that you're getting.

If I 'sudo gem uninstall ruby-debug', the test runs and passes. If I then 'sudo gem install ruby-debug' again, the test throws.

I'm running a Rails 2.1.1 project on Snow Leopard with Ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.2.0] installed.

Rebuilding the ruby-debug gem for 64-bit isn't fixing the issue for me.

alimills
I get exactly the same behavior on my system.
Luke Bayes
+2  A: 

I just ran into a similar issue myself.

It's typically caused by a gem with natively compiled bits that's loading a library compiled for a different architecture. (Sounds like you've been down that path already.)

Unfortunately, this also includes libraries that are compiled as universal binaries.

In my case the problem was caused because Ruby was loading the wrong version of OpenSSL. Perhaps the problem is similar for you. Based on the answers above it sounds like ruby-debug is causing the problem. Could it be linking against the wrong library?

Here are some links about the problem that helped me:

Luke Francl
Thanks Luke - it turns out it was caused by recent releases of ruby-debug. I filed a bug with that project and for now the workaround is to install an older version...
Luke Bayes
+3  A: 

Ok, I've fixed this on my machine. I'm not sure exactly why, but downgrading the ruby-debug gem to version 0.10.0 solves the problem for me.

The specific fix is running the following commands:

sudo gem uninstall ruby-debug

sudo gem install ruby-debug --version 0.10.0
alimills
Luke Bayes