-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
bpo-30766: Make CHECK_STATUS_PTHREAD signal-safe. #2404
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
Changes from all commits
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Make CHECK_STATUS_PTHREAD signal-safe |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,9 +142,19 @@ typedef struct { | |
pthread_mutex_t mut; | ||
} pthread_lock; | ||
|
||
#define PUTS(fd, str) _Py_write_noraise(fd, str, (int)strlen(str)) | ||
|
||
#define CHECK_STATUS(name) if (status != 0) { perror(name); error = 1; } | ||
#define CHECK_STATUS_PTHREAD(name) if (status != 0) { fprintf(stderr, \ | ||
"%s: %s\n", name, strerror(status)); error = 1; } | ||
/* CHECK_STATUS_PTHREAD is async-signal-safe */ | ||
#define CHECK_STATUS_PTHREAD(name) \ | ||
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. I never understood the purpose of these functions. Do we really need these checks? Why not replacing them with an assertion? If you want to get them at runtime, maybe call Py_FatalError()? 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. I don't know. I'm inclined not to remove them right now. 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.
Oh no, please finish your work. I like the idea of more reliable locks :-) |
||
if (status != 0) { \ | ||
int _stderr_fd = 2; \ | ||
PUTS(_stderr_fd, name); \ | ||
PUTS(_stderr_fd, ": failed with status "); \ | ||
_Py_DumpDecimal(_stderr_fd, (unsigned long) status); \ | ||
PUTS(_stderr_fd, "\n"); \ | ||
error = 1; \ | ||
} | ||
|
||
/* | ||
* Initialization. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why casting strlen() to int?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, I copied this macro from
traceback.c
.