2 ms·
> Could not figure out how to trigger a malloc failure inside of a imported library Glibc has (or at least has had) special (unsupported) instrumentation that
by nullc 6y ago
> Could not figure out how to trigger a malloc failure inside of a imported library
Glibc has (or at least has had) special (unsupported) instrumentation that lets you substitute out the libc malloc at runtime with another function.
You can use this to shim in a version that fails after a specific number of executions in order to inject malloc faults.
E.g. https://github.com/xiph/opus/blob/master/tests/test_opus_api.c#L1751 https://github.com/xiph/opus/blob/master/tests/test_opus_api...
- dalke 6y agoI considered using a shim, but couldn't figure out which malloc comes from my UDF and which comes from MySQL, and I was highly doubtful that MySQL would have identical numbers of malloc by the time my code runs.