I was testing the cassandra Ruby gem in Lion with Xcode 4.2, with Ruby 1.9.3-rc1 and clang (according to the rc1 NEWS file 1.9.3 must be compiled with clang when using Xcode 4.2) and kept getting this error:
Abort trap: 6 Running Ruby under gdb allowed me to trace it to a function inside lib/rb/ext/struct.c, Thrift version 0.7.0, as installed by thrift gem: #0 0x00007fff9504bce2 in __pthread_kill () #1 0x00007fff93d617d2 in pthread_kill () #2 0x00007fff93d52b4a in __abort () #3 0x00007fff93d4f070 in __stack_chk_fail () #4 0x000000010077a417 in set_field_value (obj=<value temporarily unavailable, due to optimizations>, field_name=<value temporarily unavailable, due to optimizations>, value=<value temporarily unavailable, due to optimizations>) at struct.c:426 #5 0x0000000100779141 in rb_thrift_struct_read (self=4306092880, protocol=4306073480) at struct.c:592 #6 0x0000000100779cb9 in read_anything (protocol=4306073480, ttype=<value temporarily unavailable, due to optimizations>, field_info=<value temporarily unavailable, due to optimizations>) at struct.c:469 #7 0x0000000100779a5a in read_anything (protocol=4306073480, ttype=<value temporarily unavailable, due to optimizations>, field_info=4304975600) at struct.c:522 #8 0x0000000100779132 in rb_thrift_struct_read (self=4306096120, protocol=4306073480) at struct.c:592 #9 0x0000000100779cb9 in read_anything (protocol=4306073480, ttype=<value temporarily unavailable, due to optimizations>, field_info=<value temporarily unavailable, due to optimizations>) at struct.c:469 #10 0x0000000100779132 in rb_thrift_struct_read (self=4306097000, protocol=4306073480) at struct.c:592 #11 0x000000010013e7c5 in vm_call_cfunc [inlined] () at /Users/ccm/.rvm/src/ruby-1.9.3-rc1/vm_insnhelper.c:404 #12 0x000000010013e7c5 in vm_call_method (th=0x100301b10, cfp=0x1004ffb30, num=1, blockptr=0x0, flag=<value temporarily unavailable, due to optimizations>, id=<value temporarily unavailable, due to optimizations>, me=<value temporarily unavailable, due to optimizations>, recv=<value temporarily unavailable, due to optimizations>) at vm_insnhelper.c:534 #13 0x000000010012f5ee in vm_exec_core (th=0x100301b10, initial=<value temporarily unavailable, due to optimizations>) at vm.inc:1015 #14 0x0000000100138c94 in vm_exec (th=0x100301b10) at vm.c:1220 #15 0x00000001001395ab in rb_iseq_eval_main (iseqval=4304251720) at vm.c:1461 #16 0x000000010003701f in ruby_exec_internal (n=<value temporarily unavailable, due to optimizations>) at eval.c:204 #17 0x0000000100036f67 in ruby_run_node (n=0x1008dab48) at eval.c:251 #18 0x0000000100000edf in main (argc=2, argv=0x7fff5fbff838) at main.c:38 >From what I could deduce get_field_value and set_field_value in struct.c allocate a temporary char[] of RSTRING_LEN+1 chars, which is not enough to hold the field name plus the "@" plus the terminating "\0". I changed it to allocate an extra char, and changed the value passed to strlcpy to be the actual length of the property name plus one char to allow for the final \0, and it works for me now. I've filled a bug in JIRA with an attached patch for 0.7.0 and 0.8.0: https://issues.apache.org/jira/browse/THRIFT-1400 Thank you for Thrift!
