kafl.fuzzer
kafl.fuzzer copied to clipboard
command startup delay, tracebacks on ctrl-c
The new merged entry via setup.py entrypoint causes ~100msec extra startup time and spams the console when aborting Ctrl-C. This is most visible when investigating files with mcat, e.g.:

Obviously we can add an option to better support this usage in mcat, but the basic problem is that we have a non-trivial loading time where Ctrl-C by user will lead to crazy stack dumps. Earliest option I found to catch the exception is here in main:
https://github.com/IntelLabs/kafl.fuzzer/blob/5a277a07a9f32e0019c1d2b809e375ed5e5c9f70/kafl_fuzzer/main.py#L12
However, even with that above mcat loop is still quite likely to be interrupted before main() and I could not find how to mute that.
Moving the imports into the try/except clause causes a new fancy exception from setup.py:

I also noticed that the new approach of setting the sub-handler in cmdline.py leads to recursively importing all project modules, even when just launching mcat or gui. I expect this causes much of the added startup latency: https://github.com/IntelLabs/kafl.fuzzer/blob/5a277a07a9f32e0019c1d2b809e375ed5e5c9f70/kafl_fuzzer/common/config/cmdline.py#L25
Another unfortunate side-effect (checking some workdir stats while rebuilding qemu)

The new merged entry via setup.py entrypoint causes ~100msec extra startup time
CPython initialization takes between 10 and 100msec as well.
A better performance fix for mcat subcommand would be for kafl mcat to process multiple input files at the same time.
but the basic problem is that we have a non-trivial loading time where Ctrl-C by user will lead to crazy stack dumps
We have no handling of the KeyboardInterrupt exception, this leads to Python dumping the stack for trivial issues such as sending CTRL-C to kafl.
This is an easy fix.
I also noticed that the new approach of setting the sub-handler in cmdline.py leads to recursively importing all project modules, even when just launching mcat or gui. I expect this causes much of the added startup latency:
Correct. But performance issues are not a big priority here, especially for the mcat utility. It would be easier to rework the command line and accept multiple files as input.