Project

General

Profile

Actions

Bug #11232

closed

rb_compile_string from parse.y segfaults

Added by kyrylo (Kyrylo Silin) almost 9 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
[ruby-core:69483]

Description

I'm using rb_compile_string in my project and invoke it in a loop.
Unfortunately, it segfaults for me.

I've set up a repository with a minimum reproducible case:
https://github.com/kyrylo/rb_compile_string_bug

The bug can be observed with Ruby compiled with the default compiler
flags. While I was debugging this, I decided to compile the same
Ruby with -O0 -g. Surprisingly, the bug did not occur with these
new flags.

Then, I've also tried to test this with this Ruby with the default
flags and it was working fine, without any segfaults:
ruby 2.3.0dev (2015-06-03 trunk 50741) [x86_64-linux].

I suspect that it's already been fixed, but I'm not sure.

Updated by nobu (Nobuyoshi Nakada) almost 9 years ago

  • Status changed from Open to Feedback

Is vparser in parser_compile_string() GCed?

Updated by kyrylo (Kyrylo Silin) almost 9 years ago

Nobuyoshi Nakada wrote:

Is vparser in parser_compile_string() GCed?

It looks like so. I'm not sure how to verify that exactly,
but when I disable the GC, it doesn't segfault anymore.

I have added a second example, with GC.disable.
To run: ruby nobug.rb.

Updated by kyrylo (Kyrylo Silin) almost 9 years ago

Thanks for the tip!
I managed to fix the segfault with the following code:

https://github.com/kyrylo/fast_method_source/blob/d05a19993cccade40176c5f10b9008d79d2fc1e5/ext/fast_method_source/fast_method_source.c#L84-L85

I changed the function I call to rb_parser_compile_string
and passed a parser manually. Voila!

Feel free to close this, if you believe it's not a bug or
it's been fixed.

Actions #4

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Status changed from Feedback to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0