[MLton] osx compiles again in x86_64 branch
Wesley W. Terpstra
wesley@terpstra.ca
Wed, 24 May 2006 01:02:44 +0200
On May 24, 2006, at 12:44 AM, Wesley W. Terpstra wrote:
> Things start going wrong after an attempt to remapHeap fails
> (because on osx HAS_REMAP is FALSE).
void *GC_mremap (void *start, size_t oldLength, size_t newLength) {
void *out;
size_t smallest;
if (oldLength < newLength)
smallest = oldLength;
else smallest = newLength;
out = mmap (0, newLength, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
memcpy (out, start, smallest);
munmap (start, oldLength);
return out;
}
ottawa:~/src/mlton/mlton.x86_64/mllex terpstra$ ./mllex
no files
Usage: mllex file.lex ...
ottawa:~/src/mlton/mlton.x86_64/mllex terpstra$
Tada!
Anyways, it's definitely the code-path which works around a missing
mremap, as I hope I've just demonstrated. So set HAS_REMAP FALSE on
linux, and I bet you'll get exactly the same problem. For whatever
reason, the stack is pointing into the region which gets freed by the
first use in growHeap. I imagine that either you're freeing the wrong
heap, or you didn't update the stack pointer to the new heap after
the move.
(It later crashes when trying to access the address which got freed)