[ODE] Segfaulting ODE with too many objects -- ALLOC vs MALLOC

Kyle Hubert khubert at gmail.com
Thu Sep 28 00:10:49 MST 2006

On 9/26/06, Kyle Hubert <khubert at gmail.com> wrote:
> Is there a definable upper bound to the number of objects ODE can
> handle at one time? I seem to have the ability to run a simulation
> fine with N number of Geoms, but at N+1 the simulation segfaults with
> the error seen below.

OK, so it appears that for dWorldQuickStep it calls SOR_LCP on line
340 in quickstep.cpp for release 0.7. This function uses alloca to
find room for all the dReals and the IndexError structs. In my
particular case, there isn't enough room on the stack, since I'm
constrained to cygwin/Windows ulimit won't let me bump my stack.
Anyways, this brings me to a curious question.

Why is everything on the stack? Is this to avoid having to keep track
of frees? I replaced the allocas with malloc/frees and everything
worked. Now I can have a lot more objects. Is this beneficial to
anyone else? I understand there would be a few more clock ticks of
overhead for the malloc function as well as free, but using the stack
is a little limiting.

If I do change the behavior would anyone else appreciate this? I can
use a preallocated pool or even a freelist/realloc. Any of the old
tricks from the book, anything but just a stack allocation.

With malloc/free we can even give concise errors that we are out of
heap and return, rather than segfaulting.

Yes? Anybody?


More information about the ODE mailing list