[issue33015] Fix function cast warning in thread_pthread.h

2018-11-30 Thread STINNER Victor
STINNER Victor added the comment: > I don't think it is crazy for 2.7, but I'd move that to its own issue as you > already nicely addressed the problem related to this PR without needing that. Good idea. I created bpo-35368. I close this issue since it's now fixed. -- resolution:

[issue33015] Fix function cast warning in thread_pthread.h

2018-11-30 Thread Gregory P. Smith
Gregory P. Smith added the comment: I don't think it is crazy for 2.7, but I'd move that to its own issue as you already nicely addressed the problem related to this PR without needing that. -- ___ Python tracker

[issue33015] Fix function cast warning in thread_pthread.h

2018-11-30 Thread STINNER Victor
STINNER Victor added the comment: > why was that only an issue on 2.7? I added PyMem_RawMalloc() to Python 3.4 and this function must be thread-safe. https://docs.python.org/dev/c-api/memory.html#raw-memory-interface "These functions are thread-safe, the GIL does not need to be held." I

[issue33015] Fix function cast warning in thread_pthread.h

2018-11-30 Thread Gregory P. Smith
Gregory P. Smith added the comment: why was that only an issue on 2.7? -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue33015] Fix function cast warning in thread_pthread.h

2018-11-30 Thread STINNER Victor
STINNER Victor added the comment: New changeset bc9f53f69e8207027bf2b18e3d01b30401e76ace by Victor Stinner in branch '2.7': bpo-33015: Use malloc() in PyThread_start_new_thread() (GH-10829) https://github.com/python/cpython/commit/bc9f53f69e8207027bf2b18e3d01b30401e76ace --

[issue33015] Fix function cast warning in thread_pthread.h

2018-11-30 Thread STINNER Victor
STINNER Victor added the comment: I wrote PR 10828 to make PyMem_Malloc() thread-safe in debug mode as well.. But I'm not sure that it's ok to push such change later in the 2.7 development cycle... So I wrote PR 10829 which only modified PyThread_start_new_thread(): use malloc/free instead

[issue33015] Fix function cast warning in thread_pthread.h

2018-11-30 Thread STINNER Victor
STINNER Victor added the comment: Oh... test_threaded_import started to crash on Python 2.7: $ ./python -m test -F -v test_threaded_import (...) 0:00:00 load avg: 1.06 [ 3] test_threaded_import Trying 20 threads ... OK. Trying 50 threads ... OK. Trying 20 threads ... OK. Segmentation fault

[issue33015] Fix function cast warning in thread_pthread.h

2018-11-30 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +10069 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue33015] Fix function cast warning in thread_pthread.h

2018-11-30 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +10068 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue33015] Fix function cast warning in thread_pthread.h

2018-11-30 Thread STINNER Victor
STINNER Victor added the comment: Ok, the bug should now be fixed. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue33015] Fix function cast warning in thread_pthread.h

2018-11-30 Thread STINNER Victor
STINNER Victor added the comment: New changeset 03b1200dfd03061e9ad0bff8199967bd80b9b900 by Victor Stinner in branch '3.6': bpo-33015: Fix UB in pthread PyThread_start_new_thread (GH-6008) (GH-10822) https://github.com/python/cpython/commit/03b1200dfd03061e9ad0bff8199967bd80b9b900

[issue33015] Fix function cast warning in thread_pthread.h

2018-11-30 Thread STINNER Victor
STINNER Victor added the comment: New changeset 8f83c2fb19c45350c2161d9e75dab4cd2bcaee28 by Victor Stinner in branch '2.7': bpo-33015: Fix UB in pthread PyThread_start_new_thread (GH-6008) (GH-10823) https://github.com/python/cpython/commit/8f83c2fb19c45350c2161d9e75dab4cd2bcaee28

[issue33015] Fix function cast warning in thread_pthread.h

2018-11-30 Thread miss-islington
miss-islington added the comment: New changeset b1355352d14a0a67107aba7ec6f26f17716a by Miss Islington (bot) in branch '3.7': bpo-33015: Fix UB in pthread PyThread_start_new_thread (GH-6008) https://github.com/python/cpython/commit/b1355352d14a0a67107aba7ec6f26f17716a --

