[Haskell-cafe] Debugging embedded ruby interpreter

Simon Marechal simon at banquise.net
Wed May 22 23:36:47 CEST 2013


Hello,

	I am trying to embed a ruby interpreter into my Haskell library. It
didn't seem complicated, and went flawlessly until I tried using it a
lot. Then I got segfaults.

Here is a test program that corrupts the Array object that is being
created :

https://github.com/bartavelle/hruby/blob/271d99e26a5df075b1011e4b30adf6adddd1c8d2/test/roundtrip.hs

Changing line 46 to this makes it work:

v <- pick (listOf arbitrary :: Gen [Double])

And this version makes it fail again :

v <- pick (listOf subvalue :: Gen [Value])

As you can see, the "frequencies" of "subvalue" are set so that only
JSON Values representing Doubles are generated. As the toRuby and
fromRuby instances for Value are just pure wrappers over the instances
for Double, the non-pure code that is executed should be the same. Am I
wrong here ?

Given that there is almost no documentation for doing this Ruby
embedding, I am unsure that I am doing it right. I looked at the Hubris
code and several other sources on the Internet, but can't find what is
wrong with my implementation.

I have no clue on how to debug this. Valgrind gives me a few
"Conditional jump or move depends on uninitialised value(s)" during
Ruby's gc, but I get more or less the same when just running the native
interpreter. Also running this with the multithreaded runtime makes it
fail immediately.

Anyone has an idea on how I should approach this problem ?



More information about the Haskell-Cafe mailing list