From: eregontp@... Date: 2017-03-14T13:58:09+00:00 Subject: [ruby-core:80157] [Ruby trunk Bug#13223] `File.join` will segv if File::SEPARATOR and File::Separator are set. Issue #13223 has been updated by Eregon (Benoit Daloze). shyouhei (Shyouhei Urabe) wrote: > Nobu already made changes but, yes we looked at this issue in today's developer meeting. > > File::SEPARATOR has been there, but not always used. For instance File.split does not honor that constant. JRuby is well-doing to carefully read our document but, we agreed that this is not somewhere we have to hustle. > > Let us define File::SEPARATOR to be _the default value of_ the file path separator; redefinition of it may or may not affect further invokations of methods, depending on implementations. It is *much* better to not leave semantics to be implementation-defined, as it's essentially the same as undefined behavior and C people know how bad that is. So I think we should settle to only one of the two possibilities here. Otherwise any program using File.join and modifying File::SEPARATOR will produce different results based on the Ruby implementation, which is inacceptable for such a method. ---------------------------------------- Bug #13223: `File.join` will segv if File::SEPARATOR and File::Separator are set. https://bugs.ruby-lang.org/issues/13223#change-63595 * Author: tenderlovemaking (Aaron Patterson) * Status: Closed * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.5.0dev (2017-02-17 trunk 57648) [x86_64-darwin16] * Backport: 2.2: DONTNEED, 2.3: DONTNEED, 2.4: DONTNEED ---------------------------------------- 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. ---Files-------------------------------- 0001-Fix-segv-in-File.join-when-SEPARATOR-and-Separator-a.patch (3.04 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: