[SERVER-66087] Call curl_global_init before threading enabled Created: 29/Apr/22  Updated: 29/Oct/23  Resolved: 11/May/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.4.15, 6.0.0-rc7, 5.0.10, 6.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Spencer Jackson Assignee: Gabriel Marks
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.0, v5.0, v4.4
Sprint: Security 2022-05-16
Participants:

 Description   

curl_global_init is not thread safe:

This function is not thread safe. You must not call it when any other thread in the program (i.e. a thread sharing the same memory) is running. This does not just mean no other thread that is using libcurl. Because curl_global_init calls functions of other libraries that are similarly thread unsafe, it could conflict with any other thread that uses these other libraries.

We call this method in CurlLibraryManager::_initializeGlobal, which we call in initialize which we call whenever we create a new handle.

We should create a MONGO_INITIALIZER to initialize curl before we spawn threads in the database.



 Comments   
Comment by Githook User [ 20/May/22 ]

Author:

{'name': 'Gabriel Marks', 'email': 'gabriel.marks@mongodb.com', 'username': 'marksg07'}

Message: SERVER-66087 Move curlLibraryManager.initialize() to global initializer
Branch: v6.0
https://github.com/mongodb/mongo/commit/9853be92a5f34ba722145a185c29542a02563f7b

Comment by Githook User [ 18/May/22 ]

Author:

{'name': 'Gabriel Marks', 'email': 'gabriel.marks@mongodb.com', 'username': 'marksg07'}

Message: SERVER-66087 Move curlLibraryManager.initialize() to global initializer
Branch: v5.0
https://github.com/mongodb/mongo/commit/cb646e5e67a35463371cc3e7b27d5b25c53d19f3

Comment by Githook User [ 18/May/22 ]

Author:

{'name': 'Gabriel Marks', 'email': 'gabriel.marks@mongodb.com', 'username': 'marksg07'}

Message: SERVER-66087 Move curlLibraryManager.initialize() to global initializer
Branch: v4.4
https://github.com/mongodb/mongo/commit/c94bb9c1fbc93b250ac3269e2e207d3b2aa2a1b7

Comment by Githook User [ 06/May/22 ]

Author:

{'name': 'Gabriel Marks', 'email': 'gabriel.marks@mongodb.com', 'username': 'marksg07'}

Message: SERVER-66087 Move curlLibraryManager.initialize() to global initializer
Branch: master
https://github.com/mongodb/mongo/commit/b08da7fbbcf6661ecb63a07b76dceb7a206240f9

Generated at Thu Feb 08 06:04:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.