microsoft / mimalloc

mimalloc is a compact general purpose allocator with excellent performance.
MIT License
9.74k stars 793 forks source link

Double free abort in secure mode #847

Closed katshup closed 4 months ago

katshup commented 5 months ago

In secure mode the library should be aborting on double free instead of swallowing the error. The idea being that you want to err on the side of caution instead of letting the program continue.

daanx commented 4 months ago

Thank you for the PR. However, the double free is not harmful so there is no real reason to abort. It is also better to modify the test in init.c,

#if (MI_SECURE>0)
  if (err==EFAULT) {  // abort on serious errors in secure mode (corrupted meta-data)
    abort();
  }
#endif

to include EAGAIN? Moreover, you can have custom behavior by registering your own error handler through mi_register_error to abort in all cases in secure mode. Hope that makes sense, best.