Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Problem using YAML

Reply
Thread Tools

Problem using YAML

 
 
Carol Almquist
Guest
Posts: n/a
 
      05-18-2004
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(0x4018410 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



 
Reply With Quote
 
 
 
 
ts
Guest
Posts: n/a
 
      05-18-2004
>>>>> "C" == Carol Almquist <(E-Mail Removed)> writes:


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

Try a newer version for ruby


Guy Decoux


 
Reply With Quote
 
 
 
 
why the lucky stiff
Guest
Posts: n/a
 
      05-18-2004
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(0x4018410 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


 
Reply With Quote
 
ts
Guest
Posts: n/a
 
      05-19-2004
>>>>> "w" == why the lucky stiff <(E-Mail Removed)> writes:

w> I thought the 'non object' bug was fixed a few weeks ago. Let's make
w> sure your extension is installing properly. What does your
w> 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)
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>,
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=0x816f26 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)
at rubyext.c:772
#19 0x080654a3 in call_cfunc (func=0x400b4890 <syck_parser_new>,
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,
argc=0, argv=0x0, body=0x4008bc2c, nosuper=0) at eval.c:5512
#21 0x0805b7c1 in rb_call (klass=1074314404, recv=1074314424, mid=3369,
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=0x816f26 at rubyext.c:749
749 rb_gc_mark(parser->root);
(gdb) p *parser
$1 = {root = 1108577860, root_on_error = 4, implicit_typing = 1,
taguri_expansion = 0, handler = 0, error_handler = 0,
bad_anchor_handler = 0, input_type = syck_yaml_utf8, io_type = syck_io_str,
bufsize = 4096, buffer = 0x0, linectptr = 0x0, lineptr = 0x0,
toktmp = 0x824e140 "D\216\023BD\216\023B",
token = 0xffffffff <Address 0xffffffff out of bounds>, cursor = 0x0,
marker = 0x816f2d8 "\b", limit = 0x0, linect = 135721728, last_token = -1,
force_token = -1, eof = 1699173, io = {file = 0x0, str = 0x0},
anchors = 0x0, bad_anchors = 0x0, syms = 0x0, levels = 0x816f2e8,
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>,
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=0x816f26 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)
at rubyext.c:772
#21 0x080654a3 in call_cfunc (func=0x400b4890 <syck_parser_new>,
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,
argc=0, argv=0x0, body=0x4008bc2c, nosuper=0) at eval.c:5512
#23 0x0805b7c1 in rb_call (klass=1074314404, recv=1074314424, mid=3369,
argc=0, argv=0x0, scope=0) at eval.c:5733
(More stack frames follow...)
(gdb)




Guy Decoux


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
YAML Problem YAML::Object Fransiscus Xaverius Ruby 2 12-14-2007 09:17 PM
yaml.rb and YAML "%" directives Joshua Choi Ruby 1 01-14-2007 07:53 AM
Puzzling over why ri can open the std ruby/ri .yaml files, but raw yaml can't Eric Promislow Ruby 4 10-31-2006 10:15 PM
YAML.dump/YAML.load bug Paul Battley Ruby 0 08-03-2005 08:28 PM
YAML Question: Using YAML::YamlNode#transform Method to get float values? RubyQuestions Ruby 0 12-03-2003 02:15 AM



Advertisments