View Issue Details

IDProjectCategoryView StatusLast Update
0000424LDMud 3.3Compilation, Installationpublic2007-10-06 20:01
Reporterford Assigned To 
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Product Version3.3.712 
Fixed in Version3.3.714 
Summary0000424: Segmentation fault whilst compiling
DescriptionI am trying to compile under
"Debian GNU/Linux 3.1 r0a "Sarge" - Official powerpc".
I have done this many times under i386 Debian.

arron@g3:~/ldmud-3.3.712/src$ sh settings/heaven7
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
For this test, '-g' instead of '-g -O2' is used as compiler flags.
checking gcc/assembler float/branch incompatibility, e.g. on AIX... no
checking for a BSD-compatible install... /usr/bin/install -c
checking for byacc... byacc
checking how to run the C preprocessor... gcc -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking sys/rusage.h usability... no
checking sys/rusage.h presence... no
checking for sys/rusage.h... no
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for stdlib.h... (cached) yes
checking libc.h usability... no
checking libc.h presence... no
checking for libc.h... no
checking for memory.h... (cached) yes
checking values.h usability... yes
checking values.h presence... yes
checking for values.h... yes
checking for string.h... (cached) yes
checking bstring.h usability... no
checking bstring.h presence... no
checking for bstring.h... no
checking netdb.h usability... yes
checking netdb.h presence... yes
checking for netdb.h... yes
checking crypt.h usability... yes
checking crypt.h presence... yes
checking for crypt.h... yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking sys/termios.h usability... yes
checking sys/termios.h presence... yes
checking for sys/termios.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking for char *... yes
checking size of char *... 4
checking for int... yes
checking size of int... 4
checking for short... yes
checking size of short... 2
checking for long... yes
checking size of long... 4
checking for needed malloc() alignment... 8
checking for uint32_t and friends... no
checking for ssize_t... yes
checking for long long... yes
checking size of long long... 8
checking for bool... no
checking for inline... inline
checking for size_t... yes
checking for pid_t... yes
checking return type of signal handlers... void
checking for main in -lm... yes
checking for main in -lsocket... no
checking for main in -lnsl... yes
checking for main in -lucb... no
checking if -lresolv is needed... no
checking for working alloca.h... yes
checking for alloca... yes
checking for fchmod... yes
checking for getrusage... yes
checking for bzero... yes
checking for memset... yes
checking for memcpy... yes
checking for memmem... yes
checking for strdup... yes
checking for strcspn... yes
checking for strchr... yes
checking for strrchr... yes
checking for getcwd... yes
checking for memmove... yes
checking for sysconf... yes
checking for gettimeofday... yes
checking for wait3... yes
checking for waitpid... yes
checking for fcntl... yes
checking for getdomainname... yes
checking for poll... yes
checking for strtoul... yes
checking for trunc... yes
checking if inet_ntoa() ok... yes
checking for IPv6 support... yes
checking for OpenSSL support... no
checking for GnuTLS support... no
checking for pthreads support... yes
checking if -lpthread or similar is needed... yes
checking for main in -lpthread... yes
checking for pthread_atfork()... yes
checking for main in -lpcre... no
checking for broken iconv in glibc 2.0-2.2... no
checking for iconv... yes
checking if iconv takes a non-const char**... yes
checking if -liconv is needed... no
checking for mySQL... no
checking for PostgresSQL... no
checking if rename handles directories... yes
checking full availability of struct rusage members... yes
checking struct rusage timeval members with tv_usec... yes
checking if return type of free is void... yes
checking if void* or char* from malloc... void *
checking if CHAR_BIT == 8 or undef... yes
checking if strtol broken... no
checking nonblocking using ioctl with FIONBIO... yes
checking nonblocking using fcntl with O_NDELAY... yes
checking nonblocking using fcntl with FNDELAY... yes
checking if fcntl with SETOWN works... yes
checking if OOBINLINE works... yes
checking for overlapping bcopy... yes
checking if strtol needs const char*... yes
checking warning CFLAGS... -Wall -Wparentheses -Wshadow
checking low optimization CFLAGS... -O -g
checking medium optimization CFLAGS... -O2 -g -fstrength-reduce -fno-force-mem -fno-force-addr
checking highest optimization CFLAGS... -O4 -fomit-frame-pointer -g -fstrength-reduce -fno-force-mem -fno-force-addr
checking if byacc includes bogus malloc prototypes... no
checking for byacc / <malloc.h> / -DSGI_SOURCE / afree name clash... no
checking malloc redefinition with linking flag ... 100.000000% successful
checking malloc overhead... 4
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: creating util/Makefile
config.status: creating util/indent/Makefile
config.status: creating util/xerq/Makefile
config.status: creating util/erq/Makefile
config.status: creating machine.h
config.status: machine.h is unchanged
arron@g3:~/ldmud-3.3.712/src$ make
./mk-patchlevel.sh
gcc -O2 -g -fstrength-reduce -fno-force-mem -fno-force-addr -Wall -Wparentheses -Wshadow -DMUD_LIB='"/heaven7/lib"' -DBINDIR='"/heaven7/bin"' -DERQ_DIR='"/heaven7/libexec"' -c -o access_check.o access_check.c
gcc -O2 -g -fstrength-reduce -fno-force-mem -fno-force-addr -Wall -Wparentheses -Wshadow -DMUD_LIB='"/heaven7/lib"' -DBINDIR='"/heaven7/bin"' -DERQ_DIR='"/heaven7/libexec"' -c -o mkfunc.o mkfunc.c
gcc -O2 -g -fstrength-reduce -fno-force-mem -fno-force-addr mkfunc.o hash.o -o mkfunc
rm -f stdstrings.c
rm -f stdstrings.h
./mkfunc strings
gcc -O2 -g -fstrength-reduce -fno-force-mem -fno-force-addr -Wall -Wparentheses -Wshadow -DMUD_LIB='"/heaven7/lib"' -DBINDIR='"/heaven7/bin"' -DERQ_DIR='"/heaven7/libexec"' -c -o actions.o actions.c
gcc -O2 -g -fstrength-reduce -fno-force-mem -fno-force-addr -Wall -Wparentheses -Wshadow -DMUD_LIB='"/heaven7/lib"' -DBINDIR='"/heaven7/bin"' -DERQ_DIR='"/heaven7/libexec"' -c -o array.o array.c
gcc -O2 -g -fstrength-reduce -fno-force-mem -fno-force-addr -Wall -Wparentheses -Wshadow -DMUD_LIB='"/heaven7/lib"' -DBINDIR='"/heaven7/bin"' -DERQ_DIR='"/heaven7/libexec"' -c -o backend.o backend.c
gcc -O2 -g -fstrength-reduce -fno-force-mem -fno-force-addr -Wall -Wparentheses -Wshadow -DMUD_LIB='"/heaven7/lib"' -DBINDIR='"/heaven7/bin"' -DERQ_DIR='"/heaven7/libexec"' -c -o bitstrings.o bitstrings.c
gcc -O2 -g -fstrength-reduce -fno-force-mem -fno-force-addr -Wall -Wparentheses -Wshadow -DMUD_LIB='"/heaven7/lib"' -DBINDIR='"/heaven7/bin"' -DERQ_DIR='"/heaven7/libexec"' -c -o call_out.o call_out.c
rm -f instrs.h
rm -f efun_defs.c
./mkfunc instrs
make: *** [instrs.h] Segmentation fault
arron@g3:~/ldmud-3.3.712/src$

