[CDRIVER-3634] Windows thread handles are leaked Created: 25/Apr/20 Updated: 28/Oct/23 Resolved: 07/May/20 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 1.17.0-beta2, 1.17.0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Kevin Albertson | Assignee: | Kevin Albertson |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | platform-problems | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
The thread functions defined in common-thread-private.h give a platform agnostic thread and mutex API. On Windows, bson_thread_create wraps CreateThread. This creates a new thread handle. And bson_thread_join wraps WaitForSingleObject to wait on that thread handle, but it does not close the thread handle after waiting. The documentation for CreateThread states: > The thread object remains in the system until the thread has terminated and all handles to it have been closed through a call to CloseHandle. The leak can be observed this with a simple example program that just creates and destroys a mongoc_client_pool_t repeatedly (which creates one monitoring thread and joins it repeatedly). The example is attached as handle-leak.c. A screenshot of process explorer showing a large number of open handles is also attached. |
| Comments |
| Comment by Githook User [ 25/May/20 ] |
|
Author: {'name': 'Kevin Albertson', 'email': 'kevin.albertson@10gen.com', 'username': 'kevinAlbs'}Message: Use correct calling convention in thread functions. |
| Comment by Githook User [ 07/May/20 ] |
|
Author: {'name': 'Kevin Albertson', 'email': 'kevin.albertson@10gen.com', 'username': 'kevinAlbs'}Message: Use correct calling convention in thread functions. |