There are some places in the code where we use the toHex() routine to display a number in hexadecimal. This function doesn't do that; it displays a sequence of hexadecimal digits representing the contents of a memory location, in the order that they occur in memory. This means that on little-endian machines (i.e. all machines that MongoDB runs on in shipping branches) all of these values are byte-swapped relative to the actual value represented in hexadecimal.
Assertion: 10334:BSONObj size: -2 (0xFEFFFFFF) is invalid. Size must be between 0 and 16793600(16MB)
This should display as:
Assertion: 10334:BSONObj size: -2 (0xFFFFFFFE) is invalid. Size must be between 0 and 16793600(16MB)
We should add a function for converting values to hexadecimal display strings and call it instead of toHex() when displaying numeric values.