ramosian-glider / sanitizers

0 stars 0 forks source link

Stack realignment with dynamic allocas #133

Closed ramosian-glider closed 9 years ago

ramosian-glider commented 9 years ago

Originally reported on Google Code with ID 132

What steps will reproduce the problem?

$ cat a.cpp 
#include <stdlib.h>

int main(int argc, char const* argv[])
{
    void* a = alloca(atoi(argv[1]));
    return 0;
}

$clang++ a.cpp -faddress-sanitizer
fatal error: error in backend: Stack realignment in presence of dynamic allocas is
not supported

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

I would expect address sanitizer to support this. perhaps by replacing alloca() and
align all allocations.

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

$clang++ --version
Apple clang version 4.1 (tags/Apple/clang-421.11.65) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

$ uname -a
Darwin arvid-macpro-634.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48
PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64

Reported by arvid.norberg on 2012-12-09 20:11:39

ramosian-glider commented 9 years ago
Hi!
This doesn't reproduce for me:
$ cat realign.cc 
#include <stdlib.h>

int main(int argc, char const* argv[])
{
        void* a = alloca(atoi(argv[1]));
        return 0;
}
$ ../bin/clang++ -fsanitize=address realign.cc 
$ ./a.out 10

However, I use OS X 10.8.2 (Darwin 12.2.0) and the latest Clang built from trunk (LLVM
revision 169652). Could you check if your test case works on the newest Clang (http://clang.llvm.org/get_started.html)?

Reported by samsonov@google.com on 2012-12-09 23:34:23

ramosian-glider commented 9 years ago
Also, please try -mllvm -asan-realign-stack=0 and let us know if it helps. 

Reported by konstantin.s.serebryany on 2012-12-10 04:59:46

ramosian-glider commented 9 years ago
"-mllvm -asan-realign-stack=0" does not make any difference on my version of clang.
It working in trunk for you is encouraging then. I may not have the patience to test
this with trunk anytime soon though. My code did build with trunk from 6 months ago
or so though.

Reported by arvid.norberg on 2012-12-15 04:16:13

ramosian-glider commented 9 years ago
Stack realignment in presence of dynamic allocas is supported by LLVM/Clang starting
from r158087 (with significant fixes in later patches). Hopefully this would work for
you in LLVM 3.2 and in the next Apple clang release.

Reported by samsonov@google.com on 2012-12-17 06:47:35

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