This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients bob.ippolito, ezio.melotti, rhettinger, serhiy.storchaka
Date 2017-05-03.06:41:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1493793710.25.0.994343860918.issue30243@psf.upfronthosting.co.za>
In-reply-to
Content
It is possible to get a core dump by using uninitialized _json objects.

$ ./python -c "import _json; _json.make_scanner.__new__(_json.make_scanner)('', 0)"
Segmentation fault (core dumped)
$ ./python -c "import _json; _json.make_encoder.__new__(_json.make_encoder)([0], 0)"
Segmentation fault (core dumped)

The cause is that make_scanner and make_encoder classes implement __new__ and __init__. The __new__ methods create uninitialized object, with NULLs pointers, the __init__ methods initialize them. Possible solutions are: 1) set fields to Py_None rather than NULL in __new__; 2) check every pointer for NULL before using; 3) just remove __init__ methods and make initialization in __new__ methods. Since the scanner and the encoder are not inheritable classes, the latter solution look the most preferable to me.
History
Date User Action Args
2017-05-03 06:41:50serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, bob.ippolito, ezio.melotti
2017-05-03 06:41:50serhiy.storchakasetmessageid: <1493793710.25.0.994343860918.issue30243@psf.upfronthosting.co.za>
2017-05-03 06:41:50serhiy.storchakalinkissue30243 messages
2017-05-03 06:41:49serhiy.storchakacreate