Project

General

Profile

Backport #8345

Method#to_proc assumes lambda returns a Proc

Added by charliesome (Charlie Somerville) over 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:54687]

Description

=begin
Method#to_proc calls #lambda and assumes the return value is a Proc by passing it to GetProcPtr.

If #lambda is overridden this can cause segfaults:

def lambda
end

method(:puts).to_proc # segfault

=end

Associated revisions

Revision 787cdae5
Added by nobu (Nobuyoshi Nakada) over 6 years ago

proc.c: frozen core methods

  • proc.c (mproc, mlambda): use frozen core methods instead of plain global methods, so that methods cannot be overridden. [ruby-core:54687] [Bug #8345]
  • vm.c (Init_VM): define proc and lambda on the frozen core object.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 40528
Added by nobu (Nobuyoshi Nakada) over 6 years ago

proc.c: frozen core methods

  • proc.c (mproc, mlambda): use frozen core methods instead of plain global methods, so that methods cannot be overridden. [ruby-core:54687] [Bug #8345]
  • vm.c (Init_VM): define proc and lambda on the frozen core object.

Revision 40528
Added by nobu (Nobuyoshi Nakada) over 6 years ago

proc.c: frozen core methods

  • proc.c (mproc, mlambda): use frozen core methods instead of plain global methods, so that methods cannot be overridden. [ruby-core:54687] [Bug #8345]
  • vm.c (Init_VM): define proc and lambda on the frozen core object.

Revision 40528
Added by nobu (Nobuyoshi Nakada) over 6 years ago

proc.c: frozen core methods

  • proc.c (mproc, mlambda): use frozen core methods instead of plain global methods, so that methods cannot be overridden. [ruby-core:54687] [Bug #8345]
  • vm.c (Init_VM): define proc and lambda on the frozen core object.

Revision 40528
Added by nobu (Nobuyoshi Nakada) over 6 years ago

proc.c: frozen core methods

  • proc.c (mproc, mlambda): use frozen core methods instead of plain global methods, so that methods cannot be overridden. [ruby-core:54687] [Bug #8345]
  • vm.c (Init_VM): define proc and lambda on the frozen core object.

Revision 40528
Added by nobu (Nobuyoshi Nakada) over 6 years ago

proc.c: frozen core methods

  • proc.c (mproc, mlambda): use frozen core methods instead of plain global methods, so that methods cannot be overridden. [ruby-core:54687] [Bug #8345]
  • vm.c (Init_VM): define proc and lambda on the frozen core object.

Revision 40528
Added by nobu (Nobuyoshi Nakada) over 6 years ago

proc.c: frozen core methods

  • proc.c (mproc, mlambda): use frozen core methods instead of plain global methods, so that methods cannot be overridden. [ruby-core:54687] [Bug #8345]
  • vm.c (Init_VM): define proc and lambda on the frozen core object.

Revision 12f4488c
Added by nagachika (Tomoyuki Chikanaga) about 6 years ago

merge revision(s) 40525,40526,40528,40530: [Backport #8345]

    proc.c: remove unnecessary static function

    * proc.c (proc_lambda): remove and use rb_block_lambda directly

instead.
* include/ruby/intern.h (rb_block_lambda): add declaration instead of
deprecated rb_f_lambda.

    * proc.c (mproc, mlambda): use frozen core methods instead of plain
      global methods, so that methods cannot be overridden.
      [ruby-core:54687] [Bug #8345]

    * vm.c (Init_VM): define proc and lambda on the frozen core object.

    * defs/id.def (predefined): add "idProc".

    * proc.c (mnew, mproc, mlambda): use predefined IDs.

    * vm.c (Init_VM): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@41394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision f8665e42
Added by usa (Usaku NAKAMURA) about 6 years ago

merge revision(s) 40525,40526,40528,40530: [Backport #8345]

    proc.c: remove unnecessary static function

    * proc.c (proc_lambda): remove and use rb_block_lambda directly

instead.
* include/ruby/intern.h (rb_block_lambda): add declaration instead of
deprecated rb_f_lambda.

    * proc.c (mproc, mlambda): use frozen core methods instead of plain
      global methods, so that methods cannot be overridden.
      [ruby-core:54687] [Bug #8345]

    * vm.c (Init_VM): define proc and lambda on the frozen core object.

    * defs/id.def (predefined): add "idProc".

    * proc.c (mnew, mproc, mlambda): use predefined IDs.

    * vm.c (Init_VM): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@41649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 41649
Added by usa (Usaku NAKAMURA) about 6 years ago

merge revision(s) 40525,40526,40528,40530: [Backport #8345]

proc.c: remove unnecessary static function

* proc.c (proc_lambda): remove and use rb_block_lambda directly

instead.
* include/ruby/intern.h (rb_block_lambda): add declaration instead of
deprecated rb_f_lambda.

* proc.c (mproc, mlambda): use frozen core methods instead of plain
  global methods, so that methods cannot be overridden.
  [ruby-core:54687] [Bug #8345]

* vm.c (Init_VM): define proc and lambda on the frozen core object.

* defs/id.def (predefined): add "idProc".

* proc.c (mnew, mproc, mlambda): use predefined IDs.

* vm.c (Init_VM): ditto.

History

Updated by charliesome (Charlie Somerville) over 6 years ago

=begin
The same happens with Proc#curry too:

def proc
end

->{}.curry

=end

#2

Updated by nobu (Nobuyoshi Nakada) over 6 years ago

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

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


proc.c: frozen core methods

  • proc.c (mproc, mlambda): use frozen core methods instead of plain global methods, so that methods cannot be overridden. [ruby-core:54687] [Bug #8345]
  • vm.c (Init_VM): define proc and lambda on the frozen core object.
#3

Updated by nagachika (Tomoyuki Chikanaga) about 6 years ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: REQUIRED, 2.0.0: REQUIRED

This issue seems like happen in 1.9.3p433 and 2.0.0p222.

#4

Updated by nagachika (Tomoyuki Chikanaga) about 6 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport200
  • Status changed from Closed to Assigned
  • Assignee changed from charliesome (Charlie Somerville) to nagachika (Tomoyuki Chikanaga)
#5

Updated by nagachika (Tomoyuki Chikanaga) about 6 years ago

  • Status changed from Assigned to Closed

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


merge revision(s) 40525,40526,40528,40530: [Backport #8345]

proc.c: remove unnecessary static function

* proc.c (proc_lambda): remove and use rb_block_lambda directly

instead.
* include/ruby/intern.h (rb_block_lambda): add declaration instead of
deprecated rb_f_lambda.

* proc.c (mproc, mlambda): use frozen core methods instead of plain
  global methods, so that methods cannot be overridden.
  [ruby-core:54687] [Bug #8345]

* vm.c (Init_VM): define proc and lambda on the frozen core object.

* defs/id.def (predefined): add "idProc".

* proc.c (mnew, mproc, mlambda): use predefined IDs.

* vm.c (Init_VM): ditto.
#6

Updated by nagachika (Tomoyuki Chikanaga) about 6 years ago

  • Project changed from Backport200 to Backport193
  • Status changed from Closed to Assigned
  • Assignee changed from nagachika (Tomoyuki Chikanaga) to usa (Usaku NAKAMURA)
#7

Updated by usa (Usaku NAKAMURA) about 6 years ago

  • Status changed from Assigned to Closed

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


merge revision(s) 40525,40526,40528,40530: [Backport #8345]

proc.c: remove unnecessary static function

* proc.c (proc_lambda): remove and use rb_block_lambda directly

instead.
* include/ruby/intern.h (rb_block_lambda): add declaration instead of
deprecated rb_f_lambda.

* proc.c (mproc, mlambda): use frozen core methods instead of plain
  global methods, so that methods cannot be overridden.
  [ruby-core:54687] [Bug #8345]

* vm.c (Init_VM): define proc and lambda on the frozen core object.

* defs/id.def (predefined): add "idProc".

* proc.c (mnew, mproc, mlambda): use predefined IDs.

* vm.c (Init_VM): ditto.

Also available in: Atom PDF