Backport #8220

Segmentation fault when providing defined? operator with empty parentheses

Added by Ross Smith about 1 year ago. Updated about 1 year ago.

[ruby-core:53999]
Status:Closed
Priority:Normal
Assignee:Tomoyuki Chikanaga

Description

=begin
Reproducing steps:
* Execute the code: (({defined? ()}))

Ruby version:
* ((%ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]%))

Expected result:
* Expected the same error as ruby 1.9.3: ((%syntax error, unexpected ')'%))

Actual result:
* Ruby crashed with the attached error log:
=end

error_log.txt Magnifier (10 KB) Ross Smith, 04/05/2013 01:01 AM


Related issues

Follows ruby-trunk - Bug #8224: defined?(()) and defined? () are inconsistent Closed 04/05/2013

Associated revisions

Revision 40312
Added by Tomoyuki Chikanaga about 1 year ago

merge revision(s) 40124: [Backport #8220]

* compile.c (iseq_compile_each): fix of defined? with empty
  expression.   [Bug #8220]

History

#1 Updated by Nobuyoshi Nakada about 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r40124.
Ross, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


compile.c: defined? with empty expression

  • compile.c (iseqcompileeach): fix of defined? with empty expression. [Bug #8220]

#2 Updated by Tomoyuki Chikanaga about 1 year ago

Hello, nobu.

r40124 fixes a segv but defined? () behaves like defined? nil.
How do you think to raise SyntaxError for defined? () (as 1.9.3).

Thanks,

#3 Updated by Nobuyoshi Nakada about 1 year ago

The parenthesis is interpreted differently between 2.0 and earlier, it
was "interpreted as grouped expression" till 1.9. That warning has
been removed in 2.0 and now that syntax can be accepted.

That is, the error was a restriction in older versions, and I think
it's not worth replicating.

#4 Updated by Tomoyuki Chikanaga about 1 year ago

  • Tracker changed from Bug to Backport
  • Project changed from ruby-trunk to Backport200
  • Status changed from Closed to Assigned
  • Assignee set to Tomoyuki Chikanaga

nobu, thank you for your explanation.
I understand the fix depends on an existing incompatibility between 2.0 and 1.9.x.
I'll merge r40124 to ruby20_0.

#5 Updated by Tomoyuki Chikanaga about 1 year ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r40312.
Ross, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 40124: [Backport #8220]

* compile.c (iseq_compile_each): fix of defined? with empty
  expression.   [Bug #8220]

Also available in: Atom PDF