1
0
Fork 0
mirror of https://github.com/rubyjs/mini_racer synced 2023-03-27 23:21:28 -04:00
mini_racer/ext
Sam Saffron 12a8aa9d82
avoid memory leak on exceptions when running without GVL
rb_thread_call_without_gvl may raise exceptions and prevent free(3) from
firing.  Instead of relying on malloc(3) and free(3), rely on the Ruby
GC to recover memory on exceptions.

In most cases, alloca() is used and malloc/free are avoided entirely.
alloca(0) works with all compilers tested (clang 10..12, gcc 9.3), so
there's no need to create extra branches for the rare argc == 0 case.

RB_ALLOCV_N and RB_ALLOCV_END are documented in Ruby 3.1 public headers
(while functions those macros use internally are private).  They are
used by the standard 'etc', 'date', and 'openssl' C extensions and exist
in their current ("RB_"-prefixed) form since Ruby 2.3.  The non-prefixed
variants (ALLOCV_N, ALLOCV_END) have existed since Ruby 1.9.3.
2022-01-17 10:51:07 +11:00
..
mini_racer_extension avoid memory leak on exceptions when running without GVL 2022-01-17 10:51:07 +11:00
mini_racer_loader use CXXFLAGS for C++ compiler 2021-12-30 11:38:48 +11:00