classification
Title: Segfault Via Resource Exhaustion
Type: Stage: resolved
Components: Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ned.deily, pabstersac
Priority: normal Keywords:

Created on 2016-07-17 06:02 by pabstersac, last changed 2016-07-17 06:29 by ned.deily. This issue is now closed.

Messages (2)
msg270611 - (view) Author: pablo sacristan (pabstersac) Date: 2016-07-17 06:02
The code is very simple:
import sys
sys.setrecursionlimit(1<<20)
test=lambda test:test(test)
test(test)

It basically works by changing the recursion limit and then starting an infinite recursion, this quickly gives a segfault.
This can be used to crash python.
msg270614 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-07-17 06:29
Sorry, the documentation for sys.setrecursionlimit() explicitly warns you against doing this:

"The highest possible limit is platform-dependent. A user may need to set the limit higher when she has a program that requires deep recursion and a platform that supports a higher limit. This should be done with care, because a too-high limit can lead to a crash."

https://docs.python.org/2.7/library/sys.html#sys.setrecursionlimit
History
Date User Action Args
2016-07-17 06:29:51ned.deilysetstatus: open -> closed

nosy: + ned.deily
messages: + msg270614

resolution: not a bug
stage: resolved
2016-07-17 06:02:29pabstersaccreate