◐ Shell
reader mode source ↗
Skip to content

bpo-33015: Fix func cast warn in PyThread_start_new_thread()#10057

Closed
vstinner wants to merge 1 commit into
python:masterfrom
vstinner:func_cast
Closed

bpo-33015: Fix func cast warn in PyThread_start_new_thread()#10057
vstinner wants to merge 1 commit into
python:masterfrom
vstinner:func_cast

Conversation

@vstinner

@vstinner vstinner commented Oct 23, 2018

Copy link
Copy Markdown
Member

Fix a warning on a cast between two different function pointer types
in the pthread implementation of PyThread_start_new_thread().

Cast the function pointer temporarily to "void *" to mute the
warning. The overall cast changes the return type of the function
pointer: convert "void" return type (no return type) to "void*"
return type.

Python uses pthread_detach() and doesn't use pthread_join(), the
thread return value is ignored.

https://bugs.python.org/issue33015

Fix a warning on a cast between two different function pointer types
in the pthread implementation of PyThread_start_new_thread().

Cast the function pointer temporarily to "void *" to mute the
warning. The overall cast changes the return type of the function
pointer: convert "void" return type (no return type) to "void*"
return type.

Python uses pthread_detach() and doesn't use pthread_join(), the
thread return value is ignored.
@vstinner

Copy link
Copy Markdown
Member Author

Hum, first I pushed a big change with unrelated cleanup changes. I rewrote my PR to only fix the compiler warning. Once this change is merged, I will write a second PR to cleanup the code.

@vstinner vstinner requested a review from zooba October 23, 2018 12:35
@gpshead

gpshead commented Oct 24, 2018

Copy link
Copy Markdown
Member

The cast in this solution is still undefined behavior. Asking around with the C and C++ experts at work it was pointed out that the C99 spec covers this:

"A pointer to a function of one type may be converted to a pointer to a function of another type and back again; the result shall compare equal to the original pointer. If a converted pointer is used to call a function whose type is not compatible with the pointed-to type, the behavior is undefined." from http://c0x.coding-guidelines.com/6.3.2.3.html

@vstinner

Copy link
Copy Markdown
Member Author

Control Flow Integrity killed my PR :-)
https://bugs.python.org/issue33015#msg328325

@vstinner vstinner closed this Oct 29, 2018
@vstinner vstinner deleted the func_cast branch October 29, 2018 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants