Re:Make CPython segfault in 5 lines of code
by paulddraper on Wednesday December 18, 2019 @11:25PM
(#21831998)
If # of lines are important, this problem can actually be demonstrated in 1 line:
[ Parent
| on HN ]
Re:Make CPython segfault in 5 lines of code
by filmor on Thursday December 19, 2019 @01:42AM
(#21832562)
This doesn't trigger a segfault for me in Python 3.7, just an exception that `print_exception` expects an `Exception`.
Someone commented below the gist with this one-liner:
(i for i in []).throw(type('E', (BaseException,), dict(__new__=lambda cls, *args: cls))())
I managed to golf it a bit down to this ;): n="__new__";(i for i in []).throw(type(n,(IOError,),{n:lambda c,*a:c})())
Re:Make CPython segfault in 5 lines of code
by ehsankia on Thursday December 19, 2019 @01:51AM
(#21832622)
Just one character but replace `[]` with `n` too :)
Re:Make CPython segfault in 5 lines of code
by chrismorgan on Thursday December 19, 2019 @07:13AM
(#21834192)
Or save that character by removing the space before `[]` instead (which you can’t do if you write `n`).
Re:Make CPython segfault in 5 lines of code
by paulddraper on Thursday December 19, 2019 @07:26AM
(#21834268)
Mine produces segfault with
$ python3.7 -VV
Python 3.7.5 (default, Nov 7 2019, 10:50:52)
[GCC 8.3.0]
Some more golfing with yours: (i for i in[]).throw(type('',(IOError,),{'__new__':lambda a,*b:a}))