[SERVER-7324] Inappropriate use of toHex( &number, 4 ) to display value in hex Created: 11/Oct/12  Updated: 11/Jul/16  Resolved: 21/Aug/13

Status: Closed
Project: Core Server
Component/s: Logging, Usability
Affects Version/s: 2.0.7, 2.2.0
Fix Version/s: 2.5.2

Type: Bug Priority: Minor - P4
Reporter: Tad Marshall Assignee: Andrew Emil (Inactive)
Resolution: Done Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

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.



 Comments   
Comment by auto [ 30/May/13 ]

Author:

{u'username': u'tadmarshall', u'name': u'Tad Marshall', u'email': u'tad@10gen.com'}

Message: SERVER-7324 Visual Studio – add hex.cpp
Branch: master
https://github.com/mongodb/mongo/commit/15145c5b6a1db46e5246bcb2d63ae6ec3d28b3a5

Comment by auto [ 29/May/13 ]

Author:

{u'username': u'AndrewCEmil', u'name': u'AndrewCEmil', u'email': u'andrew.emil@10gen.com'}

Message: SERVER-7324 removed too-large number from previous commit
Branch: master
https://github.com/mongodb/mongo/commit/913fb476f8691b52c93b3f67e66b598fa02d927b

Comment by auto [ 29/May/13 ]

Author:

{u'username': u'AndrewCEmil', u'name': u'AndrewCEmil', u'email': u'andrew.emil@10gen.com'}

Message: SERVER-7324: added templated toHexTemp function to hex.h/hex.cpp
-replaced incorrect calls of toHex
-added test of integerToHex to stringutils_test.cpp
-changed building of bsondemo
-included hex.cpp to stringutils library package
Branch: master
https://github.com/mongodb/mongo/commit/135f0fb362efd4be85b422cf386cc26c2cd5d2d5

Generated at Thu Feb 08 03:14:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.