halfcountplus has asked for the wisdom of the Perl Monks concerning the following question:

I haven't used YAML much, but it seems fairly straightforward and I would have assumed it has been playtested much. However, I have a configuration hash ref that saves via DumpFile (or Dump to string to file) but will not load:

Assertion ((key_node)->sv_flags & 0x00000400) failed: file "perl_libyaml.c", line 262 at /usr/local/lib64/perl5/site_perl/5.10.0/x86_64-linux-thread-multi/YAML/XS.pm line 70, <$IN> line 1.

Which to me implies this is the first line of input.

Right now I don't see the point in throwing the whole hash construction up, since there is nothing wrong with that. Googling, I got no hits at all for this error (but also next to nothing about YAML::XS anyway, and the POD stuff is absurdly skimpy). So I am wondering if anyone knows anything about this -- since otherwise, I have nothing invested here and would just as soon use something else as fuss with something that should be pretty gosh darn simple (save/retrieve a 1000 byte hash of arrays and strings, etc).

Replies are listed 'Best First'.
Re: YAML::XS Load/LoadFile error
by ikegami (Patriarch) on Oct 20, 2010 at 03:10 UTC

    It's not YAML::XS signaling an error in the YAML, it's Perl signaling an error in YAML::XS.

    What version of YAML::XS are you using? Try upgrading it, for starters.

      Yeah, I follow this is a problem in the module, not my code or the data structure, which is why I'm curious. This is the "latest", YAML::XS 0.34.

      Line 70 just calls YAML::XS::LibYAML, which is the C executable.

      Like I said, it would not take me long to do this by hand or another way -- JSON, XML, Storable, it doesn't matter -- just this seems excessively pathetic...

        Bugs are annoying, but pathetic? That's an odd characterisation, especially considering we have no idea what the bug is.

        Line 262 is a blank line. It's surely coming from what I see as line 265:

        /* Get each key string and value node and put them in the hash */ while ((key_node = load_node(loader))) { assert(SvPOK(key_node)); <--------------- value_node = load_node(loader); hv_store_ent( hash, key_node, value_node, 0 ); }

        It's expecting load_node to return a scalar already containing a string, but a check finds it doesn't. What does that mean exactly? The module's author could probably tell you faster than I could.