[CXX-849] Audit API usage of int32_t Created: 19/Feb/16  Updated: 08/Feb/23

Status: Backlog
Project: C++ Driver
Component/s: API
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Andrew Morrow (Inactive) Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CDRIVER-1329 maxTimeMS and maxAwaitTimeMS should b... Backlog
is related to CXX-1338 Capped size in bytes is limited to 32... Closed
Epic Link: CXX ABI
Quarter: FY24Q1

 Description   

We should review usages of int32_t in the API and ensure that they are correct. In particular, things like pipeline::skip or pipeline::sample. Another example is places where we are specifying a base fixed size integer for enumerations. Is this actually needed? Or should we let it default to int? Changing integer sizes is a common source of ABI breaks so we should make sure we are doing the right thing out of the gate.



 Comments   
Comment by David Golden [ 17/Jun/16 ]

Code review for std::chrono::duration checks: https://github.com/mongodb/mongo-cxx-driver/pull/500

Comment by David Golden [ 15/Jun/16 ]

I think for these we always take std::chrono, so we can just do a runtime check that the values fit in int32_t rather than an int64_t as I had been planning to do. Practically speaking, I doubt we'll see larger values in real-world code. If libmongoc changes and if we get user demand for astronomically high maxTimeMS values, then we can consider changing the runtime check.

Comment by Andrew Morrow (Inactive) [ 15/Jun/16 ]

We should probably correct our API and then deal with overflow at runtime internally at the site where we call the C driver. That way we don't leak this implementation flaw out to our consumers, and can eventually address it once the C driver updates ABI and we can depend on that version as our minimum. It might be tricky during the transition if we need to support both ABIs, but presumably we can interrogate the function for the size of its argument, either at configure time or via some clever template hackery.

Comment by David Golden [ 15/Jun/16 ]

libmongoc restricts maxTimeMS and maxAwaitTimeMS to int32_t in some places, whereas the spec calls for int64_t. (Filed as CDRIVER-1329)

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