Segmentation fault in Marshal.load

Bug #670571 reported by Dan Van Derveer
28
This bug affects 4 people
Affects Status Importance Assigned to Milestone
rails (Ubuntu)
Fix Released
High
Dave Walker
ruby1.8 (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Binary package hint: ruby1.8

OS: Lucid
Package: ruby1.8-1.8.7.249-2

This issue is tracked in ruby's bug tracker here:
http://redmine.ruby-lang.org/issues/show/2557

The tracker description indicates its an issue with 1.8.7 p248 only however the source for 1.8.7 p249 does not have the patch in that bug applied.

I took the patch in that bug and built my own ruby1.8 based on the source from the lucid package. Unfortunately the patched version still has the same issue. In fact I tried ruby 1.8.7 p302 as well and had the same issues with that version as well.

The only version of ruby 1.8.7 I've found to not crash occasionally on this bug is ruby-enterprise-edition 2010.02 which is discussed in this release posting:
http://blog.phusion.nl/2010/06/07/ruby-enterprise-edition-1-8-7-2010-02-released/

Perhaps the patches for ruby enterprise edition could be integrated in to the ruby1.8 package.

Tags: glucid lucid ruby

Related branches

scm (scm)
tags: added: glucid lucid ruby
Revision history for this message
Etienne Goyer (etienne-goyer-outlands) wrote :

Dan (or whoever else), can you provide a code snippet that triggers the bug on Ubuntu? I tried the example from the upstream bug, but it would not segfault. Here's my test case:

ubuntu@lucid-server:~$ cat fault.rb
#!/usr/bin/ruby
require File.expand_path("/usr/share/rails/activesupport/lib/active_support/multibyte/unicode_database.rb", __FILE__)
ActiveSupport::Multibyte::UnicodeDatabase.new.codepoints
puts "No crash"
ubuntu@lucid-server:~$ ./fault.rb
No crash

Changed in ruby1.8 (Ubuntu):
status: New → Incomplete
Revision history for this message
Dan Van Derveer (cyberkni) wrote :

Here is a test which consistently segfaults on my Lucid box.

bug_test.tar.gz contains two files:
testdata.xml - a ~1MB data file of XML
test.rb - a script that opens and parses that data file several times to cause the crash

Example run:
$ ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]
$ ./test.rb
parsed 0
parsed 1
parsed 2
/var/lib/gems/1.8/gems/activesupport-2.3.2/lib/active_support/xml_mini/libxml.rb:125: [BUG] Segmentation fault
ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]

Aborted

Revision history for this message
Etienne Goyer (etienne-goyer-outlands) wrote :

To test on plain lucid, you would need to:

    $ sudo apt-get install rails libxml-ruby
    $ gem install activesupport --version 2.3.2

And then run the above test-case. It reliably segfault for me, so marking confirmed.

Changed in ruby1.8 (Ubuntu):
status: Incomplete → Confirmed
importance: Undecided → High
Revision history for this message
Robbie Williamson (robbiew) wrote :

Do we have confirmation that this is resolved in the Maverick version?

Revision history for this message
Dave Walker (davewalker) wrote :

Issue sounds like it is isolated to amd64, and not fixed yet.

== Lucid (i386) ==
$ ./test.rb
parsed 0
parsed 1
parsed 2
parsed 3
parsed 4
parsed 5
parsed 6
parsed 7
parsed 8
parsed 9
parsed 10
parsed 11
parsed 12
parsed 13
parsed 14

== Maverick (amd64) ==
$ ./test.rb
DEPRECATION WARNING: require "activesupport" is deprecated and will be removed in Rails 3. Use require "active_support" instead.. (called from /usr/lib/ruby/1.8/activesupport.rb:2)
parsed 0
parsed 1
parsed 2
parsed 3
/usr/lib/ruby/1.8/active_support/xml_mini/libxml.rb:125: [BUG] Segmentation fault
ruby 1.8.7 (2010-06-23 patchlevel 299) [x86_64-linux]

== Natty (amd64) ==
$ ./test.rb
DEPRECATION WARNING: require "activesupport" is deprecated and will be removed in Rails 3. Use require "active_support" instead.. (called from /usr/lib/ruby/1.8/activesupport.rb:2)
parsed 0
parsed 1
/usr/lib/ruby/1.8/active_support/xml_mini/libxml.rb:125: [BUG] Segmentation fault
ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]

