Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kgio::Pipe.new results in a stack overflow #2692

Closed
eregon opened this issue Jul 20, 2022 · 1 comment
Closed

Kgio::Pipe.new results in a stack overflow #2692

eregon opened this issue Jul 20, 2022 · 1 comment

Comments

@eregon
Copy link
Member

eregon commented Jul 20, 2022

CRuby:

$ ruby -e 'require "kgio"; p Kgio::Pipe.new'      
[#<Kgio::Pipe:fd 7>, #<Kgio::Pipe:fd 8>]
$ ruby -e 'require "kgio"; p Kgio::Pipe.ancestors'
[Kgio::Pipe, Kgio::PipeMethods, Kgio::DefaultWaiters, IO, File::Constants, Enumerable, Object, Kernel, BasicObject]

TruffleRuby:

$ ruby -e 'require "kgio"; p Kgio::Pipe.new'      
[ruby] WARNING StackOverflowError
[ruby] WARNING StackOverflowError
[ruby] WARNING StackOverflowError
[ruby] WARNING StackOverflowError
<internal:core> core/truffle/ffi/pointer.rb:245:in `new': stack level too deep (SystemStackError)
	from com.oracle.svm.core.graal.snippets.StackOverflowCheckImpl.newStackOverflowError0(StackOverflowCheckImpl.java:333)
	from <internal:core> core/truffle/io_operations.rb:103:in `create_pipe'
	from <internal:core> core/io.rb:681:in `pipe'
	from <internal:core> core/truffle/io_operations.rb:109:in `create_pipe'
	from <internal:core> core/io.rb:681:in `pipe'
	from <internal:core> core/truffle/io_operations.rb:109:in `create_pipe'
	from <internal:core> core/io.rb:681:in `pipe'
	from <internal:core> core/truffle/io_operations.rb:109:in `create_pipe'
	from <internal:core> core/io.rb:681:in `pipe'
...
	from <internal:core> core/truffle/io_operations.rb:109:in `create_pipe'
	from <internal:core> core/io.rb:681:in `pipe'
	from <internal:core> core/truffle/io_operations.rb:109:in `create_pipe'
	from <internal:core> core/io.rb:681:in `pipe'
	from <internal:core> core/truffle/io_operations.rb:109:in `create_pipe'
	from <internal:core> core/io.rb:681:in `pipe'
	from -e:1:in `<main>'

The issue seems to be we assume IO and subclasses have a def initialize(fd, mode=nil) or so constructor but that doesn't seem true for Kgio::Pipe which inherits from IO, and so read_class.new(fds[0], IO::RDONLY) doesn't work as expected.

Found in sinatra/sinatra#1799

@andrykonchin andrykonchin self-assigned this Jul 21, 2022
@eregon eregon added this to the 22.3.0 milestone Jul 27, 2022
@andrykonchin
Copy link
Member

Fixed in ca0c55e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants