# Problem using YAML

**URL:** <https://rubytalk.org/t/problem-using-yaml/11602>\
**Category:** ruby-talk\
**Created:** [18 May 2004 15:24 UTC](https://rubytalk.org/t/problem-using-yaml/11602 "2004-05-18T15:24:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carol\_Almquist](https://avatars.discourse-cdn.com/v4/letter/c/c0e974/32.png) [@Carol\_Almquist](https://rubytalk.org/u/Carol_Almquist)\
**Post date:** [18 May 2004 15:24 UTC](https://rubytalk.org/t/problem-using-yaml/11602/1 "2004-05-18T15:24:11Z")

</div>

I am using ruby 1.8.1 and yaml to store data records. After a few minutes I  
get one of the following error messages.

/usr/lib/ruby/1.8/yaml.rb:39: [BUG] rb\_gc\_mark(): unknown data type  
0x0(0x40184108) non object  
ruby 1.8.1 (2003-12-25) [i686-linux]

Aborted

OR

/usr/lib/ruby/1.8/yaml.rb:193: [BUG] Segmentation fault  
ruby 1.8.1 (2003-12-25) [i686-linux]

Aborted

I am using two threads to access the data I am writing. Here is my file …

require 'thread’  
require 'yaml’  
require ‘yaml/store’

$dataMutex = Mutex.new

class DataClass

```
def initialize( time, device, countOne=0, countTwo=0 )
	@time = time
	@device = device
	@countOne = countOne
	@countTwo = countTwo
end

def getName
	"device#{@device.to_s}"
end

def writeInfo
	begin
		ext = sprintf( "%2.2d%2.2d%2.2d%2.2d%2.2d%2.2d",

```

@time.year, @time.mon, @time.day, @time.hour, @time.min, @time.sec )  
filename = getName + “.” + ext  
store = YAML::Store.new( filename )  
print "file: #{filename}\n"  
store.transaction do  
store[‘Device’] = @device  
store[‘Time’] = @time  
store[‘countOne’] = @countOne  
store[‘countTwo’] = @countTwo  
end  
rescue =\> e  
print "message #{e.message} backtrace  
#{e.backtrace}"  
end  
end  
end

def doThreadOne  
begin  
doThreadTwo  
while true do  
$dataMutex.synchronize do  
$dataArray.each do |dataItem|  
print "ThreadOne: writeInfo\n"  
dataItem.writeInfo  
end  
sleep 0.2  
end  
end  
rescue =\> e  
print "message #{e.message} backtrace #{e.backtrace}"  
end  
end

def doThreadTwo  
begin  
$ThreadTwo = Thread.new do  
while true do  
$dataMutex.synchronize do  
$dataArray.each do |dataItem|  
print "ThreadTwo:  
writeInfo\n"  
dataItem.writeInfo  
end  
sleep 0.2  
end  
end  
end  
rescue =\> e  
print "message #{e.message} backtrace #{e.backtrace}"  
end  
end

$dataArray = []  
begin  
for channel in 0…23  
t = Time.now  
$dataArray[channel] = DataClass.new( t, channel )  
end

```
doThreadOne

```

rescue =\> e  
end

Any suggestions or hints??

Thanks–  
Carol Almquist

---

<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:** [18 May 2004 15:46 UTC](https://rubytalk.org/t/problem-using-yaml/11602/2 "2004-05-18T15:46:35Z")

</div>

> ruby 1.8.1 (2003-12-25) [i686-linux]

Try a newer version for ruby

Guy Decoux

---

<div class="post-metadata">

**Author:** ![why\_the\_lucky\_stiff1](https://avatars.discourse-cdn.com/v4/letter/w/898d66/32.png) [@why\_the\_lucky\_stiff1](https://rubytalk.org/u/why_the_lucky_stiff1)\
**Post date:** [18 May 2004 20:17 UTC](https://rubytalk.org/t/problem-using-yaml/11602/3 "2004-05-18T20:17:36Z")

</div>

Carol Almquist wrote:

> I am using ruby 1.8.1 and yaml to store data records. After a few minutes I  
> get one of the following error messages.
> 
> /usr/lib/ruby/1.8/yaml.rb:39: [BUG] rb\_gc\_mark(): unknown data type  
> 0x0(0x40184108) non object  
> ruby 1.8.1 (2003-12-25) [i686-linux]
> 
> Aborted
> 
> OR
> 
> /usr/lib/ruby/1.8/yaml.rb:193: [BUG] Segmentation fault  
> ruby 1.8.1 (2003-12-25) [i686-linux]
> 
> Aborted

I’ll try this out on my Linux box at home later this evening. It ran  
great for an hour on my FreeBSD machine, until I killed it. I’m running  
today’s snapshot of 1.9.0. Still, the extension code should be the same  
on the snapshot you checked out.

I thought the ‘non object’ bug was fixed a few weeks ago. Let’s make  
sure your extension is installing properly. What does your  
YAML::Syck::VERSION read?

\_why

---

<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:** [19 May 2004 08:08 UTC](https://rubytalk.org/t/problem-using-yaml/11602/4 "2004-05-19T08:08:42Z")

</div>

> I thought the 'non object' bug was fixed a few weeks ago. Let's make  
> sure your extension is installing properly. What does your  
> YAML::Syck::VERSION read?

0.44 with ruby-1.8.2 : it don't crash but hang. Sometimes very quickly,  
sometimes after a very long time.

file: device14.20040519100437  
ThreadOne: writeInfo  
file: device15.20040519100437  
ThreadOne: writeInfo  
file: device16.20040519100437

Program received signal SIGINT, Interrupt.  
0x080a1b79 in st\_foreach (table=0x42138e0c, func=0x8069b74 \<mark\_entry\>, arg=1)  
&nbsp;&nbsp;&nbsp;&nbsp;at st.c:495  
495 retval = (\*func)(ptr-\>key, ptr-\>record, arg);  
(gdb) bt 24  
#0 0x080a1b79 in st\_foreach (table=0x42138e0c, func=0x8069b74 \<mark\_entry\>,  
&nbsp;&nbsp;&nbsp;&nbsp;arg=1) at st.c:495  
#1 0x08069baa in mark\_tbl (tbl=0x42138e44, lev=0) at gc.c:640  
#2 0x08069db5 in gc\_mark\_children (ptr=1108577804, lev=0) at gc.c:892  
#3 0x08069d8f in gc\_mark\_children (ptr=1108577812, lev=0) at gc.c:887  
#4 0x08069d8f in gc\_mark\_children (ptr=1108577820, lev=0) at gc.c:887  
#5 0x08069d8f in gc\_mark\_children (ptr=1108577828, lev=0) at gc.c:887  
#6 0x08069d8f in gc\_mark\_children (ptr=1108577836, lev=0) at gc.c:887  
#7 0x08069d8f in gc\_mark\_children (ptr=1108577844, lev=0) at gc.c:887  
#8 0x08069d8f in gc\_mark\_children (ptr=1108577852, lev=0) at gc.c:887  
#9 0x08069d8f in gc\_mark\_children (ptr=1108577860, lev=0) at gc.c:887  
#10 0x08069d38 in rb\_gc\_mark (ptr=1108577860) at gc.c:720  
#11 0x400b487e in syck\_mark\_parser (parser=0x816f268) at rubyext.c:749  
#12 0x08069ecb in gc\_mark\_children (ptr=1074243824, lev=0) at gc.c:926  
#13 0x08069af8 in mark\_locations\_array (x=0xbfff5334, n=9014) at gc.c:608  
#14 0x0806a996 in rb\_gc () at gc.c:1328  
#15 0x08069861 in rb\_newobj () at gc.c:386  
#16 0x0806b8a2 in hash\_alloc (klass=0) at hash.c:183  
#17 0x0806b901 in rb\_hash\_new () at hash.c:195  
#18 0x400b4921 in syck\_parser\_new (argc=0, argv=0x0, class=1074314424)  
&nbsp;&nbsp;&nbsp;&nbsp;at rubyext.c:772  
#19 0x080654a3 in call\_cfunc (func=0x400b4890 \<syck\_parser\_new\>,  
&nbsp;&nbsp;&nbsp;&nbsp;recv=1074314424, len=1108577860, argc=0, argv=0x3) at eval.c:5375  
#20 0x0805afcd in rb\_call0 (klass=1074314404, recv=1074314424, id=3369, oid=0,  
&nbsp;&nbsp;&nbsp;&nbsp;argc=0, argv=0x0, body=0x4008bc2c, nosuper=0) at eval.c:5512  
#21 0x0805b7c1 in rb\_call (klass=1074314404, recv=1074314424, mid=3369,  
&nbsp;&nbsp;&nbsp;&nbsp;argc=0, argv=0x0, scope=0) at eval.c:5733  
#22 0x0805700d in rb\_eval (self=1074317664, n=0x0) at eval.c:3249  
#23 0x08056f09 in rb\_eval (self=1074317664, n=0x0) at eval.c:3241  
(More stack frames follow...)  
(gdb) up 11  
#11 0x400b487e in syck\_mark\_parser (parser=0x816f268) at rubyext.c:749  
749 rb\_gc\_mark(parser-\>root);  
(gdb) p \*parser  
$1 = {root = 1108577860, root\_on\_error = 4, implicit\_typing = 1,  
&nbsp;&nbsp;taguri\_expansion = 0, handler = 0, error\_handler = 0,  
&nbsp;&nbsp;bad\_anchor\_handler = 0, input\_type = syck\_yaml\_utf8, io\_type = syck\_io\_str,  
&nbsp;&nbsp;bufsize = 4096, buffer = 0x0, linectptr = 0x0, lineptr = 0x0,  
&nbsp;&nbsp;toktmp = 0x824e140 "D\216\023BD\216\023B",  
&nbsp;&nbsp;token = 0xffffffff \<Address 0xffffffff out of bounds\>, cursor = 0x0,  
&nbsp;&nbsp;marker = 0x816f2d8 "\b", limit = 0x0, linect = 135721728, last\_token = -1,  
&nbsp;&nbsp;force\_token = -1, eof = 1699173, io = {file = 0x0, str = 0x0},  
&nbsp;&nbsp;anchors = 0x0, bad\_anchors = 0x0, syms = 0x0, levels = 0x816f2e8,  
&nbsp;&nbsp;lvl\_idx = 1, lvl\_capa = 8, bonus = 0x1}  
(gdb)

(gdb) c  
Continuing.

Program received signal SIGINT, Interrupt.  
gc\_mark (ptr=1108577860, lev=1) at gc.c:714  
714 }  
(gdb) bt 24  
#0 gc\_mark (ptr=1108577860, lev=1) at gc.c:714  
#1 0x08069b85 in mark\_entry (key=369, value=1108577860, lev=1) at gc.c:630  
#2 0x080a1b85 in st\_foreach (table=0x42138e0c, func=0x8069b74 \<mark\_entry\>,  
&nbsp;&nbsp;&nbsp;&nbsp;arg=1) at st.c:495  
#3 0x08069baa in mark\_tbl (tbl=0x42138e44, lev=0) at gc.c:640  
#4 0x08069db5 in gc\_mark\_children (ptr=1108577804, lev=0) at gc.c:892  
#5 0x08069d8f in gc\_mark\_children (ptr=1108577812, lev=0) at gc.c:887  
#6 0x08069d8f in gc\_mark\_children (ptr=1108577820, lev=0) at gc.c:887  
#7 0x08069d8f in gc\_mark\_children (ptr=1108577828, lev=0) at gc.c:887  
#8 0x08069d8f in gc\_mark\_children (ptr=1108577836, lev=0) at gc.c:887  
#9 0x08069d8f in gc\_mark\_children (ptr=1108577844, lev=0) at gc.c:887  
#10 0x08069d8f in gc\_mark\_children (ptr=1108577852, lev=0) at gc.c:887  
#11 0x08069d8f in gc\_mark\_children (ptr=1108577860, lev=0) at gc.c:887  
#12 0x08069d38 in rb\_gc\_mark (ptr=1108577860) at gc.c:720  
#13 0x400b487e in syck\_mark\_parser (parser=0x816f268) at rubyext.c:749  
#14 0x08069ecb in gc\_mark\_children (ptr=1074243824, lev=0) at gc.c:926  
#15 0x08069af8 in mark\_locations\_array (x=0xbfff5334, n=9014) at gc.c:608  
#16 0x0806a996 in rb\_gc () at gc.c:1328  
#17 0x08069861 in rb\_newobj () at gc.c:386  
#18 0x0806b8a2 in hash\_alloc (klass=1108577916) at hash.c:183  
#19 0x0806b901 in rb\_hash\_new () at hash.c:195  
#20 0x400b4921 in syck\_parser\_new (argc=0, argv=0x0, class=1074314424)  
&nbsp;&nbsp;&nbsp;&nbsp;at rubyext.c:772  
#21 0x080654a3 in call\_cfunc (func=0x400b4890 \<syck\_parser\_new\>,  
&nbsp;&nbsp;&nbsp;&nbsp;recv=1074314424, len=1108577860, argc=0, argv=0x3) at eval.c:5375  
#22 0x0805afcd in rb\_call0 (klass=1074314404, recv=1074314424, id=3369, oid=0,  
&nbsp;&nbsp;&nbsp;&nbsp;argc=0, argv=0x0, body=0x4008bc2c, nosuper=0) at eval.c:5512  
#23 0x0805b7c1 in rb\_call (klass=1074314404, recv=1074314424, mid=3369,  
&nbsp;&nbsp;&nbsp;&nbsp;argc=0, argv=0x0, scope=0) at eval.c:5733  
(More stack frames follow...)  
(gdb)

Guy Decoux