Aborted (core dumped)

Dave Walker (davewalker)
Changed in ruby1.8 (Ubuntu):
assignee: nobody → Dave Walker (davewalker)
Revision history for this message
Dave Walker (davewalker) wrote :

This seems to affect rails, not ruby. Updating as appropriate.

Changed in ruby1.8 (Ubuntu):
status: Confirmed → Invalid
Changed in rails (Ubuntu):
status: New → Confirmed
Changed in ruby1.8 (Ubuntu):
importance: High → Undecided
Changed in rails (Ubuntu):
importance: Undecided → High
Changed in ruby1.8 (Ubuntu):
assignee: Dave Walker (davewalker) → nobody
Changed in rails (Ubuntu):
assignee: nobody → Dave Walker (davewalker)
Revision history for this message
Etienne Goyer (etienne-goyer-outlands) wrote :

Dave is correct, maverick is also affected. Don't have a natty install nearby to test, so I am not sure.

I thought the bug was specific to ruby 1.8.7 p249, per the linked upstream report. In comment 8, it's reported as fixed. I am not sure anymore whether it is fixed upstream or not.

Revision history for this message
Dave Walker (davewalker) wrote :

Etienne, it don't think the ruby upstream report In comment 8 is related.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package rails - 2.3.5-1.2ubuntu1

---------------
rails (2.3.5-1.2ubuntu1) natty; urgency=low

  * debian/patches/cdata-and-white-space-handling.patch: Handle CDATA and
    improve white space handling, fixing a Segmentation Fault in some
    circumstances. Patch based on subset of upstream commit range.
    (LP: #670571)
 -- Dave Walker (Daviey) <email address hidden> Wed, 16 Mar 2011 01:03:12 +0000

Changed in rails (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Dave Walker (davewalker) wrote :

The specific test case seems to be resolved in Natty now.. however, whilst testing the patch, i discovered that the segmentation fault is non-deterministic - which is somewhat concerning. There could indeed be a deeper bug in ruby. Attaching a backtrace.

Not sure if this is related, http://groups.google.com/group/emm-ruby/browse_thread/thread/950573fc9eb248ae

Revision history for this message
Etienne Goyer (etienne-goyer-outlands) wrote :

Can someone actually affected by the bug provide us with some more insight? It would be good to fix the underlying segfault, but we would need to better understand what triggers it. Has it been fixed upstream at all?

Revision history for this message
Mark Roach (mrroach) wrote :

Hi Etienne. I'm not sure that we have any more info here, what else would you like us to provide? I'll do what I can, but we had hoped that providing a testcase that triggers the bug would be sufficient...

Revision history for this message
Etienne Goyer (etienne-goyer-outlands) wrote :

Indeed, the test-case is resolved in natty. That does not mean the underlying bug is fixed, though.

Mark, we'll need to know whether the underlying bug is indeed fixed or not in upstream Ruby, and ideally figure which commit fixed it. Failing that, a better (more specific?) test-case that segfault deterministically would help, although it's not guaranteed.

Revision history for this message
Mark Roach (mrroach) wrote :

Hi again, just to make sure I understand, when you say "we" above, do you mean that is something that you (ubuntu) folks need to/are going to do, or that it is something that I need to do?

If it's something that we (those affected by the issue) need to do, then I may be fundamentally misunderstanding the purpose of this bug. Should we be working directly with the ruby devs to get this fixed and then just use this space to point ubuntu folks to a patch number, or do you all do the sort of deeper analysis necessary for the above?

Thanks, and sorry for my general lack of insight into how this process works.

Revision history for this message
Etienne Goyer (etienne-goyer-outlands) wrote :

Mark, no problem, and no apologies required. Fundamentally, the problem is that we do not have a corresponding upstream commit that would fix the bug. In fact, it's not entirely clear whether the bug is fixed upstream or not. Without a good knowledge of the Ruby interpreter code base, it is close to impossible to figure out exactly what is going on.

Also, from what I understand, Dave committed a fix in natty for the specific test-case we currently have (posted by Dan Van Derveer). Does that fix actually address the problem as you experience it? If so, then I guess it could be considered for lucid. If not, then we will need a more specific test-case.

Dave, does the above make any sense to you?

Revision history for this message
Etienne Goyer (etienne-goyer-outlands) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.