On Tue, Nov 24, 2009 at 11:49:58AM +0800, Asm_gmail wrote:
> Bob Rossi wrote:
> > Hi,
> > I've spent countless hours reproducing this small fragment into
> > something meaningful that I can send in as a bug report. I hope
> > some of you can validate this issue, or perhaps give me some
> > insight on the problem.
> > I am using g++-sjlj version 4.2.
> > $ g++-sjlj.exe --version
> > g++-sjlj.exe (GCC) 4.2.1-sjlj (mingw32-2)
> > This was available from the mingw sourceforge project at one
> > point in time. I would appreciate if someone would
> > test this issue with the newest mingw gcc.
> > I've attached a small program that has a sporadic crash, when
> > compiled with mingw. The trick is, it only crashes when the
> > compiler optimization flags is -O1, -O2 or -O3 are set. If it is
> > compiled without optimization there is no crash.
> > Furthermore, if instead of passing -O1, -O2, or -O3, I instead
> > set the corresponding optimizations that are performed at those
> > levels from here,
> > http://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Optimize-Options.html#Optimize-Options
> > the bug goes away completely.
> > So, this compile command causes the sporadic crash,
> > g++-sjlj -O Broken.cc -o Broken.exe -mthreads -lmingw32
> > and this command produces no errors,
> > g++-sjlj Broken.cc -o Broken.exe \
> > -fdefer-pop -fdelayed-branch -fguess-branch-probability -fcprop-registers -fif-conversion -fif-conversion2 -ftree-ccp -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-ter -ftree-lrs -ftree-sra -ftree-copyrename -ftree-fre -ftree-ch -funit-at-a-time -fmerge-constants \
> > -fthread-jumps -fcrossjumping -foptimize-sibling-calls -fcse-follow-jumps -fcse-skip-blocks -fgcse -fgcse-lm -fexpensive-optimizations -frerun-cse-after-loop -fcaller-saves -fpeephole2 -fschedule-insns -fschedule-insns2 -fsched-interblock -fsched-spec -fregmove -fstrict-aliasing -fstrict-overflow -fdelete-null-pointer-checks -freorder-blocks -freorder-functions -falign-functions -falign-jumps -falign-loops -falign-labels -ftree-vrp -ftree-pre \
> > -finline-functions -funswitch-loops -fgcse-after-reload \
> > -mthreads -lmingw32
> > even though they should be the same compiler optimizations.
> > I found someone else complaining about this exact problem at the bottom
> > of this page,
> > http://forums.codeblocks.org/index.php?action=printpage;topic=11055.0
> > The problem crashes in the spawned thread at the throw statement.
> > If you put more logging in, you'll see that as soon as the throw
> > is hit, the program dies.
> > Can anyone confirm this bug at all, or with a newer version of the
> > compiler? Is there any advice that can be given to guide me past
> > this issue? Should I submit a bug to gcc somewhere?
> > Thanks,
> > Bob Rossi
> I just build this example code under Code::blocks and TDM-GCC 4.4.1-2.
> in release mode, but there is not crash when running the program.
Please note, I ran this example like this,
while ./Broken.exe; do /bin/true; done
and after about 5 seconds it would usually fail once. Does that help
reproduce the problem?