Miscompilation with "-fpeel-loops" and -O{2,3,s}

Michael Tokarev mjt at tls.msk.ru
Tue Oct 22 17:44:13 MSK 2013


22.10.2013 14:11, Marcin Mirosław wrote:
> Hi!
> I'm not sure if it's problem inside udns or inside gcc. I'm starting to
> ask here about it, if it's not problem in udns I'll look for help on gcc
> mailing list.
> I've noticed that compiling udns-0.2 using "-fpeel-loops" optimalization
> (togoether with -O2, -O3 or -Os) build executable which doesn't works
> correctly.
> Without -fpeel-loops:
> $ ./rblcheck -s rbl.mejor.pl 88.198.102.195 ; echo  $?
> 88.198.102.195 is listed by rbl.mejor.pl: 127.0.1.1
> 100
>
> with -fpeel-loops:
> $ ./rblcheck -s rbl.mejor.pl 88.198.102.195 ; echo $?
> 0

Wow.

I tried to reproduce, but my gcc (debian 4.7.2) produces a working
binary when compiled with -fpeel-loops -O2.

> I also suspect problem appears while ocmpiling udns_resolver.c, I did
> some tests, when udns_resolver.o was compiled with -fpeel-loops then
> after linking libudns didn't work correctly.

Yes, it looks like the prob is with compiling udns_resolver.c (which is
the main source file anyway).

> I have no more skills to find out where is problem (gcc or udns). I
> prepared static clang analyse of udns[1], clang states there could be
> "use-after-free" error in udns_resolver.c, can it be related to mine
> problem?

No, all these clang warnings are bogus except of one - in ex-rdns.c there's
a useless assignment to `c' variable.  There's no use-after-free in the
place clang thinks there is (unless I don't understand C).  And even if
it were were, we're not hitting it -- it can be "triggered" (at least
how clang "thinks") at the cleanup path when stuff gets cleared after
everything has been done (it is in udns_close() function, which isn't
even called by rblcheck).

So I don't quite sure what to do here.  And I haven't seen this -fpeel-loops
flag, have no idea what it does (will read).

At least, can you specify gcc version which you used which produces bad
results, and the architecture (if it is x86, please specify whenever it
is 32 or 64bits).

Thanks,

/mjt


More information about the udns mailing list