Project

General

Profile

Bug #12441

Segfault in mod_exp

Added by technion (Joshua Small) over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
[ruby-core:75785]

Description

I have the piece of code crashing reliably.

#!/usr/bin/env ruby

require 'openssl'

p = 65997564567567456745676645367739412743227643334286989217363396439283464537000853588029739004855929104754800897261407081024749574299035313695899693187167


def mything(h)
  b = 43554325436535756
  k = h.to_bn.mod_exp(b, p)
end



h = 3007963317613531062721539798844764834140098543127007866692410407137612395983233591022449771190189492227443776860661459473931676217894527075146085609662899

puts mything h

I have written very similar pieces of code before without an issue but this but particular one seems to have hit something. I have attached a crash report.


Files

crash.log (13.4 KB) crash.log Crash log technion (Joshua Small), 05/31/2016 09:34 AM

Associated revisions

Revision 31dc77ae
Added by nagachika (Tomoyuki Chikanaga) over 3 years ago

merge revision(s) 55047: [Backport #12441]

    * ext/openssl/ossl_bn.c (try_convert_to_bnptr): Extracted from
      GetBNPtr(). This doesn't raise exception but returns NULL on error.
      (GetBNPtr): Raise TypeError if conversion fails.
      (ossl_bn_eq): Implement BN#==.
      (ossl_bn_eql): #eql? should not raise TypeError even if the argument
      is not compatible with BN.
      (ossl_bn_hash): Implement BN#hash.

    * ext/openssl/ossl_bn.c (Init_ossl_bn): Define #== and #hash.

    * test/openssl/test_bn.rb: Test BN#eql?, #== and #hash

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

Revision 55906
Added by nagachika (Tomoyuki Chikanaga) over 3 years ago

merge revision(s) 55047: [Backport #12441]

* ext/openssl/ossl_bn.c (try_convert_to_bnptr): Extracted from
  GetBNPtr(). This doesn't raise exception but returns NULL on error.
  (GetBNPtr): Raise TypeError if conversion fails.
  (ossl_bn_eq): Implement BN#==.
  (ossl_bn_eql): #eql? should not raise TypeError even if the argument
  is not compatible with BN.
  (ossl_bn_hash): Implement BN#hash.

* ext/openssl/ossl_bn.c (Init_ossl_bn): Define #== and #hash.

* test/openssl/test_bn.rb: Test BN#eql?, #== and #hash

Revision a1af7155
Added by usa (Usaku NAKAMURA) over 3 years ago

merge revision(s) 55047: [Backport #12441]

    * ext/openssl/ossl_bn.c (try_convert_to_bnptr): Extracted from
      GetBNPtr(). This doesn't raise exception but returns NULL on error.
      (GetBNPtr): Raise TypeError if conversion fails.
      (ossl_bn_eq): Implement BN#==.
      (ossl_bn_eql): #eql? should not raise TypeError even if the argument
      is not compatible with BN.
      (ossl_bn_hash): Implement BN#hash.

    * ext/openssl/ossl_bn.c (Init_ossl_bn): Define #== and #hash.

    * test/openssl/test_bn.rb: Test BN#eql?, #== and #hash

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

Revision 55937
Added by usa (Usaku NAKAMURA) over 3 years ago

merge revision(s) 55047: [Backport #12441]

* ext/openssl/ossl_bn.c (try_convert_to_bnptr): Extracted from
  GetBNPtr(). This doesn't raise exception but returns NULL on error.
  (GetBNPtr): Raise TypeError if conversion fails.
  (ossl_bn_eq): Implement BN#==.
  (ossl_bn_eql): #eql? should not raise TypeError even if the argument
  is not compatible with BN.
  (ossl_bn_hash): Implement BN#hash.

* ext/openssl/ossl_bn.c (Init_ossl_bn): Define #== and #hash.

* test/openssl/test_bn.rb: Test BN#eql?, #== and #hash

History

Updated by rhenium (Kazuki Yamaguchi) over 3 years ago

  • Status changed from Open to Closed

The minimal reproducer:

123.to_bn.mod_exp(456, nil)

This is already (unintentionally) fixed in r55047.

Updated by usa (Usaku NAKAMURA) over 3 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: WONTFIX, 2.2: REQUIRED, 2.3: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) over 3 years ago

  • Backport changed from 2.1: WONTFIX, 2.2: REQUIRED, 2.3: REQUIRED to 2.1: WONTFIX, 2.2: REQUIRED, 2.3: DONE

ruby_2_3 r55906 merged revision(s) 55047.

Updated by usa (Usaku NAKAMURA) over 3 years ago

  • Backport changed from 2.1: WONTFIX, 2.2: REQUIRED, 2.3: DONE to 2.1: WONTFIX, 2.2: DONE, 2.3: DONE

ruby_2_2 r55937 merged revision(s) 55047.

Also available in: Atom PDF