Project

General

Profile

Bug #11109

Crash of irb.

Added by yangzhijava (Jeffrey Yang) about 5 years ago. Updated about 5 years ago.

Status:
Third Party's Issue
Priority:
Normal
Assignee:
ruby-core
Target version:
-
ruby -v:
2.2.2
Backport:
[ruby-core:69033]

Description

ENV:
Mac OS X 10.10.3
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]

HOW TO COMPILE:

  1. cd to the dir of ruby 2.2.2.
  2. ./configure
  3. make
  4. make install as root.

STEPS:

  1. Start the irb on console.
  2. Type the following code lines in irb:

    require 'stringio'
    require 'bson'
    sio = StringIO.new 1.to_bson
    BSON::Int64. from_bson sio
    
  3. The crash happens.

Please see also the attached file for all details.


Files

bug_report.txt (12 KB) bug_report.txt yangzhijava (Jeffrey Yang), 04/30/2015 01:44 PM
bug.rb (151 Bytes) bug.rb yangzhijava (Jeffrey Yang), 04/30/2015 02:58 PM
bug.rb (162 Bytes) bug.rb yangzhijava (Jeffrey Yang), 04/30/2015 04:06 PM

Updated by yangzhijava (Jeffrey Yang) about 5 years ago

I double-checked the backtrace in the attached log, in which it shows the rb_integer_from_bson_int64 causes the crash, however I was not sure. Could you guys still check the attached log file for confirmation?

Of course, I will contact the author of BSON and show him the log.

Apologizes if it's a wrong bug.

Updated by nobu (Nobuyoshi Nakada) about 5 years ago

  • Description updated (diff)
  • Status changed from Open to Third Party's Issue
  • Priority changed from 5 to Normal

BSON::Int64.from_bson seems to accept String only, but not to check the argument.

Updated by yangzhijava (Jeffrey Yang) about 5 years ago

BSON::Int64.from_bson accepts the object who can response IO#read, so I have to wrap a string with StringIO.

After re-checking, I found how to reproduce the bug. Please see also my attached file.

In the file, I called BSON::Int64.from_bson firstly, then BSON::Int32.from_bson, the same crash always happened in the second call of BSON::IntXX.from_bson. That means if Int32.from_bson is the second call, the crash happens, if Int64.from_bson is the second one, the crash happens, too.

Please see also bug.rb.

Updated by nobu (Nobuyoshi Nakada) about 5 years ago

IO#read and StringIO#read return nil at EOF.

https://github.com/mongodb/bson-ruby/pull/31

Updated by yangzhijava (Jeffrey Yang) about 5 years ago

Thanks for your fix and advise.

I added a sio.rewind between from_bson. The script works well. I should've realized the EOF issue.

Please see also the attached file.

By the way, how long does a bugfix be merged into BSON's master branch?

Updated by yangzhijava (Jeffrey Yang) about 5 years ago

Thanks for your help. One more question, when can I close the bug?

Updated by nobu (Nobuyoshi Nakada) about 5 years ago

Already.
"Third Party's Issue" is a kind of "Closed."

Also available in: Atom PDF