At my wits end - SEGMENT FAULTS HELP!

94 views
Skip to first unread message

Bo

unread,
Dec 19, 2011, 11:57:04 AM12/19/11
to nokogi...@googlegroups.com
I posted at least a week ago. Since then, I've made no progress.

I've now tried 4 different operating systems (Snow Leopard/Lion on OSX and 10.4/11.04/11.10 on Ubuntu), and every compiler option that I can find. I've tried MacPorts, Homebrew, and "native system", and no matter what, I can make Nokogiri segfault.  

My application has been written high dependent on Nokogiri, and is in a state of shambles because of this.  

I'm terribly confused as to what to do at this point. I've written no code for weeks. I've installed machine after machine, wiping hard disks and starting from scratch.  NOTHING works. 

My current environment is:

OSX Lion 10.7.2
Most recent XCode (reinstalled today) 
RVM 1.9.2.-290
nokogiri -v says
# Nokogiri (1.5.0)
    ---
    warnings: []
    nokogiri: 1.5.0
    ruby:
      version: 1.9.2
      platform: x86_64-darwin11.2.0
      description: ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]
      engine: ruby
    libxml:
      binding: extension
      compiled: 2.7.8
      loaded: 2.7.8

The error.  

/Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@marketfu/gems/nokogiri-1.5.0/lib/nokogiri/xml/node.rb:821: [BUG] Segmentation fault
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]

-- control frame ----------
c:0031 p:---- s:0136 b:0136 l:000135 d:000135 CFUNC  :native_write_to
c:0030 p:0250 s:0129 b:0129 l:000128 d:000128 METHOD /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@marketfu/gems/nokogiri-1.5.0/lib/nokogiri/xml/node.rb:821
c:0029 p:0183 s:0119 b:0119 l:000118 d:000118 METHOD /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@marketfu/gems/nokogiri-1.5.0/lib/nokogiri/xml/node.rb:742
c:0028 p:0054 s:0110 b:0110 l:000109 d:000109 METHOD /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@marketfu/gems/nokogiri-1.5.0/lib/nokogiri/html/document.rb:62
c:0027 p:0149 s:0106 b:0106 l:000105 d:000105 METHOD /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@marketfu/gems/nokogiri-1.5.0/lib/nokogiri/xml/node.rb:759


Any thoughts on next steps. I'm literally stuck until I get this sorted out. 




Aaron Patterson

unread,
Dec 19, 2011, 12:02:38 PM12/19/11
to nokogi...@googlegroups.com

Can you provide us with a program that will reproduce the error? Or
supply us with a gdb stack trace?

Thanks.

--
Aaron Patterson
http://tenderlovemaking.com/

Tim Elliott

unread,
Dec 19, 2011, 12:32:24 PM12/19/11
to nokogi...@googlegroups.com
On Mon, Dec 19, 2011 at 8:57 AM, Bo <wfla...@tempusgroup.com> wrote:
> My application has been written high dependent on Nokogiri, and is in a
> state of shambles because of this.

Can you try the latest git version of Nokogiri to see if the issue
still exists? I created a snapshot repository that you can test with:

gem "nokogiri", :git => "git://github.com/ender672/nokogiri.git",
:branch => "snapshot_with_gemspec"

This repository will likely be deleted soon, so please fork it if you
need it to stick around.

Cheers,
Tim

Bo

unread,
Dec 19, 2011, 1:09:12 PM12/19/11
to nokogi...@googlegroups.com
I tried it with that version, no improvement.

Here is a link to the stack trace on the crash. Working on GDB backtrace as well and teasing this out so I can give you something to run.


Thanks for looking at this guys.


Brendan Grainger

unread,
Dec 19, 2011, 12:14:48 PM12/19/11
to nokogi...@googlegroups.com
Hi Bo,

