logo       

[patch]: fix ia64 SIGSEGV in coreutils 4.5.9: msg#00044

gnu.core-utils.bugs

Subject: [patch]: fix ia64 SIGSEGV in coreutils 4.5.9

tags 183962 patch
quit

Hi,

The included patch fixes the Debian ia64 build failure for coreutils-4.5.9
reported here:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=183962

The first indication that there is a bug is a warning during the build:

if gcc -DLIBDIR=\"/usr/lib\" -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I. -g
-DSYSLOG_SUCCESS -DSYSLOG_FAILURE -DSYSLOG_NON_ROOT -O2 -MT getcwd.o -MD -MP
-MF ".deps/getcwd.Tpo" \
-c -o getcwd.o `test -f 'getcwd.c' || echo './'`getcwd.c; \
then mv ".deps/getcwd.Tpo" ".deps/getcwd.Po"; \
else rm -f ".deps/getcwd.Tpo"; exit 1; \
fi
getcwd.c: In function `rpl_getcwd':
getcwd.c:59: warning: initialization makes pointer from integer without a cast

(see http://buildd.debian.org/build.php?arch=ia64&pkg=coreutils&ver=4.5.9-1)

The warning above is cause by getcwd being defined as rpl_getcwd so we never
get a proper prototype for getcwd. Missing the prototype causes SIGSEGV
during the test suite:

| > 8589934592big
| FAIL: 8gb
| ./basic: line 35: 22418 Segmentation fault du -a a >out
| ./basic: line 37: 22419 Segmentation fault du -aS a >>out
| ./basic: line 39: 22420 Segmentation fault du -s a >>out

The solution this patch presents is to undefine getcwd twice, once before
getting the prototype for getcwd, and once after we are finished including
config.h (maybe a better solution is to prevent config.h from being included
multiple times, but maybe there is a reason to include it multiple times?).
The patch also includes the unistd.h header for good measure. Note that
including the header is not sufficient to prevent the SIGSEGV.


-David


--- coreutils-4.5.9/lib/getcwd.c.orig Sun Mar 9 14:18:40 2003
+++ coreutils-4.5.9/lib/getcwd.c Sun Mar 9 14:19:26 2003
@@ -19,8 +19,13 @@

#include <config.h>

+/* Undefine getcwd here so any prototype is not redefined to be a
+ prototype for rpl_getcwd. */
+#undef getcwd
+
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>

#include <errno.h>
#ifndef errno
@@ -32,8 +37,9 @@
#include "pathmax.h"
#include "same.h"

-/* Undefine getcwd here so any prototype is not redefined to be a
- prototype for rpl_getcwd. */
+/* Undefine getcwd again since same.h includes config.h again (config.h
+ doesn't have macros to prevent multiple inclusion.) which in turn defines
+ getcwd to rpl_getcwd. We want to use the real getcwd below. */
#undef getcwd

/* Guess high, because that makes the test below more conservative.


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise