[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

boehm-gc broken on -current i386?



just wondering if boehm-gc is broken on i386-current? has it ever
actually worked? i'm still rummaging around in cfsd looking for
trouble, and boehm-gc keeps coring on me the first time i use malloc.
a trivial example follows.

also, setting GC_find_leak=0 and compiling with -fno-stack-protector
seem to have no useful effect.

suggestions?

desdemona:ttyp4# cat test.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#ifndef DEBUG
#define DEBUG 0
#endif

#if DEBUG
#include <gc.h>
#define malloc(x) GC_MALLOC(x)
#define free(x) GC_FREE(x)
#endif

int leakmem(int n){
	char *p;

	p = malloc((size_t)n);
	if (p == NULL)
		return -1;
	else {
		printf("[leakmem] *p = %08x\n", p);
		return n;
	}
}

int main(){
	char *p;

#if DEBUG
	extern int GC_find_leak;
	GC_find_leak = 1;
#endif

	p = malloc(16 * 1024 * 1024);
	if (p != NULL)
		printf("[main] *p = %08x\n", p);

	leakmem(16 * 1024 * 1024);
}
desdemona:ttyp4# gcc -g -I/usr/local/include -L/usr/local/lib -lgc -o test test.c
desdemona:ttyp4# ./test
[main] *p = 40007000
[leakmem] *p = 41017000
desdemona:ttyp4# gcc -g -I/usr/local/include -L/usr/local/lib -lgc -o test test.c -DDEBUG=1
desdemona:ttyp4# ./test
Segmentation fault (core dumped)
desdemona:ttyp4# gdb ./test
GNU gdb 4.16.1
Copyright 1996 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 "i386-unknown-openbsd3.3"...
(gdb) r
Starting program: /tmp/./test

Program received signal SIGSEGV, Segmentation fault.
0x6001ae7d in GC_find_limit ()
(gdb) bt
#0  0x6001ae7d in GC_find_limit ()
#1  0x6001aca7 in GC_init_openbsd_elf ()
#2  0x6001a011 in GC_init_inner ()
#3  0x60016825 in GC_alloc_large ()
#4  0x60016b35 in GC_generic_malloc ()
#5  0x60016caf in GC_malloc ()
#6  0x1671 in main () at test.c:35
#7  0x1561 in ___start ()
#8  0x14d7 in __start ()
#9  0xcfbfd810 in ?? ()
Error accessing memory address 0x1: Invalid argument.
(gdb) b main
Breakpoint 1 at 0x165a: file test.c, line 32.
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /tmp/./test

Breakpoint 1, main () at test.c:32
32		GC_find_leak = 1;
(gdb) s
35		p = malloc(16 * 1024 * 1024);
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0x6001ae7d in GC_find_limit ()
(gdb) bt
#0  0x6001ae7d in GC_find_limit ()
#1  0x6001aca7 in GC_init_openbsd_elf ()
#2  0x6001a011 in GC_init_inner ()
#3  0x60016825 in GC_alloc_large ()
#4  0x60016b35 in GC_generic_malloc ()
#5  0x60016caf in GC_malloc ()
#6  0x1671 in main () at test.c:35
#7  0x1561 in ___start ()
#8  0x14d7 in __start ()
#9  0xcfbfd738 in ?? ()
Error accessing memory address 0x1: Invalid argument.
(gdb) quit
The program is running.  Quit anyway (and kill it)? (y or n) y

CK

-- 
Chris Kuethe, GCIA CISSP: Secure Systems Specialist - U of A CNS
      office: 157 General Services Bldg.    +1.780.492.8135
              chris_(_dot_)_kuethe_(_at_)_[pyxis_(_dot_)_cns_(_dot_)_]ualberta_(_dot_)_ca

     GDB has a 'break' feature; why doesn't it have 'fix' too?



Visit your host, monkey.org