#50 Defining dUSE_MALLOC_FOR_ALLOCA causes leaks

general
closed
nobody
None
5
2014-02-04
2007-10-17
Mark Williams
No

Instances of ALLOCA in quickstep.cpp and collision_space.cpp do not have corresponding calls to UNALLOCA. This means that defining dUSE_MALLOC_FOR_ALLOCA will cause memory leaks.

Discussion

  • Remi Ricard
    Remi Ricard
    2008-02-25

    Logged In: YES
    user_id=145206
    Originator: NO

    Hi,

    A quick look in collision_space.cpp and quickstep.cpp I found that ALLOCA is a macro define in
    collision_space_internal.h or at the top of quickstep.cpp.

    define ALLOCA(x) dALLOCA16(x)

    and dALLOCA16 is found in common.h
    / alloca aligned to the EFFICIENT_ALIGNMENT. note that this can waste
    * up to 15 bytes per allocation, depending on what alloca() returns.
    /

    define dALLOCA16(n) \

    ((char*)dEFFICIENT_SIZE(((size_t)(alloca((n)+(EFFICIENT_ALIGNMENT-1))))))

    So there should be no problem in
    collision_space.cpp and quickstep.cpp

    N.B. The file step.cpp redefine ALLOCA to use malloc if #ifdef dUSE_MALLOC_FOR_ALLOCA
    is define so in that case there should be a free called (or the macro UNALLOCA)

    I don't see any bug in this. I think this bug could be closed.

    Remi

     
  • Mark Williams
    Mark Williams
    2008-02-27

    Logged In: YES
    user_id=1768899
    Originator: YES

    Apologies, I'd not traced through all the redefinitions of ALLOCA. I think a bug still stands, however, and that is that dUSE_MALLOC_FOR_ALLOCA does not behave as documented in all cases.

     
  • Oleh Derevenko
    Oleh Derevenko
    2009-12-06

    This is not issue any more as both ALLOCA and dUSE_MALLOC_FOR_ALLOCA have been removed from dWorldStep().

     
  • Oleh Derevenko
    Oleh Derevenko
    2009-12-06

    Well, the problem with collision_space.cpp still remains

     
  • Daniel K. O.
    Daniel K. O.
    2014-02-04

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,2 +1 @@
    -
     Instances of ALLOCA in quickstep.cpp and collision_space.cpp do not have corresponding calls to UNALLOCA. This means that defining dUSE_MALLOC_FOR_ALLOCA will cause memory leaks.
    
    • status: open --> closed
    • Group: --> general
     
  • Daniel K. O.
    Daniel K. O.
    2014-02-04

    This is probably outdated since Oleh changed all the allocation code.