Make CPython segfault in 5 lines of code
gist.github.com
Make CPython segfault in 5 lines of code
1–10 of 78 posts
Re: Make CPython segfault in 5 lines of code
#2Re: Make CPython segfault in 5 lines of code
#3Re: Make CPython segfault in 5 lines of code
#4A quick search in bugs.python.org shows several crashes. I don’t know much about Python. Is there anything particularly special about this one?
Re: Make CPython segfault in 5 lines of code
#5A quick search in bugs.python.org shows several crashes. I don’t know much about Python. Is there anything particularly special about this one?
Re: Make CPython segfault in 5 lines of code
#6A quick search in bugs.python.org shows several crashes. I don’t know much about Python. Is there anything particularly special about this one?
import sys, threading
def r():
sys.stdin.buffer.read(1)
t = threading.Thread(target=r, daemon=True)
t.start()Re: Make CPython segfault in 5 lines of code
#7One I ran into in the wild recently is that in older versions of Lua, exceptions in GC finalizers (the `__gc` metamethod) can trigger a segfault. In those same versions of Lua, the bytecode format is notoriously dangerous to load.
I wonder whether this will be a large component of newer scripting language implementations. Do these safety issues warrant use of memory safe languages like Rust, or use of existing sandboxed VM implementations like WebAssembly?
Re: Make CPython segfault in 5 lines of code
#8A quick search in bugs.python.org shows several crashes. I don’t know much about Python. Is there anything particularly special about this one?
Just for fun, here's another one: import sys, threading def r(): sys.stdin.buffer.read(1) t = threading.Thread(target=r, daemon=True) t.start()
Re: Make CPython segfault in 5 lines of code
#9Segfaults in scripting languages are remarkably common, especially if arbitrary bytecode can be loaded into the VM. One I ran into in the wild recently is that in older versions of Lua, exceptions in GC finalizers (the `__gc` metamethod) can trigger a segfault. In those same versions of Lua, the bytecode format is notoriously dangerous to load. I wonder whether this will be a large component of newer scripting langua…
It's a plausible approach to a fully-safe, near-native-speed plugin architecture.
Re: Make CPython segfault in 5 lines of code
#10A quick search in bugs.python.org shows several crashes. I don’t know much about Python. Is there anything particularly special about this one?
Just for fun, here's another one: import sys, threading def r(): sys.stdin.buffer.read(1) t = threading.Thread(target=r, daemon=True) t.start()
import sys, threading, time
t = threading.Thread(target=sys.stdin.read, args=(1,))
t.start()
time.sleep(1)
sys.stdin.close()
Run it then after a few seconds press enter. It doesn't segfault in Python 3, but it still doesn't behave how I'd like, because I would like the close() to unblock the read(), but it doesn't unblock the read(), the read() still hangs until it gets some input.