[issue33015] Fix function cast warning in thread_pthread.h

2018-11-30 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +10066 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue33015] Fix function cast warning in thread_pthread.h

2018-11-30 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +10065 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue33015] Fix function cast warning in thread_pthread.h

2018-11-30 Thread miss-islington
Change by miss-islington : -- pull_requests: +10064 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue33015] Fix function cast warning in thread_pthread.h

2018-11-30 Thread STINNER Victor
STINNER Victor added the comment: New changeset 9eea6eaf23067880f4af3a130e3f67c9812e2f30 by Victor Stinner (Siddhesh Poyarekar) in branch 'master': bpo-33015: Fix UB in pthread PyThread_start_new_thread (GH-6008)

[issue33015] Fix function cast warning in thread_pthread.h

2018-10-29 Thread STINNER Victor
STINNER Victor added the comment: I closed my PR 10057: "Control Flow Integrity killed my PR :-) https://bugs.python.org/issue33015#msg328325 " -- ___ Python tracker ___

[issue33015] Fix function cast warning in thread_pthread.h

2018-10-25 Thread STINNER Victor
STINNER Victor added the comment: "Shall we introduce a new thread-starting API that takes a function with the "correct" pthread signature?" Extract of my PR: "Python uses pthread_detach() and doesn't use pthread_join(), the thread return value is ignored." Python doesn't give access to

[issue33015] Fix function cast warning in thread_pthread.h

2018-10-25 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Shall we introduce a new thread-starting API that takes a function with the > "correct" pthread signature? Do we need it? I don't think saving a single memory allocation is worth the bother. -- ___ Python

[issue33015] Fix function cast warning in thread_pthread.h

2018-10-24 Thread Benjamin Peterson
Benjamin Peterson added the comment: Shall we introduce a new thread-starting API that takes a function with the "correct" pthread signature? It seems like Windows already allocates. -- ___ Python tracker

[issue33015] Fix function cast warning in thread_pthread.h

2018-10-24 Thread Gregory P. Smith
Gregory P. Smith added the comment: This is presumably also present in 3.6 and 2.7 so I've tagged those on the issue, but for this kind of change i'd leave it up to release managers to see if they want to backport something of this nature that late in those release cycles. Observable side

[issue33015] Fix function cast warning in thread_pthread.h

2018-10-24 Thread Gregory P. Smith
Gregory P. Smith added the comment: I left comments on the github PRs with reasons why, but PR 6008 seems correct. PR 10057 would leave us with undefined behavior. -- ___ Python tracker

[issue33015] Fix function cast warning in thread_pthread.h

2018-10-23 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- nosy: +serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue33015] Fix function cast warning in thread_pthread.h

2018-10-23 Thread Alexey Izbyshev
Alexey Izbyshev added the comment: Such casts will also trigger a CFI violation if somebody tries to build Python (and the libc, in this case) with a signature-based CFI [1, 2]. It checks that the compile-time callee signature matches the signature of the actually called function in

[issue33015] Fix function cast warning in thread_pthread.h

2018-10-23 Thread Steve Dower
Steve Dower added the comment: Unfortunately, this isn't really a safe cast, as we're going from void to non-void return value. On x86 with current calling conventions, this is okay, since the return value is in a register that does not change or require cleanup by the caller. However, I

[issue33015] Fix function cast warning in thread_pthread.h

2018-10-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: Right, so one PR is a real fix, the other PR is a workaround (avoids the warning without fixing the underlying problem). The underlying problem is: if a platform has incompatible ABIs for the two function types, casting one function type to another may

[issue33015] Fix function cast warning in thread_pthread.h

2018-10-23 Thread STINNER Victor
STINNER Victor added the comment: I wrote a different fix for the compiler warning using a temporary cast to "void*": PR 10057. -- ___ Python tracker ___

[issue33015] Fix function cast warning in thread_pthread.h

