conda-forge / qgis-feedstock

A conda-smithy repository for qgis.
BSD 3-Clause "New" or "Revised" License
41 stars 26 forks source link

Fix crash on Python exit with Linux #354

Closed gillins closed 12 months ago

gillins commented 1 year ago

Checklist

conda-forge-webservices[bot] commented 1 year ago

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

gillins commented 1 year ago

@conda-forge-admin, please rerender

github-actions[bot] commented 1 year ago

Hi! This is the friendly automated conda-forge-webservice.

I tried to rerender for you, but it looks like there was nothing to do.

This message was generated by GitHub actions workflow run https://github.com/conda-forge/qgis-feedstock/actions/runs/5460090723.

SrNetoChan commented 1 year ago

It seems that this makes it work on Linux, but broken the builds on OSX and Windows. Do you think we started using gcc 11 in conda-forge around the time of 3.28.5?

SrNetoChan commented 1 year ago

Nevermind my comment, we are using gcc 12 since 3 months ago

gillins commented 1 year ago

Yeah sorry the gcc 12 thing turned out to be a dead end. This was all made somewhat more confusing with our hack to cope with qgis crashing during the tests obscuring the fact that the tests weren't working. I'll try and fix what is going on here at the same time hopefully - valgrind has been useful narrowing this down. I spent a fair bit of yesterday trying to track down what's going on within sip locally but so far no luck. I'm trying a few other things today, will let you know.

SrNetoChan commented 1 year ago

Let me know if you need me to test anything on a Mac OS machine I have access.

gillins commented 1 year ago

Thanks @SrNetoChan. I thought I might have been onto something finding that the package pyqt5-sip seemed unnecessary and seemed to contain some of the same stuff as sip - I thought there might be a conflict, but another dead end. I did fix that crash (on my machine at least) so that's something. I'll keep tracking through this next week.

gillins commented 12 months ago

I'm going to merge this if it passes @SrNetoChan since having this crash fixed would be very useful for people scripting on Linux. I also discovered that pyqt5-sip is essential when running the Python modules, we were only getting it "by accident" at runtime due to qscintilla2 requiring it.

SrNetoChan commented 12 months ago

Sounds good to me. We can add a comment regarding that on that issue.

Next week I will try to backport your fix on the LTR branch.

Thanks for your work and patience on this

gillins commented 12 months ago

@SrNetoChan do you know what version of PyQt5-sip that qgis.org uses?

SrNetoChan commented 12 months ago

@SrNetoChan do you know what version of PyQt5-sip that qgis.org uses?

I am afraid I don't. And I am away from office these days.

gillins commented 12 months ago

Turns out there is still a problem with OSX that I can't diagnose without access to a machine. If this is causing a problem for someone on OSX it would be good to run the test through XCode and send in the line where it crashes.

SrNetoChan commented 12 months ago

I can try to run it next week on a borrowed Mac M1 machine. Unless someone with more easy access can do it.

SrNetoChan commented 11 months ago

@gillins I am back to the office, what can I do to help?

gillins commented 11 months ago

I know very little about OSX but I did find this: https://support.apple.com/en-au/guide/console/cnsl664be99a/mac

Can you run python test_py_qgis.py (from https://github.com/conda-forge/qgis-feedstock/blob/main/recipe/test_py_qgis.py) and see if you can obtain a stack trace?

SrNetoChan commented 11 months ago

I will!

SrNetoChan commented 11 months ago

@gillins Here's what I got:

    Mambaforge-Darwin-arm64.sh  test_py_qgis.py
    Mambaforge-MacOSX-arm64.sh
    (qgis_test) qgis@Giovannis-Mac-mini Downloads % python test_py_qgis.py 
    qt.qpa.fonts: Populating font family aliases took 48 ms. Replace uses of missing font family "Open Sans" with one that exists to avoid this cost. 
    Ran `app.initQgis`
    Valid layer?: False
    Could not even validate the vector file... 
    Printing environment

    __CFBundleIdentifier: com.apple.Terminal
    TMPDIR: /var/folders/p8/vz7c8v_s4_z41b6q236vdvqm0000gp/T/
    XPC_FLAGS: 0x0
    LaunchInstanceID: 203EA1A6-5462-4BDD-9F9F-3414A35A57C1
    TERM: xterm-256color
    SSH_AUTH_SOCK: /private/tmp/com.apple.launchd.4EhEefAA3k/Listeners
    SECURITYSESSIONID: 186a4
    XPC_SERVICE_NAME: 0
    TERM_PROGRAM: Apple_Terminal
    TERM_PROGRAM_VERSION: 447
    TERM_SESSION_ID: 1CFD045F-DECA-409C-8794-B1564CA18736
    SHELL: /bin/zsh
    HOME: /Users/qgis
    LOGNAME: qgis
    USER: qgis
    PATH: /Users/qgis/mambaforge/envs/qgis_test/bin:/Users/qgis/mambaforge/condabin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
    SHLVL: 1
    PWD: /Users/qgis/Downloads
    OLDPWD: /Users/qgis
    CONDA_EXE: /Users/qgis/mambaforge/bin/conda
    _CE_M: 
    _CE_CONDA: 
    CONDA_PYTHON_EXE: /Users/qgis/mambaforge/bin/python
    CONDA_SHLVL: 2
    CONDA_PREFIX: /Users/qgis/mambaforge/envs/qgis_test
    CONDA_DEFAULT_ENV: qgis_test
    CONDA_PROMPT_MODIFIER: (qgis_test) 
    CONDA_PREFIX_1: /Users/qgis/mambaforge
    GDAL_DATA: /Users/qgis/mambaforge/envs/qgis_test/share/gdal
    GDAL_DRIVER_PATH: /Users/qgis/mambaforge/envs/qgis_test/lib/gdalplugins
    CPL_ZIP_ENCODING: UTF-8
    GSETTINGS_SCHEMA_DIR_CONDA_BACKUP: 
    GSETTINGS_SCHEMA_DIR: /Users/qgis/mambaforge/envs/qgis_test/share/glib-2.0/schemas
    XML_CATALOG_FILES: file:///Users/qgis/mambaforge/envs/qgis_test/etc/xml/catalog file:///etc/xml/catalog
    PDAL_DRIVER_PATH: /Users/qgis/mambaforge/envs/qgis_test/lib
    PROJ_DATA: /Users/qgis/mambaforge/envs/qgis_test/share/proj
    PROJ_NETWORK: ON
    PYTHONPATH: /Users/qgis/mambaforge/envs/qgis_test/share/qgis/python/plugins:/Users/qgis/mambaforge/envs/qgis_test/share/qgis/python:
    QT_PLUGIN_PATH: /Users/qgis/mambaforge/envs/qgis_test/plugins:
    QGIS_PREFIX_PATH: /Users/qgis/mambaforge/envs/qgis_test
    LC_CTYPE: UTF-8
    _: /Users/qgis/mambaforge/envs/qgis_test/bin/python
    Traceback (most recent call last):
      File "/Users/qgis/Downloads/test_py_qgis.py", line 62, in <module>
        test(fname)
      File "/Users/qgis/Downloads/test_py_qgis.py", line 48, in test
        raise Exception("QGIS Python API not functional")
    Exception: QGIS Python API not functional

    QGIS Python API not functional
    QGIS prefixPath(): "/Users/qgis/mambaforge/envs/qgis_test"
gillins commented 11 months ago

Hmmm no I need a stack trace of the C++ code, can you see anyway of getting this on OSX? Maybe there is a way of getting this with XCode instead?

SrNetoChan commented 11 months ago

Uhmm... Do I need to build it locally with debug and then run it with xcode. Sorry, I am clueless about this.

gillins commented 11 months ago

Try running it as it stands through xcode. valgrind was able to give me quite a bit of info without having to rebuild with debug. I know very little about xcode though...

gillins commented 11 months ago

Turns out there is a version of valgrind available from brew - see instructions here: https://github.com/LouisBrunner/valgrind-macos#usage

Might be an easier way than xcode? Should be able to just run valgrind python test_py_qgis.py and hopefully will give you something useful.

SrNetoChan commented 11 months ago

What a bad luck. The mac I can use is a arm M1, seems valgrind is not ready for it yet:

https://github.com/LouisBrunner/valgrind-macos/issues/56

gillins commented 11 months ago

Ah that is a shame.... Anyone out there with an x86 Mac? Or experience tracking down crashes with XCode?