[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
malloc problem on ix86/darwin
From: |
Jasper Taylor |
Subject: |
malloc problem on ix86/darwin |
Date: |
Mon, 16 Apr 2007 13:33:04 +0100 |
Hello all,
I am using c code to add a structured database to my gprolog
application. This code calls malloc() to extend the database when
needed. It works OK under Linux (32- and 64-bit) and Windows but I am
having problems under MacOS.
What happens is it works OK to start with but when the database
reaches a certain size I get "child killed: bus error". Looking
through the archives I saw that there are occasionally problems with
the bits used in the addresses returned by malloc, so I added a
wrapper that kept a mask of all bits so far used in malloced
addresses and printed out whenever there were new ones. Here's the
code for anyone interested:
long usedBits = NULL;
void* safe_malloc(count) {
long ptr;
ptr = (long)malloc(count);
if (ptr & ~usedBits) {
usedBits = usedBits|ptr;
printf("debug_c malloc uses new bits, mask now %lx\n", usedBits);
}
return (void*)ptr;
}
What happened was interesting: as long as everything was working
properly, the mask of used bits was stable at 0x017ffff0. But every
bus error was preceded by the mask growing to 0x117ffff0, i.e., the
first time bit 28 is used, even though bits 27-25 and 23 are still so
far unused. This is MacOS 10.4.9 with gcc 4.0.1 and gprolog 1.3.1
Is it possible that I should be using some alternative to malloc(),
provided in gprolog.h? I can't find any reference to such a
requirement in the documentation.
Any help very much appreciated!
--Jasper
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- malloc problem on ix86/darwin,
Jasper Taylor <=