From: Sean Chittenden Date: 2002-09-28T16:19:54+09:00 Subject: Re: Matz, if you're reading, please scan this email > >>>>> "S" == Sean Chittenden writes: > > S> ./test/tests.rb -i 0 > > Well, if I'm right the problem is in ruby_xml_parser_io_set() > > 532 rxp->ctxt = ruby_xml_parser_context_new3(); > 533 data = (rx_io_data *)rxp->data; > 534 data->io = io; > 535 GetOpenFile(io, fptr); > 536 rb_io_check_readable(fptr); > 537 f = GetWriteFile(fptr); > 538 > 539 Data_Get_Struct(rxp->ctxt, ruby_xml_parser_context, rxpc); > 540 rxpc->ctxt = xmlCreateIOParserCtxt(NULL, NULL, > 541 (xmlInputReadCallback) ctxtRead, > 542 (xmlInputCloseCallback) ctxtClose, > 543 f, XML_CHAR_ENCODING_NONE); > > When the object is garbage collected, ruby call > > 89 void ruby_xml_parser_context_free(ruby_xml_parser_context *rxpc) { > 90 if (rxpc->ctxt != NULL && rxpc->copy == RUBY_LIBXML_ORIG) { > 91 xmlFreeParserCtxt(rxpc->ctxt); > 92 ruby_xml_parser_count--; > 93 } > 94 > 95 if (ruby_xml_parser_count == 0) > 96 xmlCleanupParser(); > 97 > 98 free(rxpc); > 99 } > 100 > > xmlFreeParserCtxt() call ctxtClose() but the original object (data->io) > was previously closed by ruby : explicitely or the garbage collector has > found it before it try to release rxp->ctxt. > > The segfault is just because you call close() on a already closed IO. :-/ You could be right, but, the IO context is created when reading data from RAM, not from an actual IO socket. I've created a simpler use case: http://lists.ruby-support.com/pipermail/ruby-developers/2002-September/000044.html http://lists.ruby-support.com/pipermail/ruby-developers/2002-September/000045.html That's a much simpler example. -sc -- Sean Chittenden