TagsNo tags attached.
Attached Files
ldmud-3.3.713-joyr.patch (470 bytes)   
# To apply, do something like:
# cd ldmud-3.3.713
# patch -Np1 < ldmud-3.3.713-joyr.patch
diff -Naur ldmud-3.3.713/src/make_func.y ldmud-3.3.713-modified/src/make_func.y
--- ldmud-3.3.713/src/make_func.y	2006-03-12 20:54:37.000000000 +0000
+++ ldmud-3.3.713-modified/src/make_func.y	2006-07-05 07:11:25.000000000 +0000
@@ -2844,7 +2844,7 @@
 
 {
     int i, j, k;
-    char c;
+    unsigned char c;
     char * pattern;
 
     if ((fpw = fopen(EFUN_DEFS, "w")) == NULL)
ldmud-3.3.713-joyr.patch (470 bytes)   

Activities

lars

2005-12-04 02:34

reporter   ~0000439

That's a new one. Can you set it up so that the mkfunc call creates a coredump, or execute the mkfunc program from inside a debugger so that we can see where it exactly it dies?

ford

2005-12-07 02:26

reporter   ~0000448

g3:/home/arron/ldmud-3.3.712/src# make
./mk-patchlevel.sh
rm -f instrs.h
rm -f efun_defs.c
./mkfunc instrs
make: *** [instrs.h] Segmentation fault
g3:/home/arron/ldmud-3.3.712/src# gdb ./mkfunc
GNU gdb 6.3-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "powerpc-linux"...Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) run instrs
Starting program: /home/arron/ldmud-3.3.712/src/mkfunc instrs

