﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32293	import _scproxy and spatialite database backend segfaults	Jon Janzen	nobody	"This bug started happening to me when I upgraded to macOS 11 Big Sur, but this may be coincidence as I upgraded all of my homebrew packages at the same time.

This bug was traced down from having the `graphene_django` module in `INSTALLED_APPS`. This module imports a lot of things but one of which is `urllib.request`, which in turn actually imports `_scproxy`.

=== Steps to reproduce:
1. `django-admin startproject crashdemo && cd crashdemo`
2. Edit `crashdemo/settings.py` to use the `spatialite` backend instead of `sqlite3`
3. Add `import _scproxy` to `settings.py` (actual file doesn't matter, as long as it's imported during django startup)
4. Run `python3 manage.py runserver --noreload` (`--noreload` not strictly necessary, but it causes the segfault to occur in the main thread)

=== Expected outcome:
Django starts up normally.

=== Actual outcome:
{{{
Performing system checks...

System check identified no issues (0 silenced).
Segmentation fault: 11
}}}

=== My Environment:
macOS Big Sur 11.1 (x86-64)
sqlite3 is from homebrew
libspatialite/gdal are from homebrew
python@3.8 from homebrew (issue still exists when building from latest source)
django is 3.1.4 from pip (issue still exists when installing from latest source)

I've set some debugging points inside the C source for the `_scproxy` module, and it seems like the functions provided by the module aren't even called leading up to the segfault. It seems like the shared object just needs to be loaded? I'm not sure how to debug this issue further.

I've attached a macOS crash report and a Python traceback produced by cpython-lldb's py-bt command that indicates that this segfault is triggered when attempting to load the libspatialite extension into sqlite. I've confirmed this by wrapping that call with `print` statements and running without a debugger attached. The macOS crash report seems to point to something within `libsqlite` as being the culprit, but I don't really understand what I'm talking about here.

Since I imagine this is a highly environment-specific bug report (perhaps just affecting my Mac), I'm happy to provide any additional information, run any tests, or try potential solutions to help solve this issue."	Uncategorized	closed	Uncategorized	3.1	Normal	invalid			Unreviewed	0	0	0	0	0	0
