Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 179076 - Stack overflow in Ruby regular expressions on Gentoo but not on other distro's
Summary: Stack overflow in Ruby regular expressions on Gentoo but not on other distro's
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Ruby Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-19 08:25 UTC by Rick Moynihan
Modified: 2007-07-08 15:02 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
The YAML/redcloth file which generates the exception (regexp-stack-overflow.yaml,2.24 KB, text/plain)
2007-05-19 09:25 UTC, Rick Moynihan
Details
My emerge --info (emerge-info.txt,3.60 KB, text/plain)
2007-05-19 09:29 UTC, Rick Moynihan
Details
emerge --info (einfo.txt,3.26 KB, text/plain)
2007-05-19 09:53 UTC, Xavier Neys (RETIRED)
Details
emerge --info (emerge-info.txt,3.62 KB, text/plain)
2007-05-24 21:26 UTC, Rick Moynihan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rick Moynihan 2007-05-19 08:25:57 UTC
Hi,

I have been trying to make use of a Ruby static blogging engine (Rassmalog http://rassmalog.rubyforge.org/output/index.html ).  Unfortunately I cannot get it to work on Gentoo.  I do not experience this problem on Ubuntu (Edgy/Feisty) with the same versions of software installed.  I initially filed a bug with Rassmalog:

http://rubyforge.org/tracker/?func=detail&atid=10555&aid=10147&group_id=2737

The developer there (Suraj) distilled the problem down to an issue with Redcloth which I believe is an issue with Redcloth/Ruby on Gentoo as it seems that this issue (for me at least) only manifests itself on Gentoo, with both ruby 1.8.5p2 and ruby 1.8.6-r1.  I have not yet tried other versions from portage.

I am experiencing a stack overflow in Ruby's regex library when running the following:

$ ruby -ryaml -rubygems -e "require 'redcloth'; f = YAML.load_file('regexp-stack-overflow.yaml'); puts RedCloth.new(f['text']).to_html"

/usr/lib/ruby/site_ruby/1.8/redcloth.rb:571:in `gsub!': Stack overflow in regexp matcher: /((?:^([#*> ])(?:[^\n]|\n+(?:\2|>)|\n(?!\n|\Z))+))|((?:[^\n]+|\n+ +|\n(?![#*\n]|\Z))+)/m (RegexpError)
        from /usr/lib/ruby/site_ruby/1.8/redcloth.rb:571:in `blocks'
        from /usr/lib/ruby/site_ruby/1.8/redcloth.rb:276:in `to_html'
        from -e:3

I have the following setup:

$ uname -a
Linux godspeed 2.6.18-gentoo-r6 #1 PREEMPT Sun Dec 31 13:52:07 GMT 2006 i686 AMD Athlon(tm) 64 Processor 3000+ AuthenticAMD GNU/Linux

$ gem list --local redcloth

*** LOCAL GEMS ***

RedCloth (3.0.4)
    RedCloth is a module for using Textile and Markdown in Ruby. Textile
    and Markdown are text formats.  A very simple text format. Another
    stab at making readable text that can be converted to HTML.

I get this error when running it on the following YAML/redcloth file (this came from rassmalog a static blogging engine):  The <SNIP's> are not part of the file.)

<SNIP file="regexp-stack-overflow.yaml">
name: Version 2.0.0

date: Thu Dec 14 15:26:05 PST 2006 @18 /Internet Time/

tags:
  - history

text: |
  This release adds support for L10N(Localization)/I18N(Internationalization)/M17N(Multilingualization), adds new configuration parameters, fixes some bugs, and improves the documentation.

  h1. Caution

  * Generated file names no longer have spaces in them.

  * Blog entry file names are now required to end with <tt>.yaml</tt>

  * Variables available in ERB templates have been renamed.

  * The _publish_ task, which uploads your blog to your website,  has been renamed to _upload_ for clarity.

  * The _index_ parameter has been renamed to _recent_entries_ in the primary blog configuration file.

  h1. Details

  * New configuration parameters have been added to the blog configuration file:
  ** The _front_page_ parameter defines the name of a file in the output/ directory that should be the front page of your blog. This allows you to display an entry as your front page.
  ** The _summarize_entries_ parameter specifies whether entries are summarized in tag and archive pages.
  ** The _uploader_ parameter defines the command that uploads your blog to your website.

  * English text used in core of Rassmalog can now be easily translated for L10N(Localization)/I18N(Internationalization)/M17N(Multilingualization) without having to edit the source code.

  * A list of recent entries is now generated before the archives in the navigation menu.

  * Blog entry names and tags can now contain question marks and other characters in URL syntax.

  * Output is now correctly generated whenever the associated source file (configuration, blog entriess) changes.

  * Descriptions of parameters in examples and templates have been improved.

  * Incorrect detection of absolute URLs in RSS feed template has been fixed.

  * Incorrect parsing of an anchor for the table of contens has been fixed.

  * The content of &lt;code&gt; and &lt;tt&gt; elements is now preserved verbatim by the @String.to_html@ method.

  * Text that is indented in Textile (which is supposed to be pre-formatted verbatim text) is no longer processed as source code.

  * The <tt>README</tt> and <tt>HISTORY</tt> documentation files have been converted into blog entries. You're reading one of them now!
</SNIP>

Reproducible: Always

Steps to Reproduce:
1. Install redcloth (3.0.4) via ruby gems: sudo gem install redcloth
2. Copy the contents between the <SNIP> tags in the bug description to a file regexp-stack-overflow.yaml.
3. Run the following: 

$ ruby -ryaml -rubygems -e "require 'redcloth'; f = YAML.load_file('regexp-stack-overflow.yaml'); puts RedCloth.new(f['text']).to_html"

Actual Results:  

/usr/lib/ruby/site_ruby/1.8/redcloth.rb:571:in `gsub!': Stack overflow in regexp matcher: /((?:^([#*> ])(?:[^\n]|\n+(?:\2|>)|\n(?!\n|\Z))+))|((?:[^\n]+|\n+ +|\n(?![#*\n]|\Z))+)/m (RegexpError)
        from /usr/lib/ruby/site_ruby/1.8/redcloth.rb:571:in `blocks'
        from /usr/lib/ruby/site_ruby/1.8/redcloth.rb:276:in `to_html'
        from -e:3

Expected Results:  
To have the redcloth/yaml file turned into a string of html.
Comment 1 Rick Moynihan 2007-05-19 09:25:14 UTC
Created attachment 119674 [details]
The YAML/redcloth file which generates the exception
Comment 2 Rick Moynihan 2007-05-19 09:29:56 UTC
Created attachment 119676 [details]
My emerge --info
Comment 3 Xavier Neys (RETIRED) gentoo-dev 2007-05-19 09:53:08 UTC
Created attachment 119679 [details]
emerge --info

You might want to consider an upgrade to gcc-4
This works for me on x86 & amd64 with gcc-4.1.2
Comment 4 Rick Moynihan 2007-05-24 21:26:51 UTC
Created attachment 120229 [details]
emerge --info

I've just upgraded to gcc 4.1.2 and set it to my default with gcc-config.  I've also recompiled Ruby (and system) with it.

I still experience the same error.
Comment 5 Hans de Graaff gentoo-dev Security 2007-05-26 09:00:31 UTC
I'm afraid that I can't reproduce this either with gcc-4.1.1-r3 on an AMD64 system. It might be useful to try to isolate the problem further, hopefully to a single regexp that exhibits this behavior (without the use of YAML, etc). That may provide additional pointers to where the problem is located.
Comment 6 Hans de Graaff gentoo-dev Security 2007-07-08 15:02:35 UTC
Since no new information came to light I'm closing this as WORKSFORME. Without a reproduceable case or a bug fix there isn't that much we can do about it. Please reopen the bug if there is more information.