Project

General

Profile

Actions

Bug #20045

open

`TestDir#test_home` fails on i686

Added by vo.x (Vit Ondruch) 12 months ago. Updated 11 months ago.

Status:
Assigned
Target version:
-
ruby -v:
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [i686-linux]
[ruby-core:115635]

Description

This is followup to #19147. Testing on Fedora 38 and Fedora Rawhide, we are facing this test failure:

$ tar xf build/SOURCES/ruby-3.2.2.tar.xz
$ cd ruby-3.2.2/
$ ./configure && make

... snip ...

---
Configuration summary for ruby version 3.2.2

   * Installation prefix: /usr/local
   * exec prefix:         ${prefix}
   * arch:                i686-linux
   * site arch:           ${arch}
   * RUBY_BASE_NAME:      ruby
   * ruby lib prefix:     ${libdir}/${RUBY_BASE_NAME}
   * site libraries path: ${rubylibprefix}/${sitearch}
   * vendor path:         ${rubylibprefix}/vendor_ruby
   * target OS:           linux
   * compiler:            gcc
   * with thread:         pthread
   * with coroutine:      x86
   * enable shared libs:  no
   * dynamic library ext: so
   * CFLAGS:              ${optflags} ${debugflags} ${warnflags}
   * LDFLAGS:             -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic
   * DLDFLAGS:            -Wl,--compress-debug-sections=zlib
   * optflags:            -O3 -fno-fast-math
   * debugflags:          -ggdb3
   * warnflags:           -Wall -Wextra -Wdeprecated-declarations -Wdiv-by-zero -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wold-style-definition \
                          -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat \
                          -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef
   * strip command:       strip -S -x
   * install doc:         rdoc
   * MJIT support:        yes
   * YJIT support:        no
   * man page type:       doc

---

... snip ...

$ LANG=C make test-all 'TESTS=-v -n /TestDir#test_home/'
config.status: creating ruby-runner.h
making mjit_build_dir.so
generating i686-linux-fake.rb
i686-linux-fake.rb updated
Run options: 
  --seed=10517
  "--ruby=./miniruby -I./lib -I. -I.ext/common  ./tool/runruby.rb --extout=.ext  -- --disable-gems"
  --excludes-dir=./test/excludes
  --name=!/memory_leak/
  -v
  -n
  /TestDir#test_home/

# Running tests:

[1/0] TestDir#test_home = 0.00 s

  1) Error:
TestDir#test_home:
RuntimeError: can't set length of shared string
    /builddir/ruby-3.2.2/test/ruby/test_dir.rb:557:in `expand_path'
    /builddir/ruby-3.2.2/test/ruby/test_dir.rb:557:in `block in test_home'

Finished tests in 4.164691s, 0.2401 tests/s, 1.6808 assertions/s.
1 tests, 7 assertions, 0 failures, 1 errors, 0 skips

ruby -v: ruby 3.2.2 (2023-03-30 revision e51014f9c0) [i686-linux]
make: *** [uncommon.mk:855: yes-test-all] Error 1

Please note that having the C locale is essential. The test passes just fine with e.g. C.UTF-8 locale.

We were able to reduce the test case to the following:

$ whoami
mockbuild

$ echo 'File.expand_path("~mockbuild")' > test.rb

$ LANG=C RUBYLIB=/builddir/ruby-3.2.2/.ext/i686-linux LD_LIBRARY_PATH=. ./ruby --disable-gems test.rb
test.rb:1:in `expand_path': can't set length of shared string (RuntimeError)
	from test.rb:1:in `<main>'

As I said earlier, the LANG=C is essential as well as the RUBYLIB=/builddir/ruby-3.2.2/.ext/i386-linux. Adding the path to RUBYLIB enables Ruby to load the following libraries:

/builddir/ruby-3.2.2/.ext/i686-linux/enc/encdb.so
/builddir/ruby-3.2.2/.ext/i686-linux/enc/trans/transdb.so

And that makes the difference. Also, the File.expand_path("~mockbuild") must be in some file, replacing this by -e 'File.expand_path("~mockbuild")' does not reproduce the issue.

We also believe that this was introduced by https://github.com/ruby/ruby/pull/6699, specifically by git|5246f4027ec574e77809845e1b1f7822cc2a5cef and fixed in master by git|b4571097df4a6bd848f1195026d82a92f3a7f9d8.

Unfortunately, we were not able to discover what is the mechanism behind this, why this depends on locale, why the test must be in file, why the string is shared etc. But I hope we have provided enough details for someone else more knowledgeable.

Some background for this issue is also available here:

https://src.fedoraproject.org/rpms/ruby/pull-request/164

Actions

Also available in: Atom PDF

Like0
Like0Like0