Bugs: Browse | Submit New | Admin

[#11510] first eight bytes of regular expression overwritten with garbage; oniguruma x64 issue?

Date:
2007-06-11 21:55
Priority:
3
Submitted By:
Ben Crowell (bcrowell)
Assigned To:
Yukihiro Matsumoto (matz)
Category:
Misc / Other Standard Library
State:
Open
Platform:
 
Summary:
first eight bytes of regular expression overwritten with garbage; oniguruma x64 issue?

Detailed description
Sorry that I was not able to cut this down to a smaller example, but, as explained below, the bug goes away with almost
any seemingly trivial change to my source code.

When I run the script "bug" from the attached tarball, I get the following output:

warning, undefined reference nonmetricunits
warning, undefined reference electroncapture
./a.rb:570:in `block in handle_math': unmatched close parenthesis: /pjy\000\000\000\000\000in|end){align\*?}/
(RegexpError)
        from ./a.rb:564:in `each'
        from ./a.rb:564:in `handle_math'
        from ./a.rb:760:in `parse_para'
        from ./a.rb:1048:in `block in <main>'
        from ./a.rb:1046:in `each'
        from ./a.rb:1046:in `<main>'

In the "unmatched close parenthesis" error message, ruby is quoting line 570 from the file a.rb, but if you
look at line 570, it looks like this:

    tex.split(/\\(?:begin|end){#{x}\*?}/).each { |m|

In other words, the first eight characters of my source code have been overwritten with garbage. This error does not
seem to occur on machines with 32-bit pointers.

Strangely, trivial changes to the source code make the error go away. For instance, if I delete the third line of a.rb,
which is a comment, the error goes away.

Information about my system:
$ uname -a
Linux rintintin 2.6.20-15-generic #2 SMP Sun Apr 15 06:17:24 UTC 2007 x86_64 GNU/Linux
$ ruby --version
ruby 1.9.0 (2007-05-07 patchlevel 0) [x86_64-linux]

Add A Comment: Notepad

Please login


Followup

Message
Date: 2007-06-15 21:11
Sender: Ben Crowell

This bug does not occur on the following system:

$ uname -a
Linux muffin 2.6.20-15-generic #2 SMP Sun Apr 15 07:36:31
UTC 2007 i586 GNU/Linux
$ ruby --version
ruby 1.9.0 (2007-06-10 patchlevel 0) [i586-linux]

This makes me think it's a problem with oniguruma code
that's not 64-bit clean.
Date: 2007-06-14 15:39
Sender: Shyouhei Urabe

Assigning to matz as this is 1.9 specific.

Attached Files:

Name Description Download
bug.tar.gz a ruby program, its input, and a script ("bug") that executes the ruby program Download

Changes:

Field Old Value Date By
assigned_toshyouhei2007-06-14 15:39shyouhei
File Added2092: bug.tar.gz2007-06-11 21:55bcrowell