GithubHelp home page GithubHelp logo

Sax Parsing Segfault by Ruby GC about ox HOT 35 CLOSED

ohler55 avatar ohler55 commented on June 2, 2024
Sax Parsing Segfault by Ruby GC

from ox.

Comments (35)

ohler55 avatar ohler55 commented on June 2, 2024

If you can help me that would be great. Can you try running with the class_cache turned off? What other options are you using?

from ox.

griffinmyers avatar griffinmyers commented on June 2, 2024

Sure, would be happy to try that out. Unfortunately I can't find any documentation on how to turn class_cache off. Additionally, I'm not running with any options. Just passing in an IO object and a vanilla Sax Doc.

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

Wrong gem. Ox does not have the class_cache option, only Oj. Vanilla Sax is enough for me to get started though.

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

I checked in a fix. Can you give it a whirl on your system. Of by one on buffer size.

from ox.

griffinmyers avatar griffinmyers commented on June 2, 2024

Trying it out now. I'll give it a day or so and report back! Thanks for the prompt response, it is seriously awesome to see a gem maintained so well.

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

Thanks.

from ox.

griffinmyers avatar griffinmyers commented on June 2, 2024

I've gotten two crashes with the same .crash report. They seem to be happening less frequently, but happen nonetheless. I used revision: bb30dbe8db25b9bf34d393a0296f4e10f3c2cb87.

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

Can you give me a file to test with?

from ox.

griffinmyers avatar griffinmyers commented on June 2, 2024

The Sax document file I presume?

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

The XML file that triggers the crash.

from ox.

griffinmyers avatar griffinmyers commented on June 2, 2024

There is no XML file that triggers the crash. The crash occurs during ruby garbage collection, often times well after XML parsing has completed.

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

Can you provide a copy of the XML that is parsed before the crash? I'd like to try and recreate the problem.

from ox.

griffinmyers avatar griffinmyers commented on June 2, 2024

This is within a Rails app; there may be 100 XML documents parsed before it faults. That said I'll see if I can get it to occur by hitting only one document so you can test against it.

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

Thanks.

from ox.

griffinmyers avatar griffinmyers commented on June 2, 2024

I've been trying to isolate this with a single XML document but not finding much luck. You know, I'm wondering: If I raise an exception from within a SAX call back like #start_element or #end_element, and that's not caught until we are well into the Rails stack, would that cause the memory allocation issue?

from ox.

griffinmyers avatar griffinmyers commented on June 2, 2024

In fact, I just ran a little test, and indeed that seems to be the cause of this. When I don't raise from within the callbacks, I don't get any segfaults. I'm not having this problem with nokogiri, is this something that can be fixed?

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

Thank you for digging into the problem. That gives me something to work with. I'll see what I can do over the weekend if not sooner.

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

I'm not having much success reproducing the problem. Do you have a test you can share?

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

Were you able to find a file to share for testing?

from ox.

griffinmyers avatar griffinmyers commented on June 2, 2024

Hey, sorry sorry, I've gotten tied up with some other work at the moment, should hopefully have a solid test case for you soon. Apologies for the delay

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

No worries. Just checking up on outstanding issues.

from ox.

griffinmyers avatar griffinmyers commented on June 2, 2024

Sorry for the delay, I got a test case for you finally. You can clone it here.

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

Thats great. Thanks. I'll give it a try tonight.

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

What platform are you running on? OS X? Linux?

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

I added a print statement to the Ox initializer function and it was never called. Are you sure the test you have is a valid test?

from ox.

griffinmyers avatar griffinmyers commented on June 2, 2024

Yep, OSX 10.6. I just tried on a different machine running 10.7 and got the segfault. Are you visiting http://localhost:3000/parse/ once the rails server is running? I see it raising from within end_element

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

I missed the /parse. I get an error in soap.rb in end_element. Is that expected?

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

Eventually a crash. Cool, I can reproduce it here.

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

Got it fixed. I want to add some stack use optimizations before releasing though. A couple of days at most.

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

You made it very easy to find. Thank you for the help.

from ox.

griffinmyers avatar griffinmyers commented on June 2, 2024

Cool, glad I could help. I see the commits, but could you share a bit about what was going on that was causing it not to be exception safe?

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

I had not wrapped the parse call with a rb_protect(). With that in place I can get the exception back, cleanup, and then raise the exception. An oversight on my part.

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

Good to close?

from ox.

griffinmyers avatar griffinmyers commented on June 2, 2024

I think so. A couple days now with no hint of a problem. Thanks again, awesome to see this well maintained.

from ox.

ohler55 avatar ohler55 commented on June 2, 2024

I do my best. Thanks for the feedback and the help identifying the problem.

from ox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.