Hi,
I'm trying to embed Ruby into the Ur web programming language.
Everything seems to work fine when using rb_gc_disable().
When not disabling gc it segfaults when requiring 'net/http'.
Then I tried running gc manually and found out that the crash even
happens after initialization.
However it only happens when urweb compiles everything. Compiling a
embed ruby into C test case everything is fine.
What could be causing this?
valgrind log, initialization code:
http://mawercer.de/~marc/crash.txt
Any ideas? Could symbol collisions cause this?
The libruby.so file is used. Ruby version is 1.9.2-p0
The strange thing is that the segfault only happens when being called
within urweb.
Marc Weber
Ammar_Ali
(Ammar Ali)
7 December 2010 00:32
2
Is this a multithreaded environment? If so, it sounds vaguely like the
problem discussed in the following issue:
http://redmine.ruby-lang.org/issues/show/2294
Regards,
Ammar
···
On Mon, Dec 6, 2010 at 6:47 PM, Marc Weber <marco-oweber@gmx.de> wrote:
Hi,
I'm trying to embed Ruby into the Ur web programming language.
Everything seems to work fine when using rb_gc_disable().
When not disabling gc it segfaults when requiring 'net/http'.
Then I tried running gc manually and found out that the crash even
happens after initialization.
However it only happens when urweb compiles everything. Compiling a
embed ruby into C test case everything is fine.
What could be causing this?
valgrind log, initialization code:
http://mawercer.de/~marc/crash.txt
Any ideas? Could symbol collisions cause this?
The libruby.so file is used. Ruby version is 1.9.2-p0
The strange thing is that the segfault only happens when being called
within urweb.
Excerpts from Ammar Ali's message of Tue Dec 07 01:32:12 +0100 2010:
Is this a multithreaded environment? If so, it sounds vaguely like the
problem discussed in the following issue:
http://redmine.ruby-lang.org/issues/show/2294
Wow. I can reproduce the bug by running the initialization code within a
pthread easily now.
Does anybody know which is the correct solution?
I'm protecting ruby by using mutexes - so only one thread will be
evaluating ruby code at any given time.
Where can I find the documentation how to embed Ruby in a multithreaded
environment then?
Marc Weber
Ammar_Ali
(Ammar Ali)
7 December 2010 02:24
4
Mutexes won't help with this problem. The issue here is the GC is not
able to tell where the top of the stack is. If possible, the best
solution is to initialize ruby from main(), that way the GC can figure
out where the stack starts. If that's not possible, as in the case of
a dynamically loadable module, the patch submitted by Suraj Kurapati
in the issue above is worth trying out. Even though it is not
guaranteed to work, it worked for some. The patch basically adds a new
function to ruby that allows the stack bounds to be updated at
runtime. See the fifth note, by Roman Shterenzon, for how to get the
stack bounds of a pthread.
Regards,
Ammar
···
On Tue, Dec 7, 2010 at 3:26 AM, Marc Weber <marco-oweber@gmx.de> wrote:
Excerpts from Ammar Ali's message of Tue Dec 07 01:32:12 +0100 2010:
Is this a multithreaded environment? If so, it sounds vaguely like the
problem discussed in the following issue:
http://redmine.ruby-lang.org/issues/show/2294
Wow. I can reproduce the bug by running the initialization code within a
pthread easily now.
Does anybody know which is the correct solution?
I'm protecting ruby by using mutexes - so only one thread will be
evaluating ruby code at any given time.
Excerpts from Ammar Ali's message of Tue Dec 07 03:24:55 +0100 2010:
guaranteed to work, it worked for some.
Ok thanks. I definitely don't understand all details at this moment.
I'm surprised that such a popular language such as Ruby causes that much
trouble to me in this particular case.
I'm going to try the patch fearing that its causing kind of trouble to
me later
Thank you for your help.
Marc Weber