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.

Title: Python crashes with "Bus error: 10"
Type: crash Stage: resolved
Components: macOS Versions: Python 2.7, Python 2.6
Status: closed Resolution: duplicate
Dependencies: Superseder: Exceed Recursion Limit in Thread
View: 9670
Assigned To: ronaldoussoren Nosy List: Apple Grew, ned.deily, ronaldoussoren, rosslagerwall
Priority: normal Keywords:

Created on 2012-08-20 13:46 by Apple Grew, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
Process Python.txt Apple Grew, 2012-08-20 13:46 Crash report
Messages (9)
msg168660 - (view) Author: Apple Grew (Apple Grew) Date: 2012-08-20 13:46
Python crashes when I try to access (by sending http request from borwser) my Django application.

OS: Mac OSX Lion
Python version: 2.7.1 (This was pre-bundled with OS and not a MacPort).

There isn't a simple test case but I do have an open source app which where I am able to replicate this always on my system.

0. Make sure you have Django 1.4 installed.
1. Download the code at
2. cd to django-select2/testapp folder.
3. Use python runserver & to run the server.
4. Now try accessing . It should crash immediately.

Lines which seem to cause the crash. Follow the following instructions and the application won't crash again.
1. Open django_select2/
2. Comment line 128, uncomment line 129.
3. Uncomment line 156 and comment lines 158 and 159.
4. Now run the app again. This time it should work.
msg168663 - (view) Author: Ross Lagerwall (rosslagerwall) (Python committer) Date: 2012-08-20 14:42
Well the app has an infinite recursion.

This shows on Fedora Linux 17:
Request Method: 	GET
Request URL:
Django Version: 	1.4
Exception Type: 	RuntimeError
Exception Value: 	

maximum recursion depth exceeded while calling a Python object

Exception Location: 	/tmp/dg/django_select2/ in __init__, line 146
Python Executable: 	/home/ross/src/python/2.7/python
Python Version: 	2.7.1

Of course, this shouldn't cause a bus error in Python. Perhaps try a different build of Python or try building it yourself?
msg168685 - (view) Author: Apple Grew (Apple Grew) Date: 2012-08-20 18:09
Well I tried with Python2.6 (MacPort) now. It too crashes with Bus error. I guess this has something to do with OSX ports.

Please investigate. Whatever it maybe, but the process must not crash like that.
msg168688 - (view) Author: Apple Grew (Apple Grew) Date: 2012-08-20 18:22
If you believe this is impossible then possibly there could be a memory overflow issue which triggers this error in OSX builds. In other builds it may not cause that problem or don't share the same faulty code.
msg168699 - (view) Author: Ross Lagerwall (rosslagerwall) (Python committer) Date: 2012-08-20 20:44
Sorry, I didn't mean that it's impossible; I meant that it shouldn't happen and it should be fixed :-)

Unfortunately I don't have access to an OS X box to test.
msg168701 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2012-08-20 20:54
The bug report mentions python 2.7.1. Could you try to reproduce using the most recent release, or a fresh checkout?  

The reason I ask this is that the crash report has a deeply nested call stack and there used to be a bug where new threads were created with a too small stack. 

BTW.  Python 2.6 is in security fix only mode.
msg168732 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-08-21 03:05
I believe the issue Ronald is referring to is Issue9670.  I tried your test program with a current MacPorts Python 2.7.3 and Django 1.4 and, as Ross saw, it failed gracefully with a "maximum recursion depth exceeded while calling a Python object" exception.  Note in that issue there is currently no perfect fix for this: we've had to heuristically adjust the maximum default stack size based on experience with different compilers and trying not to unnecessarily increase memory usage for pathological cases.  The last adjustment was released in 2.7.2, so presumably not in the compiler used for the Apple-supplied Python 2.7.1 in Lion.  I'm going to close this as a duplicate of #9670.  Feel free to reopen if the problem can be reproduced with a current 2.7.3 or if someone has a better long-term solution.
msg168734 - (view) Author: Apple Grew (Apple Grew) Date: 2012-08-21 04:34
Thanks. I tested with 2.7.3 (macport) and it indeed works.
msg168736 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2012-08-21 04:54
The stack size problem was issue #9670.
Date User Action Args
2022-04-11 14:57:34adminsetgithub: 59944
2012-08-21 04:54:30ronaldoussorensetmessages: + msg168736
2012-08-21 04:34:03Apple Grewsetmessages: + msg168734
2012-08-21 03:05:29ned.deilysetstatus: open -> closed

superseder: Exceed Recursion Limit in Thread

nosy: + ned.deily
messages: + msg168732
resolution: duplicate
stage: resolved
2012-08-20 20:54:09ronaldoussorensetmessages: + msg168701
2012-08-20 20:44:28rosslagerwallsetmessages: + msg168699
2012-08-20 18:22:32Apple Grewsetversions: + Python 2.6
nosy: + ronaldoussoren

messages: + msg168688

assignee: ronaldoussoren
components: + macOS, - Interpreter Core
2012-08-20 18:09:46Apple Grewsetmessages: + msg168685
2012-08-20 14:42:03rosslagerwallsetnosy: + rosslagerwall
messages: + msg168663
2012-08-20 13:46:53Apple Grewcreate