I'm a nokogiri newb, but I also was having a lot of segfaults. For me the reason was because I was doing something funky and calling ruby 1.9.2 from ruby 1.8.7 (don't ask, not my idea). If you're not careful it'll stuff up the gem path and boom, nokogiri dies (which makes sense in my case really)

Just a thought, and good luck.

Brendan

--
You received this message because you are subscribed to the Google Groups "nokogiri-talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nokogiri-talk/-/SdvonFXnx68J.
To post to this group, send email to nokogi...@googlegroups.com.
To unsubscribe from this group, send email to nokogiri-tal...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nokogiri-talk?hl=en.

Bo

unread,
Dec 19, 2011, 2:32:23 PM12/19/11
to nokogi...@googlegroups.com
Thanks Brendan,

I  don't think that's the case here, but I do wonder if RVM has something to do with it.  

Wf

Chester Wood

unread,
Dec 19, 2011, 2:38:34 PM12/19/11
to nokogi...@googlegroups.com
Just a hunch, based on my shooting myself in the foot. You don't have both macports and homebrew installed do you?

And, I saw a similar segfault last night after I finally got nokogiri installled (albeit with the warning I complained about) and tried running the rails command. I reinstalled rvm, ruby and gemsets and still got the error until I deleted my app and generated a new one. 

That was painless for me as I was just starting a tutorial. YMMV ;-)
Maybe you can't delete the app but there might be some state you can delete.

--
You received this message because you are subscribed to the Google Groups "nokogiri-talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nokogiri-talk/-/UuLcPJ_B2ccJ.

Bryan Crossland

unread,
Dec 19, 2011, 2:39:14 PM12/19/11
to nokogi...@googlegroups.com

It could. If your RVM is pointing to one version of ruby and your app or Nokogiri was attempting to use another.

B.


 

--
You received this message because you are subscribed to the Google Groups "nokogiri-talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nokogiri-talk/-/V7unxa_m3_IJ.

Bo

unread,
Dec 19, 2011, 3:08:04 PM12/19/11
to nokogi...@googlegroups.com
Yeah, I do have both on this machine. But, I don't have both on Ubuntu where I had this problem as well.

Yeah, I've invested 18+ months in the app. It would be very hard to delete it.  That said, I'm working now to create something I can "demo" the error on, so that others can do a better job assisting. I know it's challenging to troubleshoot these types of environments.



Bo

unread,
Dec 19, 2011, 9:12:52 PM12/19/11
to nokogi...@googlegroups.com
Sorry that took so long. Been a while since I had to find/generate one of those.  

Here's the gist of the backtrace.  

Brendan Grainger

unread,
Dec 19, 2011, 10:13:20 PM12/19/11
to nokogi...@googlegroups.com
Hi Bo,

Are you using thin? If so how are you starting it? If you type:

which thin

from the root of your project what does it say? And then what's the shebang?

cat `which thin`

Thanks
Brendan

--
You received this message because you are subscribed to the Google Groups "nokogiri-talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nokogiri-talk/-/DpaE4F67ztEJ.

Brendan Grainger

unread,
Dec 21, 2011, 9:29:54 PM12/21/11
to nokogi...@googlegroups.com
Hi Bo, don't suppose you have made any progress on this? Just interested as I think nokogiri was dying at the same spot for me as indicated in your stack trace.

Thanks


On Dec 19, 2011, at 9:12 PM, Bo wrote:

William Flanagan

unread,
Dec 23, 2011, 4:18:15 PM12/23/11
to nokogi...@googlegroups.com
Nope.

So, i'm using thin. It's one deployed in my gem set for the application (Heroku deployments).  

Interestingly, the shebang is #!/usr/bin/env ruby

But, my problem isn't a browser type crash. It's in a delayed_job worker.

Bo

Bo

unread,
Jan 6, 2012, 10:53:09 AM1/6/12
to nokogi...@googlegroups.com
I still have this problem. Has anyone fixed it or found some sort of solution for it? 

Mike Dalessio

