[CDRIVER-2123] Crash when destroying bson objects Created: 07/Apr/17  Updated: 27/Oct/23  Resolved: 07/Apr/17

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: 1.6.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Olivier Bertrand [X] Assignee: Hannes Magnusson
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 10 64 bit



 Description   

I am trying to use this driver in a multi-threading application. I am using client pool and make sure that using a cursor is always done in the same thread.

However, if the first use is always successful (each are begining by mongoc_init(); and treminated by mongoc_cleanup() following ones frequently crash, always when destroying something. It says something about heap corruption or writing past the heap limit.

I have been able to avoid this by providing my own memory functions and resetting the vtable.

Is there another way to avoid these problems?



 Comments   
Comment by Olivier Bertrand [X] [ 07/Apr/17 ]

That was it, thanks.

Comment by Hannes Magnusson [ 07/Apr/17 ]

Calling mongoc_init and especially mongoc_cleanup multiple times will definitely lead to all sorts of weirdness, including heap corruption.

Feel free to re-open this ticket if removing the extra calls does not fully resolve the problem.

Comment by Olivier Bertrand [X] [ 07/Apr/17 ]

No, they are called several times. I will try to change that and tell you.

Comment by Hannes Magnusson [ 07/Apr/17 ]

I don't suppose you have a minimal example that reproduce this issue?

Also, just to clarify. You only run mongoc_init() & mongoc_cleanup() at most once for the entire lifetime of the process right?
These functions should not be called by per thread.

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