https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119314
--- Comment #13 from Novel <root at hsnovel dot net> --- (In reply to Andrew Pinski from comment #3) > Before `DEBUG_LOG_INFO("2 Data %p\n", dest.Data);` > is there any calls before hand? Like say to memcpy? or anything that might > have the nonnull attribute on it and uses dest.Data? > > Note memcpy before C23 was undefined (even if the length was 0) to pass a > null pointer to it. > > Does -fno-delete-null-pointer-checks if the issue you are running into? If > so there is most likely a what I described, `-fsanitize=undefined` should > catch that at runtime. It seems like what Andrew Pinski suggested at the beggining was indeed true. It was LUT_UpdateStringWithJString that had a memcpy deep inside a callstack. I didn't see it at first because the function did branch into so many different code paths that it was couple of layers down the call stack. I have no idea why the sanitizer or valgrind didn't catch it, maybe they don't work well when they run under JNI, I don't know. So for -fno-delete-null-pointer-checks, it seems like I was a complete idiot and pasted that to the wrong place. Sorry for wasting everyone's time. And thanks for the help.