[#105450] [Ruby master Feature#18228] Add a `timeout` option to `IO.copy_stream` — "byroot (Jean Boussier)" <noreply@...>
Issue #18228 has been reported by byroot (Jean Boussier).
11 messages
2021/09/27
[ruby-core:105402] [Ruby master Bug#17885] require_relative and require should be compatible with each other when symlinked files are used
From:
"jeremyevans0 (Jeremy Evans)" <noreply@...>
Date:
2021-09-23 23:28:14 UTC
List:
ruby-core #105402
Issue #17885 has been updated by jeremyevans0 (Jeremy Evans).
Status changed from Closed to Open
Reopening this since the patch was reverted.
After multiple previous attempts to fix this were shown to still have the same issue by the AWS Graviton2 gcc 11 CI (thank you @fkorotkov), I was finally able to reproduce the problem locally by calling `Thread.pass` inside `load_lock`. The issue is a race-condition in `ruby_verbose` checking in `load_lock`. The simplest way to fix it is to allow silencing the warning when loading encoders and transcoders. The encoder loading code already implicitly set `ruby_verbose` to false before loading, and back to its original setting after loading. The transcoder was also being required, and could also trigger the warning. If the transcoder require happened after the encoder finished, the warning was generated. I think the code was always vulnerable to a race condition, it just took the use of realpath when loading to expose the race condition between the encoder loading and transcoder loading.
To fix this, I adding a `warn` argument to `require_internal` and `load_lock`, and I added `rb_require_internal_silent`, which never issues the warning. Then I had encoder and transcoder loading use `rb_require_internal_silent` to avoid the warning.
Revised pull request at https://github.com/ruby/ruby/pull/4887
----------------------------------------
Bug #17885: require_relative and require should be compatible with each other when symlinked files are used
https://bugs.ruby-lang.org/issues/17885#change-93817
* Author: john_firebaugh (John Firebaugh)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-darwin19]
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
This is similar to #10222 (which was fixed), but it's with symlinked files. #10222 was with symlinked directories.
If files are symlinked, then mixing `require` and `require_relative` can result in the same file being loaded twice.
```
mkdir a
echo "require_relative 'b'" > a/a.rb
echo "p 'b loaded'" > a/b.rb
mkdir b
ln -s ../a/a.rb b
ln -s ../a/b.rb b
echo "$: << File.expand_path('../b', __FILE__); require 'b'; require 'a'" > c.rb
ruby c.rb
```
Expected behavior is that this prints "b loaded" once. Actual behavior is that it prints "b loaded" twice.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>