View Ticket
Not logged in
Ticket Hash: bbab46cf4dedd9703960a75429a171753a4339c5
Title: Strange Interaction Between Spatialite and Shapely
Status: Closed Type: Incident
Severity: Critical Priority: Immediate
Subsystem: Resolution: Unable_To_Reproduce
Last Modified: 2020-08-02 15:17:39
Version Found In: 4.3.0a-12.fc31
User Comments:
anonymous added on 2020-05-04 23:55:47:
## Expected behavior and actual behavior.

There is a strange interaction between loading spatialite 4.3.0 and shapely 1.7.0. I am not sure where exactly the error is happening so I am reporting the issue in both repositories.

The expected behavior is that one should be able to import shapely after loading spatialite without a segmentation faulth.

The actual behavior is that laoding shapely after loading spatialite produces a segmentation fault.

## Steps to reproduce the problem.



```
from sqlalchemy import create_engine
from sqlalchemy.event import listen


def load_spatialite(api_connection, connection_record):
    api_connection.enable_load_extension(True)
    api_connection.load_extension('mod_spatialite.so')


engine = create_engine('sqlite://')
listen(engine, 'connect', load_spatialite)


# from shapely import speedups  # Remove comment to avoid segmentation fault
engine_connection = engine.connect()
from shapely import speedups
```



Running the above code produces the following segmentation fault:
```
python: ByteOrderValues.cpp:46: static int geos::io::ByteOrderValues::getInt(const unsigned char*, int): Assertion `byteOrder == ENDIAN_LITTLE' failed.
Aborted (core dumped)
```



Removing the comment prevents the segmentation fault.

## Operating system

Fedora 31

anonymous added on 2020-05-04 23:59:55:
Here is the corresponding shapely issue:
https://github.com/Toblerity/Shapely/issues/904

sandro added on 2020-08-02 15:17:39:
as the error message says, there is a bad conflict on the GEOS library.
that said, it's more or less like finding a needle in a haystack.

my personal experience about Python is practically nothing, and I have no idea what Shapely could be; any kind of debugging is practically impossible.

hint: try using a newer version of SpatiaLite (as e.g. the very recent 5.0.0). several things have changed in the meanwhile about the iniatialization of GEOS.