[CDRIVER-4662] Possible overflow parsing Decimal128 in extJSON with very large exponents Created: 15/Jun/23  Updated: 28/Oct/23  Resolved: 24/Jul/23

Status: Closed
Project: C Driver
Component/s: Extended JSON, libbson
Affects Version/s: None
Fix Version/s: 1.24.3

Type: Bug Priority: Minor - P4
Reporter: Jeremy Mikola Assignee: Josh Siegel (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to PHPC-2259 Sync BSON corpus tests for Decimal128... Closed
is related to DRIVERS-2651 Add decimal128 clamped zeros tests wi... Closed

 Description   

DRIVER-2651 recently added new BSON corpus tests for Decimal128 where the degenerate_extjson representation uses very large exponent values.

POC-ing these tests with PHPC resulted in several failures converting the degenerate extJSON to Canonical BSON. The code path in PHPC's test runner directly utilizes libbson's bson_new_from_json() function.

The spec tests and details of the PHPC failures can be found in mongodb/specifications#1432. matt.dale@mongodb.com's assessment from this #dbx-devs thread is as follows:

As far as the failures, the ones that failed with

-180000001364000000000000000000000000000000fe5f00
+180000001364000000000000000000000000000000000000

were expecting 0E+6111 but got 0E-6176.

The ones that failed with

-180000001364000000000000000000000000000000008000
+180000001364000000000000000000000000000000fedf00

were expecting 0E-6176 but got 0E+6111.

Seems like it could be some kind of exponent overflow/underflow problem.



 Comments   
Comment by Githook User [ 24/Jul/23 ]

Author:

{'name': 'Joshua Siegel', 'email': '39130209+joshbsiegel@users.noreply.github.com', 'username': 'joshbsiegel'}

Message: CDRIVER-4662 check for decimal128 exponent overflow (#1349)
Branch: r1.24
https://github.com/mongodb/mongo-c-driver/commit/e50a625211fcfcfd408ac8d315dc4e67e913524c

Comment by Githook User [ 24/Jul/23 ]

Author:

{'name': 'Joshua Siegel', 'email': '39130209+joshbsiegel@users.noreply.github.com', 'username': 'joshbsiegel'}

Message: CDRIVER-4662 check for decimal128 exponent overflow (#1349)
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/c3587f1dd4201b636107e82985d934d0f5e3e43b

Comment by Jeremy Mikola [ 13/Jul/23 ]

When I originally reported this issue, the corpus tests were using "999999999999" as an exponent. Looking at what was ultimately merged in mongodb/specificatiosn@c09f979, the corpus tests now use "2147483647". I can confirm that the current tests pass in PHPC.

I've left a comment on the original PR in mongodb/specifications#1432.

I'll defer to you to decide if the original tests with "999999999999" should have passed, as matt.dale@mongodb.com did suggest it was an overflow/underflow error.

Comment by Josh Siegel (Inactive) [ 13/Jul/23 ]

Hi jmikola@mongodb.com - we tried both running the spec tests here and writing some of our own tests here and were unable to reproduce the error in the C Driver. Is there anything additional that you are doing in the PHPC test runner?

Generated at Wed Feb 07 21:21:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.