Program received signal SIGSEGV, Segmentation fault.
0x0feed154 in vfprintf () from /lib/libc.so.6
(gdb)

ford

2005-12-07 02:44

reporter   ~0000449

I tried uploading /home/arron/ldmud-3.3.712/src/core.gz, i got:

APPLICATION ERROR #15

File upload failed. PHP file uploads may be disabled. Please ask your admin to run the admin_check script to debug this problem.

Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.

lars

2005-12-08 00:18

reporter   ~0000450

What does the full backtrace ('bt') in gdb print?

ford

2005-12-11 03:11

reporter   ~0000451

arron@g3:~/ldmud-3.3.712/src$ make
./mk-patchlevel.sh
rm -f instrs.h
rm -f efun_defs.c
./mkfunc instrs
make: *** [instrs.h] Segmentation fault
arron@g3:~/ldmud-3.3.712/src$ gdb ./mkfunc
GNU gdb 6.3-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "powerpc-linux"...Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) run instrs
Starting program: /home/arron/ldmud-3.3.712/src/mkfunc instrs

Program received signal SIGSEGV, Segmentation fault.
0x0feed154 in vfprintf () from /lib/libc.so.6
(gdb) bt
#0 0x0feed154 in vfprintf () from /lib/libc.so.6
0000001 0x0fef57f4 in fprintf () from /lib/libc.so.6
0000002 0x10004c70 in read_func_spec () at make_func.y:2741
0000003 0x1000629c in main (argc=0, argv=0x1000731c) at make_func.y:3484
(gdb)

ford

2005-12-11 04:16

reporter   ~0000452

arron@g3:~/ldmud-3.3.712/src$ gcc -v
Reading specs from /usr/lib/gcc-lib/powerpc-linux/3.3.5/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --enable-__cxa_atexit --with-system-zlib --enable-nls --without-included-gettext --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc --disable-multilib powerpc-linux
Thread model: posix
gcc version 3.3.5 (Debian 1:3.3.5-13)
arron@g3:~/ldmud-3.3.712/src$

ford

2005-12-11 05:52

reporter   ~0000453

After reading the comments in make_func.y line 2756, I tried the following, which seems to work.

sh settings/heaven7 --with-optimize=low
make

Seems gcc version 3.3.5 (Debian 1:3.3.5-13) powerpc is a little buggy :-)

ford

2005-12-11 07:40

reporter   ~0000454

Last edited: 2005-12-11 08:38

Once ldmud compiled successfully ldmud segfaults on "ldmud --options". Using gdb & backtrace, i found the malloc routines were involved. It seems slaballoc & smalloc are not compatible with my system, ptmalloc seems to work fine.

