Issue #11109 has been updated by Jeffrey Yang.

File bug.rb added

`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`.

----------------------------------------
Bug #11109: Crash of irb.
https://bugs.ruby-lang.org/issues/11109#change-52295

* Author: Jeffrey Yang
* Status: Third Party's Issue
* Priority: Normal
* Assignee: ruby-core
* ruby -v: 2.2.2
* Backport: 2.2: UNKNOWN
----------------------------------------
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:

    ```ruby
    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.rb (151 Bytes)


-- 
https://bugs.ruby-lang.org/