-
Notifications
You must be signed in to change notification settings - Fork 637
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
pngcp has a segfault #255
Comments
This crash may be related to the compiler. When I build pngcp with plain clang-8, the crash disappeared.
|
I agree with tianxiaogu. |
@jbowler FYI. I rejected the above-mentioned commit tangyaofang@3bfadc2 because it doesn't actually solve the problem. It merely moves it to a different place. I wonder if making all function arguments (and not just the last one) volatile will solve the problem. |
I don't know what was being run here because the "apt-cache" screenshot is for the pngtools package; the one with the real pngcp, not the libpng one. It looks like the test code has problems with longjmp/setjmp; as I said in #424 mixing C++ code with C code may or may not work... The test file works just plain fine with a regular build of pngcp:
"error(libpng)" means that pngerror was called, which is why the call stack in the original report is totally broken. It looks like the longjmp crashed, possibly it encountered a C++ unwind (at least in a recent GCC12 g++ build for #424 I saw that the latest version is apparently doing unwinds, which looks dangerous unless libpng is built with -fexceptions.) |
I suggest adding -fexceptions to all libpng builds with compilers that support this. This was the way I always built libpng anyway. It will change the default behavior on almost all builds. If you don't do this then people who try to throw in the callbacks are likely to suffer crashes or worse (though it is 15 years since I encountered these problems so maybe GCC has got better...) The GCC problem is that it reported a clobber on values that were unmodified; see the comments on the definition of "gv" in pngcp.c and ANSI-C (X3.159-1989) section 4.6.2.1, the second paragraph, lines 11-14 in the original ANSI standard. Also note that the compiler actually being used is not explicitly stated, but it looks like clang, not gcc. Also I suggest not accepting bugs like this; @tangyaofang was testing two COMPLETELY DIFFERENT programs. Any report on pngcp needs to be checked very carefully to make sure which pngcp it is; fortunately the output messages have a completely different format so I can tell from that. |
Is it a bug of glibc? Not sure whether it is important. The crash can be reproduced with the HEAD or the one in pngtools released in Ubuntu 18.04.
test-case.zip
The text was updated successfully, but these errors were encountered: