[MacRuby] #1308: MacRuby does not invoke a free function which was specified in Data_Wrap_Struct().
#1308: MacRuby does not invoke a free function which was specified in Data_Wrap_Struct(). ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- http://lists.macosforge.org/pipermail/macruby-devel/2011-May/007778.html huge memory leaks occurs with Nokogiri 1.4.x {{{ #!ruby require 'rubygems' require 'nokogiri' loop do doc = Nokogiri::HTML('<html><body><p>TEST </p></body></html>') p = doc.css("p")[0].text print p end }}} Nokogiri 1.4.x use malloc() to allocate memory. MacRuby needs to invoke a free function which was specified in Data_Wrap_Struct(). -- Ticket URL: <http://www.macruby.org/trac/ticket/1308> MacRuby <http://macruby.org/>
#1308: MacRuby does not invoke a free function which was specified in Data_Wrap_Struct(). ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: 0.11-blocker ----------------------------------+----------------------------------------- Changes (by lsansonetti@…): * keywords: => 0.11-blocker Comment: Let's try to do that for the upcoming release. Adding 0.11-blocker keyword. We need to add a custom -finalize method to the given class inside rb_data_object_alloc() (but only once of course). -- Ticket URL: <http://www.macruby.org/trac/ticket/1308#comment:2> MacRuby <http://macruby.org/>
#1308: MacRuby does not invoke a free function which was specified in Data_Wrap_Struct(). ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: 0.11-blocker ----------------------------------+----------------------------------------- Comment(by lsansonetti@…): Once this problem is fixed, https://github.com/MacRuby/MacRuby/commit/1fa3eba0956090f28939eb29f52e551a6b... can be reverted. -- Ticket URL: <http://www.macruby.org/trac/ticket/1308#comment:3> MacRuby <http://macruby.org/>
#1308: MacRuby does not invoke a free function which was specified in Data_Wrap_Struct(). ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: 0.11-blocker ----------------------------------+----------------------------------------- Comment(by watson1978@…): I reverted it within local repository, but it seems memory leaks occur in JSON. -- Ticket URL: <http://www.macruby.org/trac/ticket/1308#comment:4> MacRuby <http://macruby.org/>
#1308: MacRuby does not invoke a free function which was specified in Data_Wrap_Struct(). ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: 0.11-blocker ----------------------------------+----------------------------------------- Comment(by lsansonetti@…): Ah yes, the problem isn't fixed yet :) -- Ticket URL: <http://www.macruby.org/trac/ticket/1308#comment:5> MacRuby <http://macruby.org/>
#1308: MacRuby does not invoke a free function which was specified in Data_Wrap_Struct(). ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: 0.11-blocker ----------------------------------+----------------------------------------- Comment(by lsansonetti@…): Okay, I added a fix to master: https://github.com/MacRuby/MacRuby/commit/2ba4bd4686b0f517b728216c9f8997da45... Can you retry the JSON library? -- Ticket URL: <http://www.macruby.org/trac/ticket/1308#comment:6> MacRuby <http://macruby.org/>
#1308: MacRuby does not invoke a free function which was specified in Data_Wrap_Struct(). ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: 0.11-blocker ----------------------------------+----------------------------------------- Comment(by lsansonetti@…): I see the following crash when running the nokogiri example: {{{ Thread 3 Crashed: Dispatch queue: Garbage Collection Work Queue 0 libmacruby.1.9.2.dylib 0x00000001000b52e1 st_foreach + 81 (st.c:638) 1 nokogiri.bundle 0x0000000105796bda dealloc + 58 (xml_document.c:31) 2 libmacruby.1.9.2.dylib 0x000000010003cf00 rdata_finalize + 32 (gc.c:432) 3 libobjc.A.dylib 0x00007fff82771f67 finalizeOneObject + 48 4 libauto.dylib 0x00007fff8701d3d5 Auto::foreach_block_do(auto_zone_cursor*, void (*)(void*, void*), void*) + 85 5 libobjc.A.dylib 0x00007fff82771b5c batchFinalize + 64 6 libauto.dylib 0x00007fff87017137 Auto::Zone::invalidate_garbage(unsigned long, unsigned long const*) + 71 7 libauto.dylib 0x00007fff87007b21 auto_collect_internal(Auto::Zone*, unsigned int) + 481 8 libauto.dylib 0x00007fff870080bd auto_collection_work(Auto::Zone*) + 157 9 libSystem.B.dylib 0x00007fff8246b284 _dispatch_call_block_and_release + 15 10 libSystem.B.dylib 0x00007fff82449df2 _dispatch_queue_drain + 251 11 libSystem.B.dylib 0x00007fff82449c54 _dispatch_queue_invoke + 57 12 libSystem.B.dylib 0x00007fff824497fe _dispatch_worker_thread2 + 252 13 libSystem.B.dylib 0x00007fff82449128 _pthread_wqthread + 353 14 libSystem.B.dylib 0x00007fff82448fc5 start_wqthread + 13 }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1308#comment:7> MacRuby <http://macruby.org/>
#1308: MacRuby does not invoke a free function which was specified in Data_Wrap_Struct(). ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: 0.11-blocker ----------------------------------+----------------------------------------- Comment(by watson1978@…): Thank you. It seems JSON has no problem. I will commit JSON which reverted. -- Ticket URL: <http://www.macruby.org/trac/ticket/1308#comment:8> MacRuby <http://macruby.org/>
#1308: MacRuby does not invoke a free function which was specified in Data_Wrap_Struct(). ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: 0.11-blocker ----------------------------------+----------------------------------------- Comment(by lsansonetti@…): In nokogiri's xml_document.c: {{{ tuple->unlinkedNodes = st_init_numtable_with_size(128); }}} The st_table here is prematurely collected since there is no write barrier. That's causing the problem here since we try to iterate over the table during -finalize but the table is already gone. I am not sure how to properly fix this without changing nokogiri. It is unfortunate that it does not use a MRI mark function for Data_Wrap_Struct, since we could have used it. -- Ticket URL: <http://www.macruby.org/trac/ticket/1308#comment:9> MacRuby <http://macruby.org/>
#1308: MacRuby does not invoke a free function which was specified in Data_Wrap_Struct(). ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: 0.11-blocker ----------------------------------+----------------------------------------- Comment(by lsansonetti@…): Actually it's even worse: {{{ nokogiriTuplePtr tuple = (nokogiriTuplePtr)malloc(sizeof(nokogiriTuple)); [...] tuple->unlinkedNodes = st_init_numtable_with_size(128); }}} Because this is malloc memory, a write barrier won't suffice. -- Ticket URL: <http://www.macruby.org/trac/ticket/1308#comment:10> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby