Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] "ImportError: wx/_core.cpython-312-x86_64-linux-gnu.so: undefined symbol: _Py_NegativeRefcount" #1093

Closed
EvilSupahFly opened this issue Aug 14, 2024 · 11 comments
Labels
state: triage the severity of this ticket needs evaluating type: bug Something isn't working

Comments

@EvilSupahFly
Copy link

Bug Report

As part of troubleshooting the flatpak build, I created a brand new VENV for Amulet 0.10.35 and attempted to install it with PIP (which is what the Flatpak builder does), everything was apparently successful. When I attempt to load it, it crashes right out of the box:

Traceback (most recent call last):
  File "<frozen runpy>", line 189, in _run_module_as_main
  File "<frozen runpy>", line 148, in _get_module_details
  File "<frozen runpy>", line 112, in _get_module_details
  File "/home/evilsupahfly/python-virtual-environs/amulet/lib/python3.12/site-packages/amulet_map_editor/__init__.py", line 27, in <module>
    from amulet_map_editor.api.framework.app import open_level, close_level
  File "/home/evilsupahfly/python-virtual-environs/amulet/lib/python3.12/site-packages/amulet_map_editor/api/framework/__init__.py", line 1, in <module>
    from .app import AmuletApp
  File "/home/evilsupahfly/python-virtual-environs/amulet/lib/python3.12/site-packages/amulet_map_editor/api/framework/app.py", line 1, in <module>
    import wx
  File "/home/evilsupahfly/python-virtual-environs/amulet/lib/python3.12/site-packages/wx/__init__.py", line 17, in <module>
    from wx.core import *
  File "/home/evilsupahfly/python-virtual-environs/amulet/lib/python3.12/site-packages/wx/core.py", line 12, in <module>
    from ._core import *
ImportError: /home/evilsupahfly/python-virtual-environs/amulet/lib/python3.12/site-packages/wx/_core.cpython-312-x86_64-linux-gnu.so: undefined symbol: _Py_NegativeRefcount

Current Behaviour:

Amulet crashes on load - before GUI even presents itself

Expected behavior:

Amulet doesn't crash on load

Steps To Reproduce:

My entire terminal log is available here so you can see exactly what I did and what the result was.

Environment:

  • OS: Linux Mint 22 (downstream of Ubuntu's Noble) running Python 3.12.3 in standard Python VENV
  • Minecraft Platform: Java
  • Minecraft Version: All
  • Amulet Version: 0.10.35

Additional context

Attachments

Screenshots

Worlds

@EvilSupahFly EvilSupahFly added state: triage the severity of this ticket needs evaluating type: bug Something isn't working labels Aug 14, 2024
@gentlegiantJGC
Copy link
Member

I have not seen that before.
Is it missing a shared library for wx?

@gentlegiantJGC
Copy link
Member

Looks like it is part of cpython but only included in certain contexts.

https://github.com/python/cpython/blob/f84754b70506f03bcbf9fb0265e327d05a1a4b51/Include/refcount.h#L190

@EvilSupahFly
Copy link
Author

I have a post open at wxPython to see if someone there can shed some light.

@gentlegiantJGC
Copy link
Member

The most likely issue I can think of is that the prebuilt version of wx you are using is compiled with different flags to the version of Python you are using. It is expecting the symbol from python but it doesn't exist.

@EvilSupahFly
Copy link
Author

My virtual uses 3.12 so I'm going to grab 3.9 and try again, especially since I found this on the Python 3 changelog:

Python 3.12.0 release candidate 3

Release date: 2023-09-18

Core and Builtins

gh-109496: On a Python built in debug mode, Py_DECREF() now calls _Py_NegativeRefcount() if the object is a dangling pointer to deallocated memory: memory filled with 0xDD “dead byte” by the debug hook on memory allocators. The fix is to check the reference count before checking for _Py_IsImmortal(). Patch by Victor Stinner.

I'm willing to bet "Python is too new" is the problem with the Flatpak build too. We'll see after the test machines finish.

@EvilSupahFly
Copy link
Author

EvilSupahFly commented Aug 15, 2024

Running Amulet in a virtual Python 3.9.19 after installing via pip was a success.

(amulet-py-319) evilsupahfly on Black-Beast at Thu 15 Aug 2024 12:08:58 EDT
[~/Downloads/Python/Python-3.9.19] python -m amulet_map_editor
INFO - PyMCTranslate Version 291
INFO - Loading level /home/evilsupahfly/.minecraft/saves/Otherwhere
INFO - Loading level /home/evilsupahfly/.minecraft/saves/Otherwhere
INFO - No OpenGL_accelerate module loaded: No module named 'OpenGL_accelerate'
INFO - No OpenGL_accelerate module loaded: No module named 'OpenGL_accelerate'
INFO - Downloading java launcher manifest file.
INFO - Downloading java launcher manifest file.
INFO - Finished downloading java launcher manifest file.
INFO - Finished downloading java launcher manifest file.
INFO - Creating texture atlas
INFO - Creating texture atlas
INFO - Trying to pack textures into image of size 4096x4096
INFO - Trying to pack textures into image of size 4096x4096
INFO - Successfully packed textures into an image of size 4096x4096
INFO - Successfully packed textures into an image of size 4096x4096
INFO - Finished creating texture atlas
INFO - Finished creating texture atlas
INFO - OpenGL Version 3.3.0 NVIDIA 560.28.03
INFO - OpenGL Version 3.3.0 NVIDIA 560.28.03
INFO - Finished setting up texture atlas in OpenGL
INFO - Finished setting up texture atlas in OpenGL
(amulet-py-319) evilsupahfly on Black-Beast at Thu 15 Aug 2024 12:11:12 EDT

Next, I'll see if I can build the Flatpak using this older version of Python.

Screenshot from 2024-08-15 12-10-59

@EvilSupahFly
Copy link
Author

Also, for the record, I found THIS handy little tool, which has made managing different versions of Python extremely easy!

@gentlegiantJGC
Copy link
Member

I have used this before which looks similar
https://github.com/pyenv/pyenv

@EvilSupahFly
Copy link
Author

EvilSupahFly commented Aug 16, 2024

Installing Amulet with PIP in Python 3.11.9 (which is what Flatpak uses) and running after install: No problems

Screenshot from 2024-08-15 23-04-29

... Well aside from the missing/flickering GUI buttons still...

@gentlegiantJGC
Copy link
Member

Can this be closed?

@EvilSupahFly
Copy link
Author

Go ahead. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: triage the severity of this ticket needs evaluating type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants