Project

General

Profile

Bug #13223

Updated by nobu (Nobuyoshi Nakada) almost 8 years ago

The program below will crash with a segv: 

 ~~~ruby ~~~ 
 File.const_set :Separator, "hello" 
 File.const_set :SEPARATOR, "hello" 

 GC.start 

 File.join "hello", "world" 
 ~~~ 

 This is because the separator object is referenced from a global variable and setting the constants allows the object to be GC'd and the global will go bad. 

 I've attached a patch that contains a test to demonstrate the problem along with a fix.

Back