CBFalconer wrote:
Adriaan van Os wrote:
... snip ...
This only leaves the Mac OS X malloc bug, I will do some more malloc tests and report the results to Apple.
I have no idea what the OS X malloc bug is, but I have a malloc system available that only relies on the availability of the sbrk call to function, and assumes byte addressability. I believe it to be highly portable to unices. To inject into something I simply link it before the standard library. You can also have a herd of malloc system debugging abilities. Compiles with gcc, and uses gcc varargs macros. To try it out:
I have downloaded it and will give it a try.
(It specifically rejects a malloc request of about 2 Gb up)
I built it because the existing DJGPP malloc makes free and realloc O(N) operations where N is the number of free blocks. This in turn makes freeing a large group of blocks O(N*N). nmalloc changes O(N) to O(1) and ON*N) to O(N). The original became impossible in the 50 to 100k free blocks area. VC6 and LCC-Win32 have the same fault. It also reduces memory movement in realloc. I have had no problems over the past year with it, and a few others have been using it. We hope to get it into the next alpha of DJGPP 2.04.
O(N*N) is, of course, inacceptable. Memory allocation in the Win32 API, by the way, is astonishingly slow (which is why Delphi comes with a Runtime Library Memory Manager Unit).
CBFalconer wrote:
Adriaan van Os wrote:
... snip ...
TEST fjf31.pas: failed: 2, 2, 1
TEST pack1.pas: failed
TEST systemtest.pas: *** malloc: vm_allocate(size=2147483648) failed
Of course it did. malloc of that size would require a sbrk with a negative size (even though sbrk is specified to take an unsigned). That would reduce the heap space available, and create havoc.
Yeah, 2147483648 = $80000000 and possibly negative, but the original request in systemtest.pas was just below 2GiB. Probably malloc rounds it up to an integral number of pages.
(gdb) bt #0 $90006a34 in mig_get_reply_port () #1 $90008858 in vm_allocate () #2 $9000877c in allocate_pages () #3 $9001012c in large_and_huge_malloc () #4 $90004e98 in szone_malloc () #5 $90004a44 in malloc_zone_malloc () #6 $000036a0 in Bpgetmem (Size=2147483391) at /Developer/Pascal/gpc321d17/lib/gcc-lib/powerpc-apple-darwin6.4/3.2.1/ units/system.pas:546 #7 $000144a0 in _p_New (Size=2147483391) at /Users/adriaan/gnu/gpc-20030507-2/gcc/p/rts/heap.pas:237 #8 $000050b4 in Test () at systemtest.pas:41 #9 $00005280 in pascal_main_program () at systemtest.pas:63 #10 $00005344 in main (argc=1, argv=$bffffdd8, envp=$bffffde0) at <implicit code>:63 #11 $00002724 in _start (argc=1, argv=$bffffdd8, envp=$bffffde0) at /SourceCache/Csu/Csu-45/crt.c:267 #12 $000025a4 in start ()
Regards,
Adriaan van Os