[#79914] [Ruby trunk Bug#13282] opt_str_freeze does not always dedupe — normalperson@...
Issue #13282 has been reported by Eric Wong.
4 messages
2017/03/05
[#80140] [Ruby trunk Feature#13295] [PATCH] compile.c: apply opt_str_freeze to String#-@ (uminus) — shyouhei@...
Issue #13295 has been updated by shyouhei (Shyouhei Urabe).
5 messages
2017/03/13
[#80362] Re: [Ruby trunk Feature#13295] [PATCH] compile.c: apply opt_str_freeze to String#-@ (uminus)
— Eric Wong <normalperson@...>
2017/03/26
shyouhei@ruby-lang.org wrote:
[#80368] Re: [Ruby trunk Feature#13295] [PATCH] compile.c: apply opt_str_freeze to String#-@ (uminus)
— SASADA Koichi <ko1@...>
2017/03/27
On 2017/03/26 15:16, Eric Wong wrote:
[#80205] Re: [ruby-cvs:65166] duerst:r58000 (trunk): clarifiy 'codepoint' in documentation of String#each_codepoint — Eric Wong <normalperson@...>
duerst@ruby-lang.org wrote:
4 messages
2017/03/17
[#80213] Re: [ruby-cvs:65166] duerst:r58000 (trunk): clarifiy 'codepoint' in documentation of String#each_codepoint
— Martin J. Dürst <duerst@...>
2017/03/17
Hello Eric,
[#80290] [Ruby trunk Feature#13355] [PATCH] compile.c: optimize literal String range in case/when dispatch — normalperson@...
Issue #13355 has been reported by normalperson (Eric Wong).
4 messages
2017/03/23
[#80410] Re: [Ruby trunk Feature#13355] [PATCH] compile.c: optimize literal String range in case/when dispatch
— Eric Wong <normalperson@...>
2017/03/27
normalperson@yhbt.net wrote:
[#80415] [Ruby trunk Feature#12589] VM performance improvement proposal — vmakarov@...
Issue #12589 has been updated by vmakarov (Vladimir Makarov).
5 messages
2017/03/28
[#80488] [Ruby trunk Feature#12589] VM performance improvement proposal — vmakarov@...
Issue #12589 has been updated by vmakarov (Vladimir Makarov).
4 messages
2017/03/29
[ruby-core:80007] [Ruby trunk Feature#13300] Strip chroot path from $LOADED_FEATURES when calling Dir.chroot
From:
nobu@...
Date:
2017-03-11 01:43:14 UTC
List:
ruby-core #80007
Issue #13300 has been updated by Nobuyoshi Nakada.
Should not use `features_index_add`.
By replacing `$LOADED_FEATURES`, the internal snapshot will be invalidated.
And doesn't `$LOAD_PATH` need to be stripped?
```diff
diff --git a/dir.c b/dir.c
index 365f059b0f..3b55e4f4a0 100644
--- a/dir.c
+++ b/dir.c
@@ -1119,10 +1119,42 @@ check_dirname(VALUE dir)
static VALUE
dir_s_chroot(VALUE dir, VALUE path)
{
+ VALUE features = rb_gv_get("$LOADED_FEATURES");
+ VALUE chroot_to;
+
path = check_dirname(path);
+ chroot_to = rb_file_s_expand_path(1, &path);
if (chroot(RSTRING_PTR(path)) == -1)
rb_sys_fail_path(path);
+ if (rb_type(features) == RUBY_T_ARRAY &&
+ rb_type(chroot_to) == RUBY_T_STRING) {
+ long i, features_len, chroot_len, feature_min_len;
+ VALUE feature, old_features = 0;
+ char * chroot_str = RSTRING_PTR(chroot_to);
+
+ features_len = RARRAY_LEN(features);
+ chroot_len = RSTRING_LEN(chroot_to);
+ feature_min_len = chroot_len + 1;
+
+ for (i=0; i < features_len; i++) {
+ feature = RARRAY_AREF(features, i);
+ if ((rb_type(feature) == RUBY_T_STRING) &&
+ RSTRING_LEN(feature) > feature_min_len &&
+ strncmp(chroot_str, RSTRING_PTR(feature), chroot_len) == 0) {
+ if (!old_features) {
+ features = rb_ary_dup(old_features = features);
+ }
+ feature = rb_str_substr(feature, chroot_len,
+ RSTRING_LEN(feature));
+ RARRAY_ASET(features, i, feature);
+ }
+ }
+ if (old_features) {
+ rb_ary_replace(old_features, features);
+ }
+ }
+
return INT2FIX(0);
}
#else
```
----------------------------------------
Feature #13300: Strip chroot path from $LOADED_FEATURES when calling Dir.chroot
https://bugs.ruby-lang.org/issues/13300#change-63424
* Author: Jeremy Evans
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
Currently, `Dir.chroot` doesn't modify `$LOADED_FEATURES`, leading
to a situation where `Kernel#require` will attempt to load the same
file twice, or a different file not at all because it thinks it
is already loaded.
With this example code:
~~~ ruby
require 'fileutils'
File.write('baz.rb', 'A = 1')
require './baz'
pwd = Dir.pwd
Dir.chroot(pwd)
require './baz'
FileUtils.mkdir_p(pwd)
File.write(File.join(pwd, 'baz.rb'), '$a = 2')
require "#{pwd}/baz"
warn "$a => #{$a.inspect}" unless $a == 2
~~~
Previous output on stderr:
~~~
/baz.rb:1: warning: already initialized constant A
/home/billg/baz.rb:1: warning: previous definition of A was here
$a => nil
~~~
With this patch, no output on stderr.
---Files--------------------------------
0001-Strip-chroot-path-from-LOADED_FEATURES-when-calling-.patch (2.6 KB)
--
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>