# YAML custom load: Segmentation faults

**URL:** <https://rubytalk.org/t/yaml-custom-load-segmentation-faults/12282>\
**Category:** ruby-talk\
**Created:** [25 June 2004 10:42 UTC](https://rubytalk.org/t/yaml-custom-load-segmentation-faults/12282 "2004-06-25T10:42:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kaspar\_Schiess](https://avatars.discourse-cdn.com/v4/letter/k/d78d45/32.png) [@Kaspar\_Schiess](https://rubytalk.org/u/Kaspar_Schiess)\
**Post date:** [25 June 2004 10:42 UTC](https://rubytalk.org/t/yaml-custom-load-segmentation-faults/12282/1 "2004-06-25T10:42:01Z")

</div>

Hello all,

using ruby 1.8.1 (2003-12-25) [i386-mingw32], I get segmentation faults  
using YAML to deserialize a class of my own. The class is registered as  
a domain type in YAML called ! [tua.ch](http://tua.ch),2004/ai/neural. (Yes it is a remake  
of LibNeural).

Here's the deserialization code; I would like to know if I am doing  
something conceptually wrong or if its just YAML who's crashing because  
of a bug when not using objectmaker:

- --------------------------------------  
YAML::add\_domain\_type(AI::NeuralNet::YAMLDOMAIN,  
AI::NeuralNet::YAMLLOCATION) do |type, val|  
~ net = AI::NeuralNet.new( \*val['sizes'] )

~ o = val['output']  
~ o.each\_with\_index do |w, i|  
&nbsp;&nbsp;&nbsp;&nbsp;net.set\_weights(AI::NeuralNet::LAYER\_OUTPUT, i, w)  
~ end

~ h = val['hidden']  
~ h.each\_with\_index do |w, i|  
~ net.set\_weights(AI::NeuralNet::LAYER\_HIDDEN, i, w)  
~ end

~ net  
end  
- ---------------------------------------

Note that the YAML.load call returns an object of type AI::NeuralNet  
with the correct dimensions and weights, but once I try to call into the  
object, I get a

/lib/data/set.rb:158: [BUG] rb\_gc\_mark(): unknown data type  
0x0(0x2a14698) non object  
ruby 1.8.1 (2003-12-25) [i386-mingw32]

I guess the exact location of the bug is not important, because that is  
just the point the garbage collection kicks in.

I am getting rather desperate, and I will have to abolish YAML later in  
the day to finish my work here, but any suggestions on making YAML work  
are welcome.

Best regards,  
kaspar

semantics & semiotics  
code manufacture

[www.tua.ch/ruby](http://www.tua.ch/ruby)

---

<div class="post-metadata">

**Author:** ![ts1](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@ts1](https://rubytalk.org/u/ts1)\
**Post date:** [25 June 2004 10:46 UTC](https://rubytalk.org/t/yaml-custom-load-segmentation-faults/12282/2 "2004-06-25T10:46:11Z")

</div>

> /lib/data/set.rb:158: [BUG] rb\_gc\_mark(): unknown data type  
> 0x0(0x2a14698) non object  
> ruby 1.8.1 (2003-12-25) [i386-mingw32]

> I guess the exact location of the bug is not important, because that is  
> just the point the garbage collection kicks in.

No, it's important.

try to use a recent version of YAML and Syck from CVS

Guy Decoux

---

<div class="post-metadata">

**Author:** ![Kaspar\_Schiess](https://avatars.discourse-cdn.com/v4/letter/k/d78d45/32.png) [@Kaspar\_Schiess](https://rubytalk.org/u/Kaspar_Schiess)\
**Post date:** [25 June 2004 13:01 UTC](https://rubytalk.org/t/yaml-custom-load-segmentation-faults/12282/3 "2004-06-25T13:01:33Z")

</div>

ts wrote:

> > > > > > "K" == Kaspar Schiess \<eule@space.ch\> writes:
> 
> \> /lib/data/set.rb:158: [BUG] rb\_gc\_mark(): unknown data type  
> \> 0x0(0x2a14698) non object  
> \> ruby 1.8.1 (2003-12-25) [i386-mingw32]
> 
> \> I guess the exact location of the bug is not important, because that is  
> \> just the point the garbage collection kicks in.
> 
> No, it's important.
> 
> try to use a recent version of YAML and Syck from CVS
> 
> Guy Decoux

I did, but the problem stayed: Then I checked my code and the error was  
there. So sorry for the detour and thank you for replying.

Nice side-effect is that I have the newest syck installed 😉

Yours,  
kaspar

semantics & semiotics  
code manufacture

www.tua.ch/ruby
