The BinData constructor converts the type to a string, which results in some strange behavior:
> BinData(0, true) BinData(0,"true") > BinData(0, false) Tue Jul 9 19:23:47.995 Error: invalid base64 > BinData(0, {}) Tue Jul 9 19:24:06.081 Error: invalid base64
Because of SERVER-9686, this has more disastrous consequences for HexData:
> HexData(0, true) Tue Jul 9 19:24:25.339 Assertion failure false src/mongo/util/hex.h 34 Tue Jul 9 19:24:25.341 0x10cf701a5 0x10cf499a4 0x10cf1eda2 0x10cda64d0 0x10cda6502 0x10cf01a2c 0x10cf02113 0x10ceca8c2 0x10d0feebd 0x10d0ff26b 0x10d0fbfc8 0x3db1c106362 0 mongo 0x000000010cf701a5 _ZN5mongo15printStackTraceERSo + 37 1 mongo 0x000000010cf499a4 _ZN5mongo10logContextEPKc + 228 2 mongo 0x000000010cf1eda2 _ZN5mongo12verifyFailedEPKcS1_j + 338 3 mongo 0x000000010cda64d0 _ZN5mongo7fromHexEc + 128 4 mongo 0x000000010cda6502 _ZN5mongo7fromHexEPKc + 34 5 mongo 0x000000010cf01a2c _ZN5mongoL12hexToBinDataEPNS_7V8ScopeEN2v85LocalINS2_6ObjectEEEiSs + 364 6 mongo 0x000000010cf02113 _ZN5mongo11hexDataInitEPNS_7V8ScopeERKN2v89ArgumentsE + 531 7 mongo 0x000000010ceca8c2 _ZN5mongo7V8Scope10v8CallbackERKN2v89ArgumentsE + 560 8 mongo 0x000000010d0feebd _ZN2v88internalL19HandleApiCallHelperILb0EEEPNS0_11MaybeObjectENS0_12_GLOBAL__N_116BuiltinArgumentsILNS0_21BuiltinExtraArgumentsE1EEEPNS0_7IsolateE + 1789 9 mongo 0x000000010d0ff26b _ZN2v88internalL26Builtin_Impl_HandleApiCallENS0_12_GLOBAL__N_116BuiltinArgumentsILNS0_21BuiltinExtraArgumentsE1EEEPNS0_7IsolateE + 43 10 mongo 0x000000010d0fbfc8 _ZN2v88internalL21Builtin_HandleApiCallENS0_12_GLOBAL__N_116BuiltinArgumentsILNS0_21BuiltinExtraArgumentsE1EEEPNS0_7IsolateE + 136 11 ??? 0x000003db1c106362 0x0 + 4239603557218 Tue Jul 9 19:24:25.342 ***aborting after verify() failure as this is a debug/test build mongo got signal 6 (Abort trap: 6), stack trace: 0x10cf701a5 0x10cd1cd99 0x7fff8b33194a 0x7fff52ee43d6 0x7fff8b388dce 0x10cf1f011 0x10cda64d0 0x10cda6502 0x10cf01a2c 0x10cf02113 0x10ceca8c2 0x10d0feebd 0x10d0ff26b 0x10d0fbfc8 0x3db1c106362 0 mongo 0x000000010cf701a5 _ZN5mongo15printStackTraceERSo + 37 1 mongo 0x000000010cd1cd99 _Z12quitAbruptlyi + 409 2 libsystem_c.dylib 0x00007fff8b33194a _sigtramp + 26 3 ??? 0x00007fff52ee43d6 0x0 + 140734584734678 4 libsystem_c.dylib 0x00007fff8b388dce abort + 143 5 mongo 0x000000010cf1f011 _ZN5mongo12verifyFailedEPKcS1_j + 961 6 mongo 0x000000010cda64d0 _ZN5mongo7fromHexEc + 128 7 mongo 0x000000010cda6502 _ZN5mongo7fromHexEPKc + 34 8 mongo 0x000000010cf01a2c _ZN5mongoL12hexToBinDataEPNS_7V8ScopeEN2v85LocalINS2_6ObjectEEEiSs + 364 9 mongo 0x000000010cf02113 _ZN5mongo11hexDataInitEPNS_7V8ScopeERKN2v89ArgumentsE + 531 10 mongo 0x000000010ceca8c2 _ZN5mongo7V8Scope10v8CallbackERKN2v89ArgumentsE + 560 11 mongo 0x000000010d0feebd _ZN2v88internalL19HandleApiCallHelperILb0EEEPNS0_11MaybeObjectENS0_12_GLOBAL__N_116BuiltinArgumentsILNS0_21BuiltinExtraArgumentsE1EEEPNS0_7IsolateE + 1789 12 mongo 0x000000010d0ff26b _ZN2v88internalL26Builtin_Impl_HandleApiCallENS0_12_GLOBAL__N_116BuiltinArgumentsILNS0_21BuiltinExtraArgumentsE1EEEPNS0_7IsolateE + 43 13 mongo 0x000000010d0fbfc8 _ZN2v88internalL21Builtin_HandleApiCallENS0_12_GLOBAL__N_116BuiltinArgumentsILNS0_21BuiltinExtraArgumentsE1EEEPNS0_7IsolateE + 136 14 ??? 0x000003db1c106362 0x0 + 4239603557218