Open Dylan-Brotherston opened 4 months ago
I'm having exactly the same problem, compiling with gcc and g++ in the following versions:
root@docker[x86_64-linux]:/gbsys-fw# gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root@docker[x86_64-linux]:/gbsys-fw# g++ --version
g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
When compiling, passing the flags:
set(CMAKE_C_COMPILER "/usr/bin/x86_64-linux-gnu-gcc")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -fsanitize=address -static-libasan -pthread" CACHE STRING "c flags")
set(CMAKE_CXX_COMPILER "/usr/bin/x86_64-linux-gnu-g++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -fsanitize=address -static-libasan -pthread" CACHE STRING "c++ flags")
And the execution of the application, which only executes a print with "Hello world!" returns segmentation fault, as shown below:
ycc@nitro:~/gbsys-fw$ ./output/x86_64-linux/bin/example-app
Hello, World!
ycc@nitro:~/gbsys-fw$ ./output/x86_64-linux/bin/example-app
Hello, World!
ycc@nitro:~/gbsys-fw$ ./output/x86_64-linux/bin/example-app
Segmentation fault (core dumped)
ycc@nitro:~/gbsys-fw$ ./output/x86_64-linux/bin/example-app
Hello, World!
If I remove the flag -fsanitize=address -static-libasan
the problem never occurs again.
I cannot reproduce the error with clang 17.0.6 as well as git-head.
Could you test with a never version?
The following code yield a valid program, and when compiled with clang, and gcc works as expected.
but when compiled with
-fsanitize=address
this code will randomly start givingSegmentation fault (core dumped)
errors.Note the same is true for
gcc -fsanitize=address