unread,
Jan 6, 2012, 11:22:59 AM1/6/12
to nokogi...@googlegroups.com
Hello,

On Fri, Jan 6, 2012 at 10:53 AM, Bo <wfla...@tempusgroup.com> wrote:
I still have this problem. Has anyone fixed it or found some sort of solution for it? 

As far as I can tell from reading the thread, nobody has reproduced your problem. I'm happy to help, but if I can't reproduce it on my box, run valgrind against it, run it with a debugging version of libxml2, etc., I'm afraid it's going to be extremely difficult and time consuming to find out what's going on.

If you can't help me reproduce the issue, would you be willing to give me access to a linux box under your control where I can play with your code? Contact me off list if you want this.

If you can't do either of the above, then I'll just start asking questions.

- What have you done to narrow down the possible causes within your application? What have you done to provide a reproducible case for Team Nokogiri?
- Have you tried Nokogiri HEAD? How about Nokogiri 1.4.7?
- What version of libxml2 are you using? What version of Ruby are you using? What versions of each can you reproduce the problem on?
- What platforms have you reproduced the issue on? Can you reproduce on linux?
- Are you using threads? Are you running your code within a server framework (like thin), or is this a standalone executable? If it's in a server, can you reproduce the problem by running without threads/eventmachine?
- Are you using libxml-ruby in this application, in addition to Nokogiri?
- What sort of document operations are you performing in your code? Some problematic areas (historically speaking) have been:
  - namespace manipulation
  - moving or copying nodes between documents (from one document to another)
- Can you more-easily reproduce the problem by setting GC.stress ?
- Do you see any warnings at runtime, indicating (possibly) that you're compiling against one version of libxml2 and running with another version loaded? This happens often on macs, where you might use homebrew or macports to install a second libxml2 library.

Hopefully we'll find someway to help each other on this one.

---
mike dalessio / @flavorjones


Bo

unread,
Jan 6, 2012, 4:32:57 PM1/6/12
to nokogi...@googlegroups.com
Hi Mike,

Thanks for your help. It's exceedingly frustrating, and I'm probably now thrashing to try to solve this problem. Your questions are right on. Let me answer them. 

1) You absolutely can access whichever computer it's easiest for you. My dev machine is Lion (where it happens very easily and commonly), and our production environment machines are 11.10 Ubuntu. It happens there, not as frequently.  

2) I've tested against Snow Leopard (where it started, Lion, 11.04 Ubuntu and 11.10 Ubuntu). We're running RVM, and I have tested on 1.9.2 - 190, 290 and 1.9.3-p0.  The application is Rails 2.3, bundler is running, and it's deployed on Heroku Cedar stack. The workers are AWS instances. 

3) On my development machine, I've installed via Brew the latest libxml2, libiconv, and libxslt. I have uninstalled and reinstalled using directory options that point to the homebrew versions. I have ensured they are simlinked (to the best of my ability).  On the linux servers, we've just apt-get'd the appropriate libs, and done a similar reinstall. 

4) These parts do not use threads really, they're lib/worker code. So they aren't running in thin/EM. 

5) I'm not using libxml-ruby as far as I know. 

6) I've not been messing with namespaces. This is pretty simple parsing. I am deleting nodes though (to render a page suitable for reading). 

7) GC.stress is beyond my pay grade. I'm happy to do what you tell me and give you feedback. But, on my local dev machine, I can replicate it in about 15 seconds. So, there's not a lot of stress needed.

8) Yes, I have the VERSION warning on my local still. And, to further complicate things, if you type "which nokogiri" i get one at /usr/bin/nokogiri when I'm at the bash prompt in my application subdirectory. 

Hopefully those answers help. I'll email you direct about remoting in. 

W






  

Bo

unread,
Jan 27, 2012, 5:16:06 PM1/27/12
to nokogi...@googlegroups.com
So, just thought I'd share that we're still having this error, and have found no solution yet for it. 

Reply all
Reply to author
Forward
0 new messages