[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [creduce-dev] question on creduce usage

Since I suggested building g++ with address sanitizer, even though I've never tried it myself,
I felt honor-bound to give it a shot :-)  Note: I am not a professional gcc wrangler, just a hobbyist.
This worked for me:

# One-time preparation
sudo apt build-dep g++
sudo apt install libmpc-dev
# work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48879)
(cd /usr/include; sudo ln -s asm-generic asm)
# If you don't want to clutter /usr/local, pick some other prefix when running configure
sudo mkdir /usr/local
sudo chown $USER /usr/local
# build as usual, but --with-build-config=bootstrap-asan
git clone git://gcc.gnu.org/git/gcc.git 
cd gcc
mkdir btmp
cd btmp
.../configure --with-arch=native --enable-multiarch --disable-lto --enable-stage1-languages=c  --enable-languages=c,c++ --with-build-config=bootstrap-asan
make -j4 bootstrap
make install

Bootstrapping took 8 hours on an i3-4130.

After that, running /usr/local/bin/g++ hello.cc aborts with 
==528129==ERROR: LeakSanitizer: detected memory leaks
but setting LSAN_OPTIONS=detect_leaks=0 lets it succeed.

Should be just the ticket for finding internal errors... although 
it was built with -O2, so the backtraces might not be as informative
as you'd like.
- Dan

On Thu, Aug 6, 2020 at 2:49 PM Dan Kegel <dank@kegel.com> wrote:
> I have not tried it myself, but googling finds references to a  --with-build-config=bootstrap-asan option for building gcc itself.  I have not checked what it does.
> On Thu, Aug 6, 2020, 14:23 Jack <ostroffjh@users.sourceforge.net> wrote:
>> (I didn't get Dan's message directly - perhaps it's still out in the
>> ether...)
>> On 2020.08.06 16:55, John Regehr wrote:
>> >> Can you also bootstrap gcc with address sanitizer?  That might help
>> >> detect the error more reliably...?
>> > This is a good idea.
>> A pointer please?  I'm not sure how to approach this.
>> >
>> >> Also, in my experience, restarting creduce runs from scratch after
>> >> improving your oracle script etc. is kind of part of the territory...
>> My test.sh is only
>> #!/bin/bash
>> x86_64-pc-linux-gnu-g++  -fvisibility-inlines-hidden -Os -pipe
>> -fomit-frame-pointer -std=c++14 -fPIC -m64 -pthread -finline-functions
>> -Wno-inline -Wall -fvisibility=hidden -DBOOST_ALL_DYN_LINK=1
>> -DNDEBUG -c -o instantiate_predef_macros.o
>> instantiate_predef_macros.pp.cpp > gcc_out.txt 2>&1
>> grep "stack smashing detected" gcc_out.txt >/dev/null 2>&1
>> so there isn't much to change.  I suppose I could try removing some of
>> the parameters, but I don't personally understand them well enough to
>> know if they will affect the outcome.  I suppose I could try a manual
>> creduce on the command line itself :-)
>> Jack