2018-10-23 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +9394 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue33015] Fix function cast warning in thread_pthread.h

2018-10-23 Thread STINNER Victor
STINNER Victor added the comment: The GCC warning is: func_cast.c:34:30: warning: cast between incompatible function types from 'python_callback' {aka 'void (*)(void *)'} to 'void * (*)(void *)' [-Wcast-function-type] pthread_callback func2 = (pthread_callback)func;

[issue33015] Fix function cast warning in thread_pthread.h

2018-10-23 Thread STINNER Victor
STINNER Victor added the comment: func_cast.c: C program reproducing the issue. Using an additional (void*) cast, it's possible to workaround the cast warning. /* Test GCC 8.1 -Wcast-function-type for https://bugs.python.org/issue33015 * * Compiled on Linux with: * gcc x.c -o x -Wall

[issue33015] Fix function cast warning in thread_pthread.h

2018-10-23 Thread STINNER Victor
STINNER Victor added the comment: "Fix function cast warning in thread_pthread.h" Can you please paste the warning? -- ___ Python tracker ___

[issue33015] Fix function cast warning in thread_pthread.h

2018-10-23 Thread STINNER Victor
STINNER Victor added the comment: > gcc8.1 throws this warning irrespective of the cast since converting function > pointers may result in undefined behaviour unless it is cast back to its > original type. Do you have a reference explaining this issue? I dislike adding a memory allocation

[issue33015] Fix function cast warning in thread_pthread.h

2018-05-15 Thread Steve Dower
Steve Dower added the comment: Ah okay, fair enough. Knowing that, I'll take another look at the PR. I'd really like to simplify this as much as possible to avoid risk of regression. -- ___ Python tracker

[issue33015] Fix function cast warning in thread_pthread.h

2018-05-15 Thread Siddhesh Poyarekar
Siddhesh Poyarekar added the comment: Actually it is not; the parameter passed to Pythread_start_new_thread has a different type (void (*)(void *)) from what's accepted (and executed by) pthread_create (void *(*)(void *)). That is undefined behaviour.

[issue33015] Fix function cast warning in thread_pthread.h

2018-05-11 Thread Steve Dower
Steve Dower added the comment: In this case, we know the behaviour is okay and the warning is wrong. We should suppress the warning around the offending line, rather than adding significant code that may introduce genuine bugs. --

[issue33015] Fix function cast warning in thread_pthread.h

2018-05-10 Thread Siddhesh Poyarekar
Siddhesh Poyarekar added the comment: gcc8.1 throws this warning irrespective of the cast since converting function pointers may result in undefined behaviour unless it is cast back to its original type. -- ___ Python

[issue33015] Fix function cast warning in thread_pthread.h

2018-05-09 Thread Steve Dower
Steve Dower added the comment: Can't we just fix the cast? We shouldn't have to do heap allocations for this. -- nosy: +steve.dower ___ Python tracker

[issue33015] Fix function cast warning in thread_pthread.h

2018-04-22 Thread Ned Deily
Change by Ned Deily : -- nosy: +benjamin.peterson ___ Python tracker ___ ___

[issue33015] Fix function cast warning in thread_pthread.h

2018-03-10 Thread Brett Cannon
Change by Brett Cannon : -- nosy: -brett.cannon ___ Python tracker ___ ___

[issue33015] Fix function cast warning in thread_pthread.h

2018-03-09 Thread Terry J. Reedy
Change by Terry J. Reedy : -- nosy: +brett.cannon, pitrou ___ Python tracker ___ ___

[issue33015] Fix function cast warning in thread_pthread.h

2018-03-06 Thread Siddhesh Poyarekar
Change by Siddhesh Poyarekar : -- keywords: +patch pull_requests: +5773 stage: -> patch review ___ Python tracker ___

[issue33015] Fix function cast warning in thread_pthread.h

2018-03-06 Thread Siddhesh Poyarekar
New submission from Siddhesh Poyarekar : The PyThread_start_new_thread function takes a void (*)(void *) as the function argument, which does not match with the pthread_create callback which has type void *(*)(void *). I've got a fix for this that adds a wrapper