-
Nikolay Shirokovskiy authored
As it breaks sane usage of region as a data stack: size_t region_svp = region_used(&fiber()->gc); /* some allocation on fiber gc and usage of allocated memory. */ region_truncate(&fiber()->gc, region_svp); If in the above snippet one calls a function that in turn calls `fiber_gc` then the snippet code may have use-after-free and later UB on truncation. For this reason let's get read of fiber_gc. However we need to make sure we won't introduce leaks this way. So before actually removing fiber_gc we make it perform leak check instead and only after fixing all the leaks the fiber_gc was removed. In order to find the leak easily the backtrace of the first fiber gc allocation that is not truncated is saved and then reported. In order to catch leaks that are not triggered by the current test suit and to prevent introducing leaks in future patches the leak check is added on fiber exit/recycle and for long living system fibers on every loop iteration. Leak check in release build is on but without leak backtrace info by default for performance reasons. Backtrace can be provided by using `fiber.leak_backtrace_enable()` knob before starting leaking fiber. Regularly leaks are only reported in log but it will not help to catch errors when running test suits so build option ABORT_ON_LEAK is added. When it is on we abort on leak. This option is turned off for all builds that used in CI. Closes #5665 NO_CHANGELOG=internal NO_DOC=internal
Nikolay Shirokovskiy authoredAs it breaks sane usage of region as a data stack: size_t region_svp = region_used(&fiber()->gc); /* some allocation on fiber gc and usage of allocated memory. */ region_truncate(&fiber()->gc, region_svp); If in the above snippet one calls a function that in turn calls `fiber_gc` then the snippet code may have use-after-free and later UB on truncation. For this reason let's get read of fiber_gc. However we need to make sure we won't introduce leaks this way. So before actually removing fiber_gc we make it perform leak check instead and only after fixing all the leaks the fiber_gc was removed. In order to find the leak easily the backtrace of the first fiber gc allocation that is not truncated is saved and then reported. In order to catch leaks that are not triggered by the current test suit and to prevent introducing leaks in future patches the leak check is added on fiber exit/recycle and for long living system fibers on every loop iteration. Leak check in release build is on but without leak backtrace info by default for performance reasons. Backtrace can be provided by using `fiber.leak_backtrace_enable()` knob before starting leaking fiber. Regularly leaks are only reported in log but it will not help to catch errors when running test suits so build option ABORT_ON_LEAK is added. When it is on we abort on leak. This option is turned off for all builds that used in CI. Closes #5665 NO_CHANGELOG=internal NO_DOC=internal