[JAVA-4215] Closing a MongoClient twice with AutoEncryptionSettings causes double free and crash Created: 30/Jun/21  Updated: 28/Oct/23  Resolved: 07/Jul/21

Status: Closed
Project: Java Driver
Component/s: Client Side Encryption
Affects Version/s: None
Fix Version/s: 3.12.9, 4.3.0

Type: Bug Priority: Major - P3
Reporter: Spencer Brown Assignee: Ross Lawley
Resolution: Fixed Votes: 0
Labels: internal-user
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to MONGOCRYPT-322 Calling close multiple times causes a... Closed
Case:

 Description   

This issue is easily reproducible and I can supply a sample program on request. Triggering conditions are creating a MongoClient for CSFLE, adding AutoEncryptionSettings, connecting to some MongoDB and doing something (it does not need to actually involve any encryption), closing the MongoClient, then closing it again. The second close causes a double free exception, and depending on your environment, can cause a crash dump or heap corruption error.

If the MongoClient is not using AutoEncryption settings, you can close it twice with no ill effects.

Driver version is 4.2.3 (sync), mongodb-crypt version is 1.2.0.



 Comments   
Comment by Githook User [ 07/Jul/21 ]

Author:

{'name': 'Ross Lawley', 'email': 'ross.lawley@gmail.com', 'username': 'rozza'}

Message: Ensure MongoClient#close only actions on first call

Backport from: e069cfcbf91d59987de89129bc0c4c83e16b2d99

JAVA-4215
Branch: 3.12.x
https://github.com/mongodb/mongo-java-driver/commit/9a4cf5e7daf72b2c2273cec262ebc8dbeeed31db

Comment by Githook User [ 06/Jul/21 ]

Author:

{'name': 'Ross Lawley', 'email': 'ross.lawley@gmail.com', 'username': 'rozza'}

Message: Ensure MongoClient#close only actions on first call

JAVA-4215
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/e069cfcbf91d59987de89129bc0c4c83e16b2d99

Comment by Ross Lawley [ 02/Jul/21 ]

PR: https://github.com/mongodb/mongo-java-driver/pull/744

Generated at Thu Feb 08 09:01:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.