Red Hat Bugzilla – Bug 84226
htons() broken for Pentium 4
Last modified: 2016-11-24 10:24:02 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20021003
Description of problem:
It appears as though the htons implementation has some problems on Pentium 4. I
have attached the code for a small test program based on code from the OpenSLP
You'll notice that the buffer generation on RedHat 7.3 differs from Redhat 8.0.
You'll also notice that buffer generation differs between Pentium 2/3 and
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1.compile program on RH 7.3 and RH 8.0 and compare output
2.compile program on RH 8.0 and compare output when run on Pentium 3 and Pentium 4
Redhat 7.3 produces correctly formatted buffer.
Redhat 8.0 on Pentium 2/3 produces correctly formatted buffer
Redhat 8.0/8.1 beta produces INCORRECTLY formatted buffer
Code generation for htons() should be compatible across pentium family such that
use of htns() to format packet buffers is source/binary compatible across Redhat
distros and all pentium architectures
Additional info: See attached htons_test.c file
Actual results (should say)
Redhat 8.0/8.1 on Pentium 4 beta produces INCORRECTLY formatted buffer
Created attachment 90058 [details]
Short test program that uses htons() to build packet buffer
This program has undefined behaviour, see info gcc on -fstrict-aliasing.
You cannot access one memory location (in your testcase char) through
two different pointers which may not alias.