| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
🤖 New build scheduled with the buildbot fleet by @ZeroIntensity for commit dc39d9a 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F132800%2Fmerge If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
Sorry, something went wrong.
There was a problem hiding this comment.
Did you forget fclose(). I think that you need also dup().
Sorry, something went wrong.
|
Should be fixed now. |
Sorry, something went wrong.
| int res = vfprintf(handle, fmt, vargs); | ||
| va_end(vargs); | ||
| fclose(handle); | ||
| close(newfd); |
There was a problem hiding this comment.
You don't need close() here, because fclose() closes the file descriptor.
Sorry, something went wrong.
There was a problem hiding this comment.
Sorry, I'm not used to going between FILE * and int like this. Fixed it.
Sorry, something went wrong.
|
I'm not sure what to do about WASM lacking dup. |
Sorry, something went wrong.
There was a problem hiding this comment.
close() is still used when fopen() fails.
On WASM, an alternative implementation can use vsnpritf() and a fixed-size buffer. Does WASM even support access to a call stack?
Also, some platforms can use dprintf() directly, instead of a fallback.
Sorry, something went wrong.
That's intentional. fdopen() doesn't close the file descriptor on failure, does it? I'd like to lean away from dprintf, because apparently, it comes with its own set of problems. There are some POSIX implementations that don't implement it correctly, and I don't think it's worth adding something like a _POSIX_SOURCE guard here |
Sorry, something went wrong.
|
I meant that removing the define was premature if the define was needed. But there is no compiling error, so it may be unneeded. |
Sorry, something went wrong.
|
It's a deprecated alias on Windows, but I don't think they'll go removing it anytime soon. I'll add it back for completeness. |
Sorry, something went wrong.
|
It looks like there is a _Py_dup function that we can use for WASI, but it's not heap-safe when exceptions occur. Signal handlers in faulthandler can't use the heap, so any of the PyErr calls are unsafe. I guess we could add an internal-only _PyErr_SetFromErrnoHeapsafe that only raises when we're not in a signal handler. |
Sorry, something went wrong.
|
@vstinner, do we need to use _Py_dup() instead of dup() in this case? |
Sorry, something went wrong.
|
_Py_dup() is more complicated to ensure that the file descriptor is non-inheritable. I don't think that it's useful here. |
Sorry, something went wrong.
| || info[i].dli_fname[0] == '\0' | ||
| ) { | ||
| dprintf(fd, " Binary file '<unknown>' [%p]\n", array[i]); | ||
| _Py_fdprintf(fd, " Binary file '<unknown>' [%p]\n", array[i]); |
There was a problem hiding this comment.
It would be safer to not use printf family but use traceback.c functions to write directly into the fd.
Sorry, something went wrong.
There was a problem hiding this comment.
Yeah, but then we have to deal with stack limits. I'll probably end up using those regardless, though.
Sorry, something went wrong.
There was a problem hiding this comment.
I wrote #132854 to replace dprintf() with _Py_write_noraise().
Sorry, something went wrong.
There was a problem hiding this comment.
Yeah, but then we have to deal with stack limits
Which stack limits? traceback.c code is designed to use little stack memory and be async-signal safe.
Sorry, something went wrong.
There was a problem hiding this comment.
I was thinking of a sprintf that would be incrementally printed. Your solution works a lot better.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
I thought it wasn't possible for a system to have glibc's backtrace() but not glibc's dprintf(). Apparently, I was wrong.
This uses fdopen()/vfprintf() instead, which should be portable across anything POSIX, and even Windows.