I would suggest making ptmalloc & opt=low the default for linux/powerpc systems.

lars

2005-12-11 18:20

reporter   ~0000455

Thanks for localizing the crash. There are two things I'd like you to try for me (given that I'm not running Linux):

- In make_func.y, separate the printf() statement before line 2756 into multiple ones (one for each line of output), and see if that still crashes under high optimization.
- When configuring the driver, add the option --enable-malloc-sbrk=no and see if that works with slaballoc/smalloc. If not, I might need a backtrace of the crash in the allocator (under low/no optimization).

ford

2005-12-12 03:50

reporter   ~0000456

--enable-malloc-sbrk=no fixes the problem with slaballoc/smalloc.

ford

2005-12-12 05:52

reporter   ~0000457

Interestingly enough, it only crashes on med optimisation, no, low, & high all work.

i broke the code up to :

    fprintf(stderr,
"Primary codes: %3d\n"
           , num_instr[C_CODE]
        );

    fprintf(stderr,
"Primary efuns: %3d\n"
           , num_instr[C_EFUN]
        );

    fprintf(stderr,
"Tabled efuns: %3d (%d + %d + %d + %d + %d)\n"
           , num_instr[C_EFUN0]+num_instr[C_EFUN1]+num_instr[C_EFUN2]
                               +num_instr[C_EFUN3]+num_instr[C_EFUN4]
           , num_instr[C_EFUN0], num_instr[C_EFUN1], num_instr[C_EFUN2]
           , num_instr[C_EFUN3], num_instr[C_EFUN4]
        );


It still crashes on medium.

lars

2005-12-12 18:58

reporter   ~0000458

"--enable-malloc-sbrk=no fixes the problem with slaballoc/smalloc." - Seems that I need to disable it in general for PPC architectures.

As for the crasher, there isn't much my configure script can test for. What could be done (in general) is to take the MED_OPTIMIZE options and one by one remove them from the compilation until mkfunc no longer crashes. That information might be useful for the GCC maintainers.

joyr

2006-07-05 00:30

reporter   ~0000511

Last edited: 2006-07-05 00:37

This happens to me too with 3.3.713 on Fedora Core 5.

The problem seems to be in the way the 'char c' is used, IIRC it's undefined behaviour to increment 'signed char' past the max ('char' is signed on my system). So I changed the 'char c' variable to unsigned one and the results were good, efun_defs.c looked exactly the same as with no optimizations.

I'll upload a patch for that.

Edit: This was/is on i386, not PPC.

joyr

2006-07-10 20:50

reporter   ~0000512

Fixed/works (no crashing) in 3.3.714.

Issue History

Date Modified Username Field Change
2005-12-04 00:30 ford New Issue
2005-12-04 02:34 lars Note Added: 0000439
2005-12-07 02:26 ford Note Added: 0000448
2005-12-07 02:44 ford Note Added: 0000449
2005-12-08 00:18 lars Note Added: 0000450
2005-12-11 03:11 ford Note Added: 0000451
2005-12-11 04:16 ford Note Added: 0000452
2005-12-11 05:52 ford Note Added: 0000453
2005-12-11 07:40 ford Note Added: 0000454
2005-12-11 08:38 ford Note Edited: 0000454
2005-12-11 18:20 lars Note Added: 0000455
2005-12-12 03:50 ford Note Added: 0000456
2005-12-12 05:52 ford Note Added: 0000457
2005-12-12 18:58 lars Note Added: 0000458
2006-07-05 00:30 joyr Note Added: 0000511
2006-07-05 00:35 joyr File Added: ldmud-3.3.713-joyr.patch
2006-07-05 00:37 joyr Note Edited: 0000511
2006-07-10 20:50 joyr Note Added: 0000512
2007-10-06 20:01 lars Status new => closed
2007-10-06 20:01 lars Resolution open => fixed
2007-10-06 20:01 lars Fixed in Version => 3.3.714