coolzhao / Geo-SAM

A QGIS plugin tool using Segment Anything Model (SAM) to accelerate segmenting or delineating landforms in geospatial raster images.
MIT License
199 stars 26 forks source link

Crash on QGIS 3.36 in ubuntu 20.04 #43

Open YanCheng-go opened 2 months ago

YanCheng-go commented 2 months ago

I was trying the plugin on QGIS 3.36 in ubuntu 20.04. The image encoder worked, but the software crashed whenever I clicked the segmentation tool.

cmosig commented 2 months ago

Same issue here:

Steps to reproduce: Open QGIS, press Segmentation Tool, select generated Encodings, Press "Load" -> Crash.

QGIS Log:

QGIS died on signal 11Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
No thread selected
No stack.
gdb returned 256
[1]    71179 IOT instruction (core dumped)  qgis
cmosig commented 2 months ago

I launched pdb and checked at which line of code it would crash: https://github.com/coolzhao/Geo-SAM/blob/847db2a74b4198cf4dedee2b58bc4292e2056bed/tools/torchgeo_sam.py#L192

This does not make much sense to me honestly because this simply creates an index. Running this line of code outside of qgis does not create a crash or exception.

Fanchengyan commented 2 months ago

Hi @cmosig ,

Thank you for the troubleshooting. This should be a bug of QGIS. I have reproduced this bug in the Python Console in QGIS 3.34 and 3.36. Running the following code directly will cause QGIS to crash.

from rtree.index import Index, Property
index = Index(interleaved=False, properties=Property(dimension=3))

I will submit an issue to QGIS. Since GeoSAM and torchgeo heavily relay on rtree, it is recommended to find a way to install a version prior to 3.34 before QGIS fixes this bug.

Fanchengyan commented 2 months ago

Hi @YanCheng-go and @cmosig ,

Here is the solution: https://geo-sam.readthedocs.io/en/latest/blog/2024/05-02_crash_on_QGIS.html

cmosig commented 2 months ago

Thanks, this worked instantly!

YanCheng-go commented 2 months ago

@Fanchengyan Thanks! It also worked for me on Ubuntu 20.02 and QGIS3.36 installed through flatpak. Just need to downgrade rtree with the following line:

flatpak run --devel --command=pip3 org.qgis.qgis install rtree==0.9.4