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