Skip to content

How do I configure with ASAN? #22588

@jkeenan

Description

@jkeenan

More than once, I have had to ask, "How do I invoke ./Configure so as to build with ASAN?" (Most recently: #22586 (comment)) But I never seem to succeed. Can we straighten this out so that more people can explore address sanitizers?

My environment:

$ uname -mrs
Linux 6.8.0-40-generic x86_64

$ clang --version
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ 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.

$ git describe
v5.41.3

My most recent attempt (from #22586 (comment)):

$ git clean -dfx; sh ./Configure -des -Dusedevel -Accflags=-fsanitize=address -Aldflags=-fsanitize=address -Dcc=clang
...

./Configure gets almost all the way through, then segfaults:

...
Run make depend now? [y]  
clang -c -DPERL_CORE -fsanitize=address -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -Wall generate_uudmap.c
clang -o generate_uudmap -fsanitize=address -fstack-protector-strong -L/usr/local/lib generate_uudmap.o -lpthread -ldl -lm -lcrypt -lutil -lc 
./generate_uudmap uudmap.h bitcount.h mg_data.h
make: *** [Makefile:346: bitcount.h] Segmentation fault (core dumped)
...

I should note in passing that it feels awkward to me to delay calling -Dcc=clang until after I've called -Accflags and -Aldflags. But when I put -Dcc=clang where it feels more natural, ./Configure quickly collapses:

$ git clean -dfx; sh ./Configure -des -Dusedevel -Dcc=clang -Accflags=-fsanitize=address -Aldflags=-fsanitize=address
...
Let me guess what the preprocessor flags are...
Any additional ld flags (NOT including libraries)?
[ -fsanitize=address -fstack-protector-strong -L/usr/local/lib]  
Checking your choice of C compiler and flags for coherency...

I've tried to compile and run the following simple program:

#include <stdio.h>
int main() { printf("Ok\n"); return(0); }

I used the command:

	clang -o try -O2 -fsanitize=address -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -fsanitize=address -fstack-protector-strong -L/usr/local/lib try.c -lpthread -ldl -lm -lcrypt -lutil -lc
	 ./try

and I got the following output:

Segmentation fault (core dumped)
The program compiled OK, but exited with status 139.
You have a problem.  Shall I abort Configure [y]  
Ok.  Stopping Configure.

Next, let's try the above only with gcc instead of clang:

$ git clean -dfx; sh ./Configure -des -Dusedevel -Dcc=gcc -Accflags=-fsanitize=address -Aldflags=-fsanitize=address
...
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
...
^C

I get what appears to be an infinite loop of those DEADLYSIGNALs.

And finally, putting gcc at the end of the invocation:

$ git clean -dfx; sh ./Configure -des -Dusedevel -Accflags=-fsanitize=address -Aldflags=-fsanitize=address -Dcc=gcc
...
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
...
^C

I have a vague recollection that in the past I was able to complete ./Configure only to have my machine grind to a halt during make. But now I can't even get through ./Configure!

Guidance requested.

Metadata

Metadata

Assignees

Labels

Closable?We might be able to close this ticket, but we need to check with the reporter

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions