I'm attempting to wrap a small library I've written in c, and I think I'm on the home stretch to getting it working. The library has some pretty solid tests around it, and I've ran it through valgrind to remove any memory leaks and glaring issues. It works pretty solid on it's own.
However, when I attempt to wrap it using ruby it segfaults. Here's an example project that wraps the library. When the tests in that project are ran, the call to the library segfaults. Running it results in a core abort which I've loaded in gdb to debug, but I'm not sure what's wrong. The core dump says the issue is on this line, but I have no idea what's causing it since the information given is pretty sparse and the code runs well if I run the tests in c land.
The line that the core dump says is segfaulting:
assert( yypParser->yytos!=0 );
You can reproduce it by running rake
from the root directory which kicks of a process that ultimately generates a shared object that is loaded by the tests. I'm hoping someone with more experience in c can take a look and potentially point me in the right direction.
Please let me know if any more information is needed.
Snippet from the core dump:
#0 0x00007f150caa2c37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x00007f150caa6028 in __GI_abort () at abort.c:89
#2 0x00007f150dba8d8d in die () at error.c:407
#3 rb_bug_context (ctx=ctx@entry=0x7f150f3b1b80, fmt=fmt@entry=0x7f150dbe2f6a "Segmentation fault at %p") at error.c:437
#4 0x00007f150daa45ce in sigsegv (sig=<optimized out>, info=0x7f150f3b1cb0, ctx=0x7f150f3b1b80) at signal.c:890
#5 <signal handler called>
#6 0x00007f150b96b02b in Parse (yyp=0xf9925e0, yymajor=20, yyminor=..., state=0x7ffe17b6a3a0) at parser.c:1919
#7 0x00007f150b96b8e8 in numerize (data=data@entry=0x7f150b96c1aa "one", state=state@entry=0x7ffe17b6a3a0) at ../../../../ext/example_project/fast_numerizer/fast_numerizer.c:102
#8 0x00007f150b960e0b in example_project_c_code_function () at ../../../../ext/example_project/./example_project.c:11