-
Notifications
You must be signed in to change notification settings - Fork 134
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
Undefined behavior in wuffs-v0.4.c #152
Comments
I can work around the issue by this: #pragma clang attribute push (__attribute__((no_sanitize("undefined"))), apply_to=function)
#include "wuffs-v0.4.c"
#pragma clang attribute pop but I think this is less than ideal. |
Can you share the ubsan-using command line that triggers this? |
While investigating another issue - gabime/spdlog#3145 - I run Microsoft Visual C++ Redistributable repair, and after that, I can no longer reproduce this undefined behavior. This suggests the issue was in somehow caused by old or broken Microsoft Visual C++ Redistributable. I wish Microsoft would have added some sort of version check when they did breaking change (microsoft/STL#4730). |
OK, not reproducible. Still, you mentioned "Microsoft Visual C++ Redistributable" but also |
And, in case this gets re-opened later, I am unable to reproduce any ubsan warnings. With this patch: $ git diff
diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c
index 1a197f73..9b7019d0 100644
--- a/release/c/wuffs-unsupported-snapshot.c
+++ b/release/c/wuffs-unsupported-snapshot.c
@@ -1,6 +1,9 @@
#ifndef WUFFS_INCLUDE_GUARD
#define WUFFS_INCLUDE_GUARD
+#include <stdio.h>
+int trigger_ubsan = 0x7fffffff;
+
// Wuffs ships as a "single file C library" or "header file library" as per
// https://github.com/nothings/stb/blob/master/docs/stb_howto.txt
//
@@ -17181,6 +17184,7 @@ wuffs_base__image_decoder__decode_frame_config(
wuffs_base__image_decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src) {
+fprintf(stderr, "wuffs_base__image_decoder__decode_frame_config\n");
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
@@ -64136,6 +64140,8 @@ wuffs_png__decoder__decode_frame_config(
wuffs_png__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src) {
+fprintf(stderr, "wuffs_png__decoder__decode_frame_config\n");
+if (trigger_ubsan++ == 123456) { fprintf(stderr, "undefined behavior! (int overflow)\n"); }
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
} I get this output:
So, ubsan is triggering, but if I take out the |
I was compiling in msys2 clang64 environment using clang:
AFAIK, msvc does not support ubsan currently. |
This could be somehow my own bad, as I've just started testing wuffs, but I decided to report this anyway:
When I run my code with ubsan, I get this kind of reports:
The text was updated successfully, but these errors were encountered: