Project

General

Profile

Actions

Bug #20071

closed

Reading code from stdin SEGV's when `--parser=prism`

Added by eightbitraptor (Matthew Valentine-House) 5 months ago. Updated 5 months ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:115776]

Description

The following examples all SEGV on master.

ruby --parser=prism
cat test_code.rb | ruby --parser=prism
ruby --parser=prism < test_code.rb

This is because the prism setup code in process_options either assumes that a file has been passed or an explicit string with -e and does not handle the case where the input is expected to come from stdin.

This PR attempts to address this

Updated by eightbitraptor (Matthew Valentine-House) 5 months ago

cc @HParker (Adam Hess)

Would you be ok to take a look at the PR? I'm not sure of the best way to address this.

Actions #2

Updated by eightbitraptor (Matthew Valentine-House) 5 months ago

  • Status changed from Open to Closed

Applied in changeset git|893fe30ef2b30525d932d6b1256f717cc60b3311.


[PRISM] Fix crash when --parser=prism called with stdin

[Bug #20071]

Currently Ruby crashes when the --parser=prism flag is used either with
no input, or with input that is being redirected from stdin. So all of
the following will crash

ruby --parser=prism
ruby --parser=prism < test_code.rb
cat test_code.rb | ruby --parser=prism

This commit checks whether the input is assumed to be from stdin, and
then processes that as a file.

This will fix the second and third case above, but will cause a slight
behavioural changes for the first case - Ruby will treat stdin as an
empty file in this case and exit, rather than waiting for data to be
piped into stdin.

Actions

Also available in: Atom PDF

Like0
Like0Like0