ramosian-glider / sanitizers

0 stars 0 forks source link

Error references nonexistent SHT_SYMTAB_SHNDX with -fsanitize=undefined #158

Closed ramosian-glider closed 9 years ago

ramosian-glider commented 9 years ago

Originally reported on Google Code with ID 157

What steps will reproduce the problem?

1. Compile a C file using Asan and with "-fsanitize=undefined"

I've got a C file that contains mostly MACROs that get expanded to functions.
And whenever I try to compile it using asan it finishes, and gives me the error above
when I try to use it (with 'nm' or for linking)

Also the compile time goes from ~45seconds without Asan to something like ~7-8minutes
with Asan.

  Main flags used for compilation :
   -fno-common -fsanitize=undefined -fsanitize=address-full -fno-omit-frame-pointer
-fno-optimize-sibling-calls

What is the expected output? What do you see instead?

Expected a working object file. Instead when using 'nm' I got :

BFD: myfile.o symbol number 65315 references nonexistent SHT_SYMTAB_SHNDX section

$ file myfile.o
myfile.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (GNU/Linux), stripped

What version of the product are you using? On what operating system?

$ uname -a
Linux linux 2.6.32-5-amd64 #1 SMP Wed Jan 12 03:40:32 UTC 2011 x86_64 GNU/Linux

$ clang --version
clang version 3.3 (trunk 174701)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Reported by mkvtoolnix.build.jonthn on 2013-02-08 09:46:08

ramosian-glider commented 9 years ago
repro? 

Reported by konstantin.s.serebryany on 2013-02-08 10:09:58

ramosian-glider commented 9 years ago
I'm in the process of making one. I will update this issue when I have one.

Reported by mkvtoolnix.build.jonthn on 2013-02-08 11:51:21

ramosian-glider commented 9 years ago
I'm still trying to come up with a testcase but sofar I still got a file around 500Kb
of C code and 'creduce' is still working to reduce it.

But I've narrowed down the flags to this set :

clang  \
-fno-common \
-fsanitize=undefined \
-fsanitize=address-full \
-m32 -march=pentiumpro -pipe -x c -O2\
-w -c myfile.c \
-ffunction-sections -fdata-sections -g \
-o myfile.o

I also tried with a more recent version of Clang/Asan (around this morning), same problem.

Reported by mkvtoolnix.build.jonthn on 2013-02-13 16:02:37

ramosian-glider commented 9 years ago
Do you see the same problem with -fsanitize=address instead of -fsanitize=address-full?

Reported by samsonov@google.com on 2013-02-13 16:04:29

ramosian-glider commented 9 years ago
Yes, same problem with -fsanitize=address

Reported by mkvtoolnix.build.jonthn on 2013-02-14 09:51:26

ramosian-glider commented 9 years ago
Please reopen once you get a repro for 
"symbol number 65315 references nonexistent SHT_SYMTAB_SHNDX section"
(I do not insist on a minimized repro, but it would be nice, of course)

Also, if you have a repro for 
"compile time goes from ~45seconds without Asan to something like ~7-8minutes with"
we'd like to see it too (in a separate bug report)

Reported by konstantin.s.serebryany on 2013-02-15 13:02:15

ramosian-glider commented 9 years ago
After a *lot* of days trying to reduce it I wasn't (or more precisely creduce) able
to reduce it to it's minimum so here it is.

Again the compilation line I'm using :

$ clang -fno-common -fsanitize=undefined -fsanitize=address -m32 -march=pentiumpro
-pipe -x c -O2 -w -c TESTCASE_reproducer.c -ffunction-sections -fdata-sections -g -o
TESTCASE_reproducer.o

$ nm TESTCASE_reproducer.o
BFD: TESTCASE_reproducer.o symbol number 65305 references nonexistent SHT_SYMTAB_SHNDX
section

I hope it will help you, if you need something more do tell me.

Reported by mkvtoolnix.build.jonthn on 2013-03-12 08:19:14

ramosian-glider commented 9 years ago
Just tried the above command line on fresh clang -- does not repro for me :(

Reported by konstantin.s.serebryany on 2013-03-12 08:28:52

ramosian-glider commented 9 years ago
Note, I am on ubuntu 12.04 which has a newer set of binutils, etc.

Reported by konstantin.s.serebryany on 2013-03-12 08:30:05

ramosian-glider commented 9 years ago
I didn't try with a fresh clang (will do).

As for the version of binutils for me, I got "binutils 2.20.1-16" (glibc-2.11)

Reported by mkvtoolnix.build.jonthn on 2013-03-12 12:01:21

ramosian-glider commented 9 years ago
Mine: 
GNU nm (GNU Binutils for Ubuntu) 2.22

Reported by konstantin.s.serebryany on 2013-03-12 12:26:07

ramosian-glider commented 9 years ago
Ok it doesn't seem to be related to binutils because with a fresh clang (r176857) it
also works for me.

But if you find a reason or the source of the problem I would very much learn about
it.

Reported by mkvtoolnix.build.jonthn on 2013-03-12 13:09:02

ramosian-glider commented 9 years ago
Adding Project:AddressSanitizer as part of GitHub migration.

Reported by ramosian.glider on 2015-07-30 09:13:40