[CDRIVER-3635] Thread creation on Windows should use _beginthreadex 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: | Improvement | Priority: | Major - P3 |
| 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 | ||
| Description |
|
Currently, CreateThread is used as the primitive to create threads on Windows, defined here: https://github.com/mongodb/mongo-c-driver/blob/r1.17/src/common/common-thread-private.h#L58 My understanding is that _beginthreadex is a wrapper around CreateThread to ensure it is safe to use the C runtime. The documentation for CreateThread states:
This is additionally stated in https://docs.microsoft.com/en-us/windows/win32/procthread/creating-threads
Though docs for the CRT library state: "All versions of the CRT support multi-threaded development", so I believe on Windows 10, where we are linking against the Universal CRT shipped with Windows, this may not be an observable issue. Other evidence:
As an aside, we're using the wrong function signature for CreateThread anyway. Our thread functions have the pthread signature:
CreateThread expects the thread function to match the signature:
So that slightly worries me. If we need to fix this anyway, we'd might as well use the recommended thread creation function. |
| Comments |
| Comment by Githook User [ 25/May/20 ] |
|
Author: {'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}Message: |
| 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@mongodb.com', 'username': 'kevinAlbs'}Message: |
| 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. |