<div dir="auto"><div>I'm not a core Python Dev, but quick question, why would you expect "<span style="font-family:sans-serif;font-size:12.8px">fractions.Fraction("1.64E66464</span><span style="font-family:sans-serif;font-size:12.8px">66664")" not to take 100s of megabytes and hours to run?</span><div dir="auto"><br></div>Simply evaluating: 164 * 10**<span style="font-family:sans-serif;font-size:12.8px">66464</span><span style="font-family:sans-serif;font-size:12.8px">6666 will take hundreds of megabytes by definition.</span></div><div dir="auto"><span style="font-family:sans-serif;font-size:12.8px"><br></span></div><div dir="auto"><span style="font-family:sans-serif;font-size:12.8px">Regards</span></div><div dir="auto"><span style="font-family:sans-serif;font-size:12.8px">Damian</span></div><div dir="auto"><br></div><div dir="auto"><br><div class="gmail_quote" dir="auto"><div dir="ltr">On Tue, Jul 17, 2018, 12:54 Jussi Judin <<a href="mailto:jjudin%2Bpython@iki.fi">jjudin+python@iki.fi</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I have been fuzzing[1] various parts of Python standard library for Python 3.7 with python-afl[2] to find out internal implementation issues that exist in the library. What I have been looking for are mainly following:<br>
<br>
* Exceptions that are something else than the documented ones. These usually indicate an internal implementation issue. For example one would not expect an UnicodeDecodeError from netrc.netrc() function when the documentation[3] promises netrc.NetrcParseError and there is no way to pass properly sanitized file object to the netrc.netrc().<br>
* Differences between values returned by C and Python versions of some functions. quopri module may have these.<br>
* Unexpected performance and memory allocation issues. These can be somewhat controversial to fix, if at all, but at least in some cases from end-user perspective it can be really nasty if for example fractions.Fraction("1.64E6646466664") results in hundreds of megabytes of memory allocated and takes very long to calculate. I gave up waiting for that function call to finish after 5 minutes.<br>
<br>
As this is going to result in a decent amount of bug reports (currently I only filed one[4], although that audio processing area has much more issues to file), I would like to ask your opinion on filing these bug reports. Should I report all issues regarding some specific module in one bug report, or try to further split them into more fine grained reports that may be related? These different types of errors are specifically noticeable in zipfile module that includes a lot of different exception and behavioral types on invalid data <<a href="https://github.com/Barro/python-stdlib-fuzzers/tree/master/zipfile/crashes" rel="noreferrer noreferrer" target="_blank">https://github.com/Barro/python-stdlib-fuzzers/tree/master/zipfile/crashes</a>> . And in case of sndhdr module, there are multiple modules with issues (aifc, sunau, wave) that then show up also in sndhdr when they are used. Or are some of you willing to go through the crashes that pop up and help with the report filing?<br>
<br>
The code and more verbose description for this is available from <<a href="https://github.com/Barro/python-stdlib-fuzzers" rel="noreferrer noreferrer" target="_blank">https://github.com/Barro/python-stdlib-fuzzers</a>>. It works by default on some GNU/Linux systems only (I use Debian testing), as it relies on /dev/shm/ being available and uses shell scripts as wrappers that rely on various tools that may not be installed on all systems by default.<br>
<br>
As a bonus, as this uses coverage based fuzzing, it also opens up the possibility of automatically creating a regression test suite for each of the fuzzed modules to ensure that the existing functionality (input files under <fuzz-target>/corpus/ directory) does not suddenly result in additional exceptions and that it is more easy to test potential bug fixes (crash inducing files under <fuzz-target>/crashes/ directory).<br>
<br>
As a downside, this uses two quite specific tools (afl, python-afl) that have further dependencies (Cython) inside them, I doubt the viability of integrating this type of testing as part of normal Python verification process. As a difference to libFuzzer based fuzzing that is already integrated in Python[5], this instruments the actual (and only the) Python code and not the actions that the interpreter does in the background. So this should result in better fuzzer coverage for Python code that is used with the downside that when C functions are called, they are complete black boxes to the fuzzer.<br>
<br>
I have mainly run these fuzzer instances at most for several hours per module with 4 instances and stopped running no-issue modules after there have been no new coverage discovered after more than 10 minutes. Also I have not really created high quality initial input files, so I wouldn't be surprised if there are more issues lurking around that could be found with throwing more CPU and higher quality fuzzers at the problem.<br>
<br>
[1]: <a href="https://en.wikipedia.org/wiki/Fuzzing" rel="noreferrer noreferrer" target="_blank">https://en.wikipedia.org/wiki/Fuzzing</a><br>
[2]: <a href="https://github.com/jwilk/python-afl" rel="noreferrer noreferrer" target="_blank">https://github.com/jwilk/python-afl</a><br>
[3]: <a href="https://docs.python.org/3/library/netrc.html" rel="noreferrer noreferrer" target="_blank">https://docs.python.org/3/library/netrc.html</a><br>
[4]: <a href="https://bugs.python.org/issue34088" rel="noreferrer noreferrer" target="_blank">https://bugs.python.org/issue34088</a><br>
[5]: <a href="https://github.com/python/cpython/tree/3.7/Modules/_xxtestfuzz" rel="noreferrer noreferrer" target="_blank">https://github.com/python/cpython/tree/3.7/Modules/_xxtestfuzz</a><br>
<br>
-- <br>
Jussi Judin<br>
<a href="https://jjudin.iki.fi/" rel="noreferrer noreferrer" target="_blank">https://jjudin.iki.fi/</a><br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank" rel="noreferrer">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/damian.peter.shaw%40gmail.com" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/damian.peter.shaw%40gmail.com</a><br>
</blockquote></div></div></div>