Open gvanem opened 9 months ago
And adding -fno-sanitize=function
to the above CFLAGS
is off-course also OK; no crash.
Didn't manage to reproduce neither on local machine nor Godbolt. Maybe a Windows-specific issue somehow?
Maybe a Windows-specific issue somehow?
Perhaps. You (or someone else), should try it on Windows then?
In lack of a better name than "compact returns", it seems clang with UBSAN is sensitive to a syntax like
enum { a, b, c } func (args)
. Perfectly legal C-code. This little GNU-makefile with the flag-fsanitize=undefined
shows the problem:ubsan-crash.mak
``` # # A rewrite of libcurl's 'lib/content_encoding.c' for # the issue: # https://github.com/curl/curl/issues/12618 # CC = clang-cl CFLAGS = -nologo -fsanitize=undefined default: crash crash: ubsan_crash.c FORCE $(CC) -c $(CFLAGS) $< no_crash: ubsan_no_crash.c FORCE $(CC) -c $(CFLAGS) $< ubsan_crash.c: $(MAKEFILELISTS) $(info Generating $@) $(file > $@, $(ubsan_crash_c)) ubsan_no_crash.c: $(MAKEFILELISTS) $(info Generating $@) $(file > $@, $(ubsan_no_crash_c)) FORCE: ; clean: rm -f ubsan_crash.c ubsan_crash.obj \ ubsan_no_crash.c ubsan_no_crash.obj # # This is similar to this "crash-point" # https://github.com/curl/curl/blob/master/lib/content_encoding.c#L372 # # where it seems clang + UBSAN is sensitive to a syntax like # "enum { a, b, c } func (args)" # define ubsan_crash_c enum { GZIP_OK, GZIP_BAD, GZIP_UNDERFLOW } check_gzip_header (unsigned char const *data, size_t len, size_t *headerlen) { (void) data; (void) len; (void) headerlen; return (GZIP_OK); } endef # # A rewrite into a typedef'ed 'gzip_status' works fine. # define ubsan_no_crash_c typedef enum { GZIP_OK, GZIP_BAD, GZIP_UNDERFLOW } gzip_status; gzip_status check_gzip_header (unsigned char const *data, size_t len, size_t *headerlen) { (void) data; (void) len; (void) headerlen; return (GZIP_OK); } endef ```Running
make -f ubsan-crash.mak
, gives me:And running
make -f ubsan-crash.mak no_crash
is OK.Version-info:
clang-cl --version
:On Win-10, version 22H2 (OS-build 19045.3803).