New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tcpdump 4.1.1 bus error when 'gcc -O2' (default) optimizatio #130
Comments
Submitted by guy_harris Is this Solaris-on-SPARC, or Solaris-on-x86/x86-64? This isn't BSD, so SIGBUS isn't being misused for a reference to an invalid pointer; the most common cause of SIGBUS on Solaris-on-SPARC is, as I remember, an unaligned access - they cause a trap on SPARC. If this is Solaris-on-SPARC, and, for example, the optimizer is assuming that bp points to a properly-aligned structure after
and is optimizing
into, for example, a load of the 32-bit word pointed to by bp followed by a mask against 0xFFFFFF00 and a comparison against 0x01010600, that would fail if bp isn't properly aligned. If something such as that is the case, we might have to add an EXTRACT_8BITS() macro and hope that using tricks similar to what we have for EXTRACT_16BITS() keeps the optimizer from assuming bp is aligned on a 2-byte or 4-byte boundary. (bp is probably "optimized out" because it has the same address in it that cp does; if this is SPARC, it probably just uses the register in which cp was passed.) |
Submitted by guy_harris
Ha, ha. That's exactly what it's doing.... |
Submitted by itillman It is indeed Solaris on SPARC. |
Submitted by guy_harris I've checked a change into the trunk and 4.1 branch that prevents GCC 4.2.4, at least, from doing that optimization on "struct bootp". It prevents the crash, at least on the machine on which I tested it. |
Converted from SourceForge issue 3042751, submitted by itillman
Platform:
tcpdump 4.1.1
libpcap 1.1.1
Solaris 10
gcc 4.2.4
(Also verified with gcc 3.3.6 on Solaris 9, gcc 4.1.2 on on Solaris 9, gcc 4.3.4 on Solaris 10, gcc 4.4.3 on Solaris 10
tcpdump 4.1.1 built with gcc 4.2.4 on Solaris 10 (defaults to 'gcc -O2'):
Adding -q makes the problem go away:
Rebuild tcpdump adding '-g' to CCOPT in Makefile, so we can debug more easily.
Crashes as expected:
When I look at it this core with ddd, ddd tells me that at print-bootp.c:76,,
value 'bp' has been optimized out.
Ditto for when I go up a frame to print-ip.c:434 and look at value 'up'.
(That's what led me to try rebuilding without optimization to find
that worked around the issue.)
Rebuilding tcpdump without -O2 (regardless of whether I include -g), makes the problem go away:
So it seems like the problem is related to gcc optimizing away something
that tcpdump wants to reference.
The text was updated successfully, but these errors were encountered: