-
-
Notifications
You must be signed in to change notification settings - Fork 29
fix compatible issues in python 3.14 #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 21 commits
5f35844
6153369
1389e13
19c9434
546217f
0f15195
68b7713
c298389
7dd96f1
b128872
1c1bcfd
e119a0c
33533c5
385d66c
cf49a75
7c92255
8f32f8b
ba28e30
d6bc361
7af95ed
b5d71e9
105ff80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# cython: freethreading_compatible = True | ||
""" | ||
Fine-grained alarm function | ||
""" | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -120,7 +120,7 @@ static void setup_cysignals_handlers(void); | |||||
static void cysigs_interrupt_handler(int sig); | ||||||
static void cysigs_signal_handler(int sig); | ||||||
|
||||||
static void do_raise_exception(int sig); | ||||||
static void _do_raise_exception(int sig); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. _do_raise_exception is declared static here, but it is invoked from macros.h's inline _sig_on_postjmp, which is compiled into other translation units. With static linkage, other TUs cannot resolve this symbol, causing link errors. Remove static (make it have external linkage) and provide a prototype in a shared header (e.g., macros.h) so all TUs see the declaration.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
static void sigdie(int sig, const char* s); | ||||||
|
||||||
#define BACKTRACELEN 1024 | ||||||
|
@@ -392,11 +392,10 @@ static void cysigs_interrupt_handler(int sig) | |||||
{ | ||||||
if (!cysigs.block_sigint && !custom_signal_is_blocked()) | ||||||
{ | ||||||
/* Raise an exception so Python can see it */ | ||||||
do_raise_exception(sig); | ||||||
|
||||||
/* Jump back to sig_on() (the first one if there is a stack). | ||||||
* The signal number is encoded in the return value of sigsetjmp. | ||||||
* Do NOT call Python code from signal handler! */ | ||||||
#if !_WIN32 | ||||||
/* Jump back to sig_on() (the first one if there is a stack) */ | ||||||
siglongjmp(trampoline, sig); | ||||||
#endif | ||||||
} | ||||||
|
@@ -449,10 +448,10 @@ static void cysigs_signal_handler(int sig) | |||||
} | ||||||
#endif | ||||||
|
||||||
/* Raise an exception so Python can see it */ | ||||||
do_raise_exception(sig); | ||||||
/* Jump back to sig_on() (the first one if there is a stack). | ||||||
* The signal number is encoded in the return value of sigsetjmp. | ||||||
* Do NOT call Python code from signal handler! */ | ||||||
#if !_WIN32 | ||||||
/* Jump back to sig_on() (the first one if there is a stack) */ | ||||||
siglongjmp(trampoline, sig); | ||||||
#endif | ||||||
} | ||||||
|
@@ -554,15 +553,15 @@ static void setup_trampoline(void) | |||||
|
||||||
|
||||||
/* This calls sig_raise_exception() to actually raise the exception. */ | ||||||
static void do_raise_exception(int sig) | ||||||
static void _do_raise_exception(int sig) | ||||||
{ | ||||||
#if ENABLE_DEBUG_CYSIGNALS | ||||||
struct timespec raisetime; | ||||||
if (cysigs.debug_level >= 2) { | ||||||
get_monotonic_time(&raisetime); | ||||||
long delta_ms = (raisetime.tv_sec - sigtime.tv_sec)*1000L + (raisetime.tv_nsec - sigtime.tv_nsec)/1000000L; | ||||||
PyGILState_STATE gilstate = PyGILState_Ensure(); | ||||||
print_stderr("do_raise_exception(sig="); | ||||||
print_stderr("_do_raise_exception(sig="); | ||||||
print_stderr_long(sig); | ||||||
print_stderr(")\nPyErr_Occurred() = "); | ||||||
print_stderr_ptr(PyErr_Occurred()); | ||||||
|
@@ -588,7 +587,7 @@ static void _sig_on_interrupt_received(void) | |||||
sigprocmask(SIG_BLOCK, &sigmask_with_sigint, &oldset); | ||||||
#endif | ||||||
|
||||||
do_raise_exception(cysigs.interrupt_received); | ||||||
_do_raise_exception(cysigs.interrupt_received); | ||||||
cysigs.sig_on_count = 0; | ||||||
cysigs.interrupt_received = 0; | ||||||
custom_set_pending_signal(0); | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -143,12 +143,22 @@ static inline int _sig_on_prejmp(const char* message, CYTHON_UNUSED const char* | |||||
/* | ||||||
* Process the return value of cysetjmp(). | ||||||
* Return 0 if there was an exception, 1 otherwise. | ||||||
* | ||||||
* This function propagates the signal number naturally via jmpret | ||||||
* (the return value from sigsetjmp/cylongjmp), which is always nonzero | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct 'cylongjmp' to 'siglongjmp'.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
* when a signal occurs. This avoids using global state and eliminates | ||||||
* potential desynchronization between the jump return value and any | ||||||
* stored signal number. | ||||||
*/ | ||||||
static inline int _sig_on_postjmp(int jmpret) | ||||||
{ | ||||||
if (unlikely(jmpret > 0)) | ||||||
{ | ||||||
/* An exception occurred */ | ||||||
/* A signal occurred and we jumped back via longjmp. | ||||||
* jmpret contains the signal number that was passed to siglongjmp. | ||||||
* Now we're back in a safe context (not in signal handler), | ||||||
* so it's safe to call Python code to raise the exception. */ | ||||||
_do_raise_exception(jmpret); | ||||||
Comment on lines
+157
to
+161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This inline function calls _do_raise_exception but there's no C declaration visible in this header. Without an extern prototype, this will be an implicit declaration (or an error under modern compilers). Add an extern prototype for _do_raise_exception(int) in a header included by all consumers (e.g., declare it at the top of macros.h) and ensure the function has external linkage. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
_sig_on_recover(); | ||||||
return 0; | ||||||
} | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.