Problem using YAML/SYCK on Solaris 8

I'm using ruby 1.8.2 (2004-06-28) [sparc-solaris2.8] and yaml/syck
in a daemon script to write alive messages every 10 seconds.
Sooner or later the loop/thread/script ends with one of the following
error messages:

....
9179
9180
9181
/usr/local/lib/ruby/1.8/yaml.rb:340: [BUG] Segmentation fault
ruby 1.8.2 (2004-06-28) [sparc-solaris2.8]

Abort (core dumped)

OR

....
1709
1710
1711
Exception `NotImplementedError' at /usr/local/lib/ruby/1.8/yaml.rb:340
- method `write' called on terminated object (0xd3088)
/usr/local/lib/ruby/1.8/yaml.rb:340:in `end_object': method `write'
called on terminated object (0xd3088) (NotImplementedError)
        from /usr/local/lib/ruby/1.8/yaml.rb:340:in `quick_emit'
        from /usr/local/lib/ruby/1.8/yaml/rubytypes.rb:307:in
`to_yaml'
        from to_yaml_test.rb:7
        from to_yaml_test.rb:6:in `loop'
        from to_yaml_test.rb:6

Here is the simplified source code ...

···

------------------------
require 'yaml'

i = 0
loop{
  "HelloWorld".to_yaml
  i+=1
  STDERR.puts i
}
------------------------

uname -a
SunOS tb-sun-1 5.8 Generic_108528-12 sun4u sparc SUNW,Sun-Blade-1000

gcc -v
Reading specs from /usr/local/lib/gcc/sparc-sun-solaris2.8/3.4.0/specs
Configured with: ../configure --with-as=/usr/ccs/bin/as
--with-ld=/usr/ccs/bin/ld --disable-nls
Thread model: posix
gcc version 3.4.0

On Linux there is no problem :wink:

Any suggestions or hints??
Thanks--

Andi

/usr/local/lib/ruby/1.8/yaml.rb:340: [BUG] Segmentation fault

Probably a problem in syck_emitter_new()

bonus and ignore_id must be affected *after* the call to
Data_Wrap_Struct() because if the GC run when Data_Wrap_Struct() is called
it can remove emitter->bonus

Exception `NotImplementedError' at /usr/local/lib/ruby/1.8/yaml.rb:340
- method `write' called on terminated object (0xd3088)

  emitter->bonus was GC'ed

Guy Decoux

ts wrote:

bonus and ignore_id must be affected *after* the call to
Data_Wrap_Struct() because if the GC run when Data_Wrap_Struct() is called
it can remove emitter->bonus

Understood. Fixed in CVS and Ruby 1.8 branch.

Andi, can you try again for me? Wonderful.

_why

Hi,

At Wed, 30 Jun 2004 02:43:11 +0900,
why the lucky stiff wrote in [ruby-talk:104858]:

> bonus and ignore_id must be affected *after* the call to
> Data_Wrap_Struct() because if the GC run when Data_Wrap_Struct() is called
> it can remove emitter->bonus
>
>
Understood. Fixed in CVS and Ruby 1.8 branch.

I think instance initialization should be in #initialize,
apart from the allocator.

···

--
Nobu Nakada

why the lucky stiff <ruby-talk@whytheluckystiff.net> wrote in message news:<40E1AA11.4080707@whytheluckystiff.net>...

Andi, can you try again for me? Wonderful.

It works!
Thanks a lot to Guy and _why.

Andi