This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Address sanitizer use a lot of memory
- From: ownssh <ownsshaim at aol dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Sun, 13 Apr 2014 11:49:33 -0400 (EDT)
- Subject: Re: Address sanitizer use a lot of memory
- Authentication-results: sourceware.org; auth=none
- References: <8D12494A58A7945-81C-7D02 at webmail-d273 dot sysops dot aol dot com> <8D12546B6F57A7E-13A4-B840 at webmail-m278 dot sysops dot aol dot com>
This problem is resolved.
check out
http://llvm.org/viewvc/llvm-project?rev=201400&view=rev
https://code.google.com/p/address-sanitizer/issues/detail?id=256
gcc havn't merge it yet, but I already test this problem is not exist
with clang svn.
---
ownssh
ownsshaim@aol.com
-----Original Message-----
From: ownssh <ownsshaim@aol.com>
To: gcc-help <gcc-help@gcc.gnu.org>
Sent: Sat, Apr 12, 2014 6:32 pm
Subject: Re: Address sanitizer use a lot of memory
I did more research and I found this is because address sanitizer use
mmap to allocate the fake stack.
First address sanitizer will get the fake stack size from RLIMIT_STACK
in sanitizer_linux.cc:GetThreadStackTopAndBottom,
then allocate in asan_fake_stack.cc:AllocateOneSizeClass.
One way to reduce the memory usage is set a smaller RLIMIT_STACK,
example:
sh -c "ulimit -s 32; ASAN_OPTIONS=verbosity=1 ./a.out"
But the better solusion maybe reduce the real memory usage from mmap.
Also this issue are exist in clang 3.4 because it take same approach.
I will continue post if I found anything more.
regard.
On 11 April 2014 20:03, ownssh wrote:
Address sanitizer use a lot of memory with pthread of this code:
---
#include <vector>
#include <iostream>
#include <chrono>
#include <thread>
using namespace std;
void thread_main(int thread_id) {
cout << thread_id << endl;
this_thread::sleep_for(chrono::milliseconds(5000));
}
int main() {
vector<shared_ptr<thread>> thread_list;
for (int i=0; i<200; i++) {
thread_list.push_back(make_shared<thread>(thread_main, i));
}
for (auto t: thread_list) {
t->join();
}
thread_list.clear();
return 0;
}
---
before add -fsanitize=address it used 1.6mb, after add it used
270.5mb.
this code just simply create 200 threads, I have no idea why it will
use so much.
GCC version is "gcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC)",
from rhel 6 devtoolset.
Please let me known if you found anything about this, thanks.
regard.
---
ownssh
ownsshaim@aol.com