If a rule arg typecheck failed we would leak argument values. This uses
RAII to track owenership instead of manual management to prevent
missing a free when an early exit exception is thrown for such failures.
This marks the last mem leak in the ASAN tests. And marks a clean ASAN
run for all tests.
Also fix double-free in property set create. This changes the object_free
calls to zero out the object pointer to prevent/catch double frees
and use-after-free issues. It also changes parse_free in the same way.
And adds a parse_ptr to scope manage the lifetime of PARSE
objects. Which fixes another mem leak in the parse_impl for
early abnormal exits.
If a function exits abnormally, for any reason, the passed in function
frame args would leak. This change captures such early exits and
cleans up the args for directly invoked functions. This clears up about
70% of current memory leaks.
In preparation to clean up the Jam function global stack move the
definition of the STACK and related functions inside the function.cpp
source file only.
Modern memory allocator is fast enough to not need our own
chained caching of specific data. Hence remove the use of caching
of free LIST instances to simplify memory management.
Also remove uses of exit/abort.
This replaces most abort/exit calls with the utility that throws an
exception. The exception is caught in main to cleanly return failure.
This allows to clean up allocations and always return a valid status
value instead of abnormal termination.
This changes the pointer type used everywhere for _targets/TARGETS to a
unique_ptr to manage the ownership correctly. Thus removing the memory
leaks resulting therein.