Bug 84226 - htons() broken for Pentium 4
Summary: htons() broken for Pentium 4
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 8.0
Hardware: other
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
Depends On:
TreeView+ depends on / blocked
Reported: 2003-02-13 17:54 UTC by Matt Peterson
Modified: 2016-11-24 15:24 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2003-02-13 20:00:12 UTC

Attachments (Terms of Use)
Short test program that uses htons() to build packet buffer (1.57 KB, text/plain)
2003-02-13 17:59 UTC, Matt Peterson
no flags Details

Description Matt Peterson 2003-02-13 17:54:08 UTC
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
Pentium 4.

Version-Release number of selected component (if applicable):

How reproducible:

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


Actual Results:  
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

Expected Results:  
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

Comment 1 Matt Peterson 2003-02-13 17:58:05 UTC
Actual results (should say)
Redhat 8.0/8.1 on Pentium 4 beta produces INCORRECTLY formatted buffer

Comment 2 Matt Peterson 2003-02-13 17:59:39 UTC
Created attachment 90058 [details]
Short test program that uses htons() to build packet buffer

Comment 3 Jakub Jelinek 2003-02-13 20:00:12 UTC
This program has undefined behaviour, see info gcc on -fstrict-aliasing.
You cannot access one memory location (in your testcase char[3]) through
two different pointers which may not alias.

Note You need to log in before you can comment on or make changes to this bug.