Bug 163306 - Reading or assigning global h_errno variable causes a memory violation report from mudflap
Reading or assigning global h_errno variable causes a memory violation report...
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Frank Ch. Eigler
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2005-07-14 18:35 EDT by Vesselin Peev
Modified: 2009-01-09 01:53 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2009-01-09 01:53:28 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Vesselin Peev 2005-07-14 18:35:57 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Fedora/1.0.4-1.3.1 Firefox/1.0.4

Description of problem:
Simply reading or writing to the h_errno global variable gives out a read/write violation in mudflap.

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

How reproducible:

Steps to Reproduce:
1. Compile the program

#include <stdio.h>
#include <netdb.h>
int main()
printf("%d", h_errno);
return 0;

and the program

#include <netdb.h>
int main()
h_errno = 0;
return 0;

with mudflap enabled, i.e.

gcc -fmudflap prog1.c -lmudflap -o prog1
gcc -fmudflap prog2.c -lmudflap -o prog2

2. Run prog1 and prog2.

Actual Results:  When prog1 is run, this is what I get:

mudflap violation 1 (check/read): time=1121380261.574621 ptr=0xb7eff6b4 size=4
pc=0xb7f09322 location=`a.cpp:6 (main)'
      /usr/lib/libmudflap.so.0(__mf_check+0x44) [0xb7f09322]
      ./a.out(main+0x81) [0x8048839]
      /usr/lib/libmudflap.so.0(__wrap_main+0x1d8) [0xb7f0a04e]
Nearby object 1: checked region begins 17B after and ends 20B after
mudflap object 0x80cb430: name=`errno area'
bounds=[0xb7eff6a0,0xb7eff6a3] size=4 area=static check=0r/0w liveness=0
alloc time=1121380261.574591 pc=0xb7f09e0a
number of nearby objects: 1

When prog2 is run, the report is similar, but it says "(check/write)", instead of "(check/read)" -- because h_errno is written to.

Expected Results:  There should have been no violation messages.

Additional info:
Comment 1 Jakub Jelinek 2005-07-15 04:33:17 EDT
That's a mudflap bug.  (*__h_errno_location()) (which is what h_errno expands
to) is a thread local storage variable similarly to errno (*__errno_location()).
libmudflap has special quirks for errno, but not for h_errno (and I guess
not for _res either, and I wonder if any other thread local storage variable).
Comment 2 Vesselin Peev 2005-07-15 08:30:15 EDT
Jakub, cool, thanks! May I ask why the need for h_errno to expand to a thread 
local storage variable if gethostbyname is not reentrant, and it (global 
h_errno) isn't used by the reentrant equivalent gethostbyname_r?
Comment 3 Jakub Jelinek 2005-07-15 08:33:14 EDT
h_errno is used in many other functions, some of which are reentrant.
Comment 4 Frank Ch. Eigler 2005-09-23 18:04:21 EDT
Is there a complete list of such variables someplace?  Failing that, I'll add
h_errno support to gcc mainline, and consider backporting.
Comment 5 Dan Hollis 2005-10-07 18:49:44 EDT
mudflap is very buggy atm, i get violations just reading from argv[] :)
Comment 6 Frank Ch. Eigler 2005-10-07 19:26:10 EDT
(In reply to comment #5)
> mudflap is very buggy atm, i get violations just reading from argv[] :)

This would be a separate problem.  Make sure you pass -fmudflap to the link
stage too.  If you do, and you still encounter this, please open a separate
bugzilla with a sample program.
Comment 7 Christian Iseli 2007-01-22 05:50:31 EST
This report targets the FC3 or FC4 products, which have now been EOL'd.

Could you please check that it still applies to a current Fedora release, and
either update the target product or close it ?

Comment 8 petrosyan 2008-02-18 17:21:14 EST
this bug is still present in Fedora 8, gcc-4.1.2-33
Comment 9 Bug Zapper 2008-11-26 01:51:48 EST
This message is a reminder that Fedora 8 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 8.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '8'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 8's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 8 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
Comment 10 Bug Zapper 2009-01-09 01:53:28 EST
Fedora 8 changed to end-of-life (EOL) status on 2009-01-07. Fedora 8 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.

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