From: Dominik Bathon Date: 2006-08-01T09:19:35+09:00 Subject: Re: Ruby2CExtension (Was: converting some autogenerated ruby code to C) On Tue, 01 Aug 2006 01:19:57 +0200, Eric Hodel wrote: > On Jul 31, 2006, at 12:54 PM, Dominik Bathon wrote: > >> You could try Ruby2CExtension (http://ruby2cext.rubyforge.org/), it is >> similar to rubyToRubyC but supports blocks and closures and tries to >> match Ruby's semantics as close as possible. It can handle most Ruby >> code. > > I tried it, it doesn't work. Thanks for the report. > $ svn info . | egrep 'Revision|URL' > URL: svn://rubyforge.org/var/svn/ruby2cext/trunk > Revision: 10 > $ svn info ../../rubynode/trunk/ | egrep 'Revision|URL' > URL: svn://rubyforge.org/var/svn/rubynode/trunk > Revision: 4 > $ ruby stuff/builtin_methods_test.rb > 433 > cc -dynamic -bundle -undefined suppress -flat_namespace -fno-common -O > -pipe -fno-common -g -I. -I /usr/local/lib/ruby/1.8/powerpc-darwin8.7.0 > -o bm_test.bundle bm_test.c -lruby185-static -ldl -lobjc > $ ruby -rbm_test -e0 > ./bm_test.bundle: [BUG] Bus Error > ruby 1.8.5 (2006-07-25) [powerpc-darwin8.7.0] This might be the problem, it is explicitly only for 1.8.4 (the official release). There seem to have been some changes with rbconfig so the build command (the line below 433) might be wrong. Future versions will support 1.8.5. > Abort trap > $ gdb `which ruby` > GNU gdb 6.3.50-20050815 (Apple version gdb-477) (Sun Apr 30 20:06:22 GMT > 2006) > 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 "powerpc-apple-darwin"...Reading symbols for > shared libraries ... done > > (gdb) run -r bm_test -e0 > Starting program: /usr/local/bin/ruby -r bm_test -e0 > Reading symbols for shared libraries .. done > Reading symbols for shared libraries . done > > Program received signal EXC_BAD_ACCESS, Could not access memory. > Reason: KERN_PROTECTION_FAILURE at address: 0x00000000 > st_lookup (table=0x0, key=6005024, value=0xbfffe918) at st.c:250 > 250 hash_val = do_hash(key, table); > (gdb) bt > #0 st_lookup (table=0x0, key=6005024, value=0xbfffe938) at st.c:250 > #1 0x00566c04 in rb_intern (name=0x5ba120 "abs") at parse.y:6006 This line is if (st_lookup(sym_tbl, (st_data_t)name, (st_data_t *)&id)) So sym_tbl seems to be NULL, which definitely shouldn't be the case, so as I said, I think it's a build problem. Could you please try to build bm_test.c with the following extconf.rb (with ruby 1.8.5 (2006-07-25) [powerpc-darwin8.7.0]): require "mkmf" create_makefile "bm_test" And please also post the output of make. And could you also try with 1.8.4 official release? Thanks, Dominik > #2 0x005061c4 in init_syms () at bm_test.c:9 > #3 0x0051b584 in Init_bm_test () at bm_test.c:7131 > #4 0x0001fe0c in dln_load (file=0x420a50 "./bm_test.bundle") at > dln.c:1480 > #5 0x0001c390 in rb_require_safe (fname=3299340, safe=0) at eval.c:7165 > #6 0x000030e0 in rb_protect (proc=0x1c4e0 , data=4326896, > state=0xbffff208) at eval.c:5427 > #7 0x000666e4 in require_libraries () at ruby.c:356 > #8 0x00067d24 in proc_options (argc=0, argv=0x5ba120) at ruby.c:812 > #9 0x00067ef4 in ruby_process_options (argc=3, argv=0xbffff7a8) at > ruby.c:1199 > #10 0x00015b44 in ruby_options (argc=3, argv=0xbffff7a8) at eval.c:1523 > #11 0x00002358 in main (argc=3, argv=0xbffff7a8, envp=0xbfffe938) at > main.c:45 >