DevHeads.net

Rawhide / ruby / SystemStackError / "stack level too deep"

If anyone notices Ruby programs which suddenly start to throw stack
overflow errors (SystemStackError or the error message
"stack level too deep") but *only* in the latest Rawhide (glibc >=
2.26-9000, ruby >= 2.5.0), then I'm interested to hear from you.

Rich.

Comments

Re: Rawhide / ruby / SystemStackError / "stack level too deep"

By Florian Weimer at 01/11/2018 - 08:19

On 01/11/2018 12:42 PM, Richard W.M. Jones wrote:
Could you reproduce this outside of Koji?

Thanks,
Florian

Re: Rawhide / ruby / SystemStackError / "stack level too deep"

By Richard W.M. Jones at 01/11/2018 - 09:14

On Thu, Jan 11, 2018 at 01:19:41PM +0100, Florian Weimer wrote:
Oh yes, very much so. You need absolutely latest Rawhide however
(certainly of glibc & ruby, not sure what else).

git clone <a href="https://github.com/libguestfs/nbdkit" title="https://github.com/libguestfs/nbdkit">https://github.com/libguestfs/nbdkit</a>
sudo dnf builddep nbdkit
cd nbdkit
./configure
make
make check -C tests TESTS=test-ruby

The test will fail with an error message:

nbdkit: error: ruby: stack level too deep

To go further with debugging it, I found the easiest way was:

gdb --args src/nbdkit -f -v plugins/ruby/.libs/nbdkit-ruby-plugin.so tests/test.rb
(gdb) break ec_stack_overflow
(gdb) run

In another window do:

telnet localhost 10809

Examining the Ruby execution context (*ec) seems to show that Ruby
gets confused by the use of C pthreads:

machine = {
stack_start = 0x7fffffffe000, <-- in the main thread stack
stack_end = 0x7ffff46997e8, <-- apparently "huge" stack
stack_maxsize = 8384512,

which is caused just because we're running in a different thread from
the main thread.

What strange is how this suddenly started to happen, whereas the same
code has been working fine for years. Unfortunately I cannot now
downgrade glibc to "prove" this is a glibc thing, rather than what's
more likely which is it's either Ruby itself or the test.

Rich.

Re: Rawhide / ruby / SystemStackError / "stack level too deep"

By Richard W.M. Jones at 01/11/2018 - 10:10

OK I believe this is actually a bug in the nbdkit plugin rather than
glibc / Ruby. Apparently you need to call some functions to tell Ruby
about the thread stacks. Totally undocumented ...

Rich.

Re: Rawhide / ruby / SystemStackError / "stack level too deep"

By Jun Aruga at 01/11/2018 - 11:44

I faced "stack level too deep" when running a unit test for rubygem-mysql2.
As when I ran the case's logic it manually, that was okay, I just
commented out the test case.
<a href="https://src.fedoraproject.org/rpms/rubygem-mysql2/blob/master/f/rubygem-mysql2.spec#_154" title="https://src.fedoraproject.org/rpms/rubygem-mysql2/blob/master/f/rubygem-mysql2.spec#_154">https://src.fedoraproject.org/rpms/rubygem-mysql2/blob/master/f/rubygem-...</a>

<a href="https://github.com/rails/rails/blob/v5.0.0/activesupport/CHANGELOG.md" title="https://github.com/rails/rails/blob/v5.0.0/activesupport/CHANGELOG.md">https://github.com/rails/rails/blob/v5.0.0/activesupport/CHANGELOG.md</a>
stack level too deep error

Jun

On Thu, Jan 11, 2018 at 3:10 PM, Richard W.M. Jones < ... at redhat dot com> wrote: