Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 16267 - glibc 2.3.2pre1 breaks 'extern int errno'
Summary: glibc 2.3.2pre1 breaks 'extern int errno'
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: Highest blocker (vote)
Assignee: Martin Schlemmer (RETIRED)
URL:
Whiteboard:
Keywords:
: 16355 16406 22248 (view as bug list)
Depends on:
Blocks: 16344 16355 16363 16370 16396 16420 16436 16444 16450 16480 16715 16798 16801 16804 17012 17013 17187 17744
  Show dependency tree
 
Reported: 2003-02-24 05:06 UTC by Jedi/Sector One
Modified: 2003-07-30 15:40 UTC (History)
17 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Fix errno (djbdns) (error.h.patch,243 bytes, patch)
2003-02-25 14:22 UTC, Andy Dustman
Details | Diff
Fix ebuild (djbdns) (djbdns.ebuild.patch,393 bytes, patch)
2003-02-25 14:24 UTC, Andy Dustman
Details | Diff
Patch to make glimpse compile with new glibc (errno.diff,4.51 KB, patch)
2003-02-25 15:46 UTC, Sami Nieminen
Details | Diff
New ebuild for glimpse that uses errno patch (glimpse-4.15-r1.ebuild,694 bytes, text/plain)
2003-02-25 15:48 UTC, Sami Nieminen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jedi/Sector One 2003-02-24 05:06:54 UTC
Qmail, Daemontools and djbDNS assumes that "errno" can be defined as "extern int
errno;".

This is a broken assertion.

When Glibc 2.3.2pre1 is emerged, all DJB software immediately stop working.

And compilation doesn't work any more, because "errno" is no more defined as a
global symbol.

Fix : add patches for all DJB software to  #include <errno.h> and remove "extern
int errno"

Reproducible: Always
Steps to Reproduce:
1.
2.
3.
Comment 1 SpanKY gentoo-dev 2003-02-25 12:12:29 UTC
dosfstools breaks too ... 
az: shall we just handle this on a case by case basis ? 
Comment 2 SpanKY gentoo-dev 2003-02-25 12:12:50 UTC
*** Bug 16344 has been marked as a duplicate of this bug. ***
Comment 3 SpanKY gentoo-dev 2003-02-25 12:20:41 UTC
*** Bug 16355 has been marked as a duplicate of this bug. ***
Comment 4 Sami Nieminen 2003-02-25 12:30:20 UTC
glimpse (4.15) ebuild also fails with 'undefined reference to errno'. 
Comment 5 SpanKY gentoo-dev 2003-02-25 13:04:38 UTC
daemontools is also broken ... 
Comment 6 SpanKY gentoo-dev 2003-02-25 13:10:58 UTC
in light of these issues, imo this version of glibc should be masked asap ... 
 
any thought on how it'll affect binary packages ?  we can patch source code of 
programs but we cant really patch binary packages (vmware) ... 
Comment 7 Andy Dustman 2003-02-25 14:22:32 UTC
Created attachment 8716 [details, diff]
Fix errno (djbdns)

Fix use of errno by including errno.h
Comment 8 Andy Dustman 2003-02-25 14:24:56 UTC
Created attachment 8717 [details, diff]
Fix ebuild (djbdns)

Apply errno patch, minor spacing cleanup
Comment 9 Andy Dustman 2003-02-25 14:27:29 UTC
Note that the above patches will NOT break building under older glibc versions.
Comment 10 Sami Nieminen 2003-02-25 15:46:14 UTC
Created attachment 8719 [details, diff]
Patch to make glimpse compile with new glibc

Attached patch makes glimpse compile with new glibc 2.3.2pre1
Comment 11 Sami Nieminen 2003-02-25 15:48:07 UTC
Created attachment 8720 [details]
New ebuild for glimpse that uses errno patch

Attached ebuild uses errno.diff to patch glimpse to compile with new glibc
2.3.2pre1
Comment 12 SpanKY gentoo-dev 2003-02-25 16:37:29 UTC
*** Bug 16370 has been marked as a duplicate of this bug. ***
Comment 13 Martin Schlemmer (RETIRED) gentoo-dev 2003-02-25 17:51:40 UTC
Yep, havent looked at this yet, but we will have to handle it case by case.

Basically a problem that you need to include errno.h, and not declare errno
external.  I already added patches to net-nds/portmap and x11-misc/xloadimage
at the beginning of the year when I did some testing on glibc-2.3.2 cvs.
Comment 14 SpanKY gentoo-dev 2003-02-25 19:45:39 UTC
that is fine but what about binary only packages ?
vmware breaks with the new glibc
Comment 15 SpanKY gentoo-dev 2003-02-25 19:47:54 UTC
also, i still maintain that the new glibc should be masked due to the sheer volume of broken ebuilds ...

yes we patch them, but we do it on developer boxes and not let the users experience this too
Comment 16 Martin Schlemmer (RETIRED) gentoo-dev 2003-02-25 23:27:52 UTC
Ok, I thought ~ was for developers, and users that *wanted to help test* 
developmental stuff ?
Comment 17 SpanKY gentoo-dev 2003-02-25 23:48:39 UTC
yes, ~ is for testing/development, but package.mask is for broken (which is what this is) 
Comment 18 Martin Schlemmer (RETIRED) gentoo-dev 2003-02-26 02:51:33 UTC
I am sorry, but the glibc developers do not consider this as broken.  It will
be the same in 2.3.2 official, and following versions.  And this is what '~'
if for .. we fix things now for when 2.3.2 is officially out.  Do you want this
chaos when 2.3.2 is actually out ?
Comment 19 SpanKY gentoo-dev 2003-02-26 03:05:37 UTC
i wasnt suggesting we mask it now and forever ...
i was suggesting we package.mask it and then on our own dev boxes we try to emerge
and patch as many packages as possible ... you can tell there are, and will be,
plenty of packages that break ...

then, we patched a large number of ebuild's, we release it to ~ and let all the
other random users report the packages we missed ...

however, we still need some kind of solution for older binary only packages ...
even if it's like hacking something into lib-compat ...
Comment 20 SpanKY gentoo-dev 2003-02-26 04:01:17 UTC
*** Bug 16396 has been marked as a duplicate of this bug. ***
Comment 21 narendra sankar 2003-02-26 16:21:21 UTC
There is a hack available for vmware. It is described in in vmware.for-linux.experimental which I am copying below. It works for me with the
caveat that for non root users, LD_PRELOAD clears suid. vmware needs suid access
to /dev/misc/vmmon and /dev/tty0 and /dev/tty7(tty on which current X is running). 
I had to change the permissions on these to a+rw for vmware to run as non-root.
It will complain about /dev/tty8 and not having permission to run full-screen. However changing permissions on tty8 does not seem to work. I don't rung full-screen, so not an issue for me, but may be problems for others. 
From researching on the web, I believe it is correct for LD_PRELOAD to clear
suid. vmware-ui and vmware-mks have suid propagated to them from vmware.
However the LD_PRELOAD, breaks the chain.
I don't know what problems can be created by changing the permissions on the 
tty0 and tty7. So far I haven't seen any. But I am on a non-secure workstation. If security is important, this might be an issue. Hopefully vmware will
release a patch sometime soon, as redhat 8.1 I believe will require that. Otherwise they might just move people to version 4.0 which is in beta now.
Naren
------------------------------------------------

In the interest of posterity (and helping anyone else using vmware with
rawhide glibc), here's what ended up working.

Compile the attached file q.c into q.so.  Put q.so into /usr/lib/, and
chmod it 555.  Then rename the files /usr/lib/vmware/bin/vmware-{ui,mks},
giving them a ".bin" extension.  Then create two new files named
/usr/lib/vmware/bin/vmware-{ui,mks} instead that contain:
-------------------
#!/bin/bash
LD_PRELOAD=q.so exec "$0.bin" "$@"
-------------------

chmod a+rx these new files, and all should be well.

The basic problem is that vmware binaries have their own copy of errno and
related functions, and there is a clash with the new glibc ones.  q.so will
resolve this problem.  The need for the scripts above arises from the fact
that each of the binaries launched by the initial /usr/bin/vmware call
needs to have the q.so preloaded.  

q.c was written by Petr Vendrovec, and many thanks go to him for the work
he put into the debugging of the problem and the attached code!

In summary, q.c qorreqts the formerly inqurable qrashes.

Cheers,
-- 
  Ami Fischman
  usenet@fischman.org

-------------------------------------------------------
/*
 * Build with: gcc -W -Wall -shared -o q.so q.c
 */

#include <dlfcn.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <stdio.h>

void go(void) __attribute__((constructor));

void go(void) {
 void* qh;
 unsigned char *__real_errno_location, *__vm_errno_location;

 qh = dlopen("libc.so.6", RTLD_GLOBAL);
 __real_errno_location = dlsym(qh, "__errno_location");
 __vm_errno_location = dlsym(NULL, "__errno_location");
 printf("Got eroloc %p & %p\n", __vm_errno_location, __real_errno_location);
 if (__real_errno_location && __vm_errno_location && __real_errno_location != __vm_errno_location) {
  unsigned int errnobase = (int)__vm_errno_location;
  unsigned int mpbase = errnobase & ~0xFFF;
  unsigned int mplen = 4096;

  if (errnobase + 5 > mpbase + mplen) {
   mplen = mplen + 4096;
  }
  mprotect((void*)mpbase, mplen, PROT_READ|PROT_WRITE|PROT_EXEC);
  *__vm_errno_location = 0xE9;
  *(int*)(__vm_errno_location + 1) = __real_errno_location - __vm_errno_location - 5;
  mprotect((void*)mpbase, mplen, PROT_READ|PROT_EXEC);
 }
} 

----------------------------------
Comment 22 narendra sankar 2003-02-26 16:25:07 UTC
Another comment. There is an ongoing discussion on the wine lists as to how to solve this. This is a problem for wine. So wine will not work at this time, and the last I know there is no real solution for this yet. The same is true for the mono compiler and tools. There are issues there, and the wine and mono teams are trying to figure out a solutions.
look at the following for more information.
http://www.winehq.com/news/?view=155#Threading%20Problems%20with%20glibc%202.3
Comment 23 SpanKY gentoo-dev 2003-02-26 17:48:03 UTC
*** Bug 16420 has been marked as a duplicate of this bug. ***
Comment 24 Andy Dustman 2003-02-26 18:54:26 UTC
Idea: Is it feasible to create an eclass that would facilitate fixing source files, changing "extern int errno;" to "#include <errno.h>" during the src_unpack stage? i.e.

# grep pattern intentionally loose
find ${S} -type f -name '*.[ch]' | xargs grep -l errno | while read f; do
    einfo "Fixing errno usage in ${f}"
    mv ${f} ${f}.orig
    # why are sed regexes so lame?
    perl -p -e 's|(extern\W+int\W+errno\W*;)|/* \1 */\n#include <errno.h>\n|;' \
        <${f}.orig >${f}
done

Then the ebuilds of packages with problems just need to inherit fix_errno (or whatever) and we don't need a bazillion patches everywhere.

I've tested the above script on qmail and it works correctly. I think it will work on the majority of cases.

BTW, looks like mysql is another app that breaks with glibc-2.3.2. (I only tried 4.0.11a, but certainly older versions are affected as well.)
Comment 25 SpanKY gentoo-dev 2003-02-26 20:56:04 UTC
well, in addition to fixing it, we should be talking to upstream maintainers about this bug 
Comment 27 Clemens Schwaighofer 2003-03-01 23:39:01 UTC
kerberos5 1.2.7 is also affected by the glibc bug. I tried to ship around with -DHAVE_ERRNO_AS_DEFINE=1 but it didn't work.
I submited a seperate bug for kerberos5 1.2.7 itself
Comment 28 phoen][x 2003-03-05 07:59:19 UTC
*** Bug 16355 has been marked as a duplicate of this bug. ***
Comment 29 Derek Dolney 2003-03-06 18:16:26 UTC
The Intel Fortran Compiler, ifc, is also broken by this. Presumably also their C Compiler, icc.
Comment 30 narendra sankar 2003-03-06 18:20:53 UTC
The intel c/c++ compiler icc & icpc Version 7.0   Build 20030212Z
works without any problems on glibc 2.3.2. I have built an internal project on this and it is running with no bugs so far.
Comment 31 James Cloos 2003-03-06 21:15:22 UTC
Another package affected by this is ezm3, needed to compile cvsup.
Comment 32 dan 2003-03-07 16:32:03 UTC
any updates on the wine situation? 
Comment 33 narendra sankar 2003-03-07 16:35:12 UTC
The last I read, for wine they are still working on a solution. The reason for the delay is the intent to also fix the threading model which is definitely more work.
So for now, people needing wine should not upgrade glibc.
Comment 34 Matt Bailey 2003-03-10 19:35:55 UTC
fix:
while OOo is extracting add this line:

#include <errno.h>


to this file:

/var/tmp/portage/openoffice-1.0.2/work/oo_1.0.2_src/dmake/extern.h
Comment 35 Matt Bailey 2003-03-10 19:41:22 UTC
^ for openoffice that is. fixes the dmake error
Comment 36 Martin Schlemmer (RETIRED) gentoo-dev 2003-03-11 13:15:24 UTC
Right, we should just replace all declarations of errno with '#include <errno.h>'.

What binary packages except for WineX (the one you pay for), and VMWare are 
affected ?
Comment 37 Joakim 2003-03-16 08:07:31 UTC
Sorry but please explain this to me... How come glibc developers don't consider this 
broken? There is appearently a change in 2.3.2 that breaks a majority of apps even if 
they are compiled with the latest gnu compiler... but seam to work some none-gnu 
ones... Then this must be a gcc bug then really or? 
 
To me keep on adding patches to apps making them work seam to be a temporary 
solution not THE solution? 
Comment 38 Martin Schlemmer (RETIRED) gentoo-dev 2003-03-16 10:26:54 UTC
Its rather simple:  all programs that was coded like so:

------------ broken code ----------------
extern int errno;
-----------------------------------------

breaks.  The right way (and why the glibc devs do not really bother), is to
include errno.h like so:

------------- the right way --------------
#include <errno.h>
------------------------------------------

System header files is there for a reason, and doing things like
declaring 'errno' as an 'extern int' when the proper system header
do exist, is just wrong (or in the glibc devs's books).
Comment 39 Philip Walls (RETIRED) gentoo-dev 2003-03-16 13:45:15 UTC
Crossover 1.2 is affected, I believe 1.3 suffers from the problem as well.
Comment 40 Wout Mertens (RETIRED) gentoo-dev 2003-03-17 08:03:54 UTC
Fixed krb5-1.2.7 ebuild with a construct like in comment 24. 
Comment 41 Bjarke Istrup Pedersen (RETIRED) gentoo-dev 2003-03-21 17:50:04 UTC
libmpeg3-1.5-r1 also has this problem. 
Comment 42 christian gut 2003-03-26 15:50:46 UTC
what about the wine thing? could wie just replace the wrong errno things in code? or any other fix?
Comment 43 phoen][x 2003-03-30 11:18:40 UTC
Got a quick fix for wine* from irc:
'export LD_ASSUME_KERNEL=2.2.5' before you run wine.

Thanks to taviso in #gentoo.

The related url is: http://www.winehq.com/index.php?issue=163#Making%20Wine%20Run%20With%20glibc%202.3

-phoen][x-
Comment 44 Martin Schlemmer (RETIRED) gentoo-dev 2003-05-18 09:26:06 UTC
Ok, I was a bit busy, but I'll try now to get to everything.  Could you
guys add a bug for all packages that is affected by this?  I can then
start sorting them out.

NOTE: please add a *new* bug, with me as owner.
Comment 45 Martin Holzer (RETIRED) gentoo-dev 2003-05-22 18:43:13 UTC
*** Bug 16406 has been marked as a duplicate of this bug. ***
Comment 46 nate grady 2003-07-06 16:40:48 UTC
In xloadimage, I had to add:
#include <errno.h>
to the top of img.c in order for it to compile as well.
Comment 47 Rigo 2003-07-07 01:33:06 UTC
app-games/mindless-1.2 as well (needed to include errno.h in http_fetcher.c)
Comment 48 SpanKY gentoo-dev 2003-07-27 22:58:12 UTC
glibc-2.3.2 is marked stable, all packages are out w/errno fixes, and we should be 
good to go :) 
 
nice work all 
Comment 49 Michael Imhof (RETIRED) gentoo-dev 2003-07-30 15:40:20 UTC
*** Bug 22248 has been marked as a duplicate of this bug. ***