yes there new engine used a local variable of 756 kbyte of the stack.
This is used for all of the computational geometry stuff (convex hull calculation and optimizer and other things)
This is absolute necessary for multithreading, each function must be practically re entrant, and before I was using the solve memory pool for that kind of things. But there was causing old kind of hard to track bug does to memory been trump by a call back calling some collision function or creation and objects or thing like that.
The problem is that now the engine trust that the stack space will be at least that long, in MSV the stack is ground incrementally on demand, for that the compiler issue some dead code at the beginning of each function that is using more than 4k bytes of local variable.
While reading the documentation on Visual Studio 8 I learned that this option called stack probe could be compiled out and I found out that this could be done in VS 2003 from the command line
The problem is that if a function try to assess none committed stack it will crash.
I could be that in Pascal the stack is not committed and that is why are crashes in the DLL.
You could do few thing.
- see if you can coming stack space (ugly but it may work)
- create a dummy functon that will commint the stack by creating a local variable of 800k and callong menset. (also ugly)
- If that dopes not work send me a demo for me to test and see when is the best pace to coming the stack from the dll internally.
I do not really understand what is the goal of Microsoft of allocating 1 mega Byte by default of stack fro each program, and yet the stack is not committed and they commite it 4 k at a time but calling and expensive function and adding that to each function of a program. (another of those solution in search of a problem).
Why not commit the stack at the beginning f the CRT?
in you sample try this
- Code: Select all
void stackProbe()
{
char pool[756* 1024]
memset(pool, 0, sizeof pool)
}
stackProbe()
NewtonAllocMemory = procedure (sizeInBytes: integer ); cdecl;
PNewtonAllocMemory = ^NewtonAllocMemory;
NewtonFreeMemory = procedure (ptr: Pointer; sizeInBytes: integer ); cdecl;
PNewtonFreeMemory = ^NewtonFreeMemory;
function NewtonCreate (malloc: PNewtonAllocMemory; mfree: PNewtonFreeMemory): PNewtonWorld; cdecl; external newtondll;
NWorld := NewtonCreate(nil, nil);