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

SDL2 version crashes on start with "arguments to dbus_connection_unref() were incorrect" #91

Open
akien-mga opened this issue Jan 20, 2017 · 40 comments

Comments

@akien-mga
Copy link

I just updated Mageia's m64py package to the new version 0.2.4, after packaging PySDL2 0.9.5. On startup I get a DBus-related error and it crashes.

M64Py - A frontend for Mupen64Plus version 0.2.4

Frontend: INFO: OpenGL_accelerate module loaded
Frontend: INFO: Using accelerated ArrayDatatype
Frontend: INFO: attached to library 'Mupen64Plus Core' version 2.5.0
Frontend: INFO: includes support for Dynamic Recompiler.
Core: Unable to open rom database file '(null)'.
Frontend: INFO: video extension enabled
Video: No version number in 'Rice-Video' config section. Setting defaults.
Video: Old parameter config version detected : 0, updating to 1;
Video: Couldn't find Glide64mk2.ini
Frontend: DEBUG: plugin_startup()
Frontend: WARNING: FILES: Error opening, creating, reading, or writing to a file
Frontend: WARNING: Glide64mk2 Video Plugin failed to start.
Input: Couldn't find config file 'InputAutoCfg.ini'
Input: missing 'plugged' parameter from config section AutoConfig0. Setting to 1 (true).
Input: missing 'plugin' parameter from config section AutoConfig0. Setting to 1 (none).
Input: missing config key 'DPad R' for controller 1 button 0
Input: missing config key 'DPad L' for controller 1 button 1
Input: missing config key 'DPad D' for controller 1 button 2
Input: missing config key 'DPad U' for controller 1 button 3
Input: missing config key 'Start' for controller 1 button 4
Input: missing config key 'Z Trig' for controller 1 button 5
Input: missing config key 'B Button' for controller 1 button 6
Input: missing config key 'A Button' for controller 1 button 7
Input: missing config key 'C Button R' for controller 1 button 8
Input: missing config key 'C Button L' for controller 1 button 9
Input: missing config key 'C Button D' for controller 1 button 10
Input: missing config key 'C Button U' for controller 1 button 11
Input: missing config key 'R Trig' for controller 1 button 12
Input: missing config key 'L Trig' for controller 1 button 13
Input: missing config key 'Mempak switch' for controller 1 button 14
Input: missing config key 'Rumblepak switch' for controller 1 button 15
Input: missing config key 'X Axis' for controller 1 axis 0
Input: missing config key 'Y Axis' for controller 1 axis 1
process 18809: arguments to dbus_connection_unref() were incorrect, assertion "connection->generation == _dbus_current_generation" failed in file dbus-connection.c line 2822.
This is normally a bug in some application using the D-Bus library.
  D-Bus not built with -rdynamic so unable to print a backtrace
Abandon (core dumped)

Going back to version 0.2.3 works fine.

@gen2brain
Copy link
Member

Are you sure that going back to version 0.2.3 works? On same system, you are not running as root, same mupen64plus etc.?
There is nothing special in 0.2.4, dbus in frontend is only used to enable/disable screensaver and nothing is changed there, not sure if any plugin is using dbus on Linux. Looks like Glide64mk2 can't start, it is missing .ini file.

@akien-mga
Copy link
Author

Going back to 0.2.3 does work on the same system in the same conditions. The only difference is that it was packaged 6 months ago - I'll try building 0.2.3 anew with the same setup as 0.2.4 and see how it goes.

@akien-mga
Copy link
Author

Rebuilt 0.2.3 and tried it, it still works fine. The log is quite similar, so the missing Glide64mk2 is another issue as it does not prevent startup (I might need to fix my mupen64plus package?):

M64Py - A frontend for Mupen64Plus version 0.2.3

Frontend: INFO: OpenGL_accelerate module loaded
Frontend: INFO: Using accelerated ArrayDatatype
Frontend: INFO: attached to library 'Mupen64Plus Core' version 2.5.0
Frontend: INFO: includes support for Dynamic Recompiler.
Core: Unable to open rom database file '(null)'.
Frontend: INFO: video extension enabled
Video: Couldn't find Glide64mk2.ini
Frontend: DEBUG: plugin_startup()
Frontend: WARNING: FILES: Error opening, creating, reading, or writing to a file
Frontend: WARNING: Glide64mk2 Video Plugin failed to start.
Video: No version number in 'Rice-Video' config section. Setting defaults.
Video: Old parameter config version detected : 0, updating to 1;
Input: Couldn't find config file 'InputAutoCfg.ini'
Input: missing 'plugged' parameter from config section AutoConfig0. Setting to 1 (true).
Input: missing 'plugin' parameter from config section AutoConfig0. Setting to 1 (none).
Input: missing config key 'DPad R' for controller 1 button 0
Input: missing config key 'DPad L' for controller 1 button 1
Input: missing config key 'DPad D' for controller 1 button 2
Input: missing config key 'DPad U' for controller 1 button 3
Input: missing config key 'Start' for controller 1 button 4
Input: missing config key 'Z Trig' for controller 1 button 5
Input: missing config key 'B Button' for controller 1 button 6
Input: missing config key 'A Button' for controller 1 button 7
Input: missing config key 'C Button R' for controller 1 button 8
Input: missing config key 'C Button L' for controller 1 button 9
Input: missing config key 'C Button D' for controller 1 button 10
Input: missing config key 'C Button U' for controller 1 button 11
Input: missing config key 'R Trig' for controller 1 button 12
Input: missing config key 'L Trig' for controller 1 button 13
Input: missing config key 'Mempak switch' for controller 1 button 14
Input: missing config key 'Rumblepak switch' for controller 1 button 15
Input: missing config key 'X Axis' for controller 1 axis 0
Input: missing config key 'Y Axis' for controller 1 axis 1

@gen2brain
Copy link
Member

python2 vs python3 issue maybe? Check also version of dbus-python, I have no idea what else can be a issue. Try to start it as root, then it should print a warning that it can't connect to dbus session, so it should not try to use it.

@akien-mga
Copy link
Author

It does work as root since the DBus session is not used indeed.

I build m64py with python3 and have dbus-python 1.2.4.

@akien-mga
Copy link
Author

For the reference, my spec file:

# This should be pushed to tainted as per Mageia's policy on emulators

%define debug_package %{nil}

Name:             m64py
Version:          0.2.4
Release:          %mkrel 1
Summary:          A Qt5 frontend for Mupen64Plus
License:          GPLv3
Group:            Emulators
Url:              http://m64py.sourceforge.net
Source:           http://sourceforge.net/projects/m64py/files/%{name}-%{version}/%{name}-%{version}.tar.gz

BuildRequires:    python3-qt5-devel
BuildRequires:    python3-sip
Requires:         %{_lib}mupen64plus2 >= 2.0
Requires:         %{_lib}sdl2.0_0
Requires:         python3-dbus
Requires:         python3-opengl
Requires:         python3-qt5
Requires:         python3-sdl2
Requires:         python3-sip

%description
M64Py is a Qt5 front-end (GUI) for Mupen64Plus 2.0, a cross-platform
plugin-based Nintendo 64 emulator. The front-end is written in Python
and it provides a user-friendly interface over Mupen64Plus shared library.

%prep
%autosetup

%build
%py3_build

%install
%py3_install

%files
%doc AUTHORS ChangeLog COPYING LICENSES PKG-INFO README.md
%{_bindir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/pixmaps/%{name}.png
%{python3_sitelib}/%{name}/
%{python3_sitelib}/%{name}-%{version}-py%{python3_version}.egg-info

It did not change significantly since 0.2.3, apart from adding python3-sdl2 as dependency (PySDL2).

@akien-mga
Copy link
Author

I'll see if I can bisect the issue.

@gen2brain
Copy link
Member

This is a part of code that use dbus on Linux to enable/disable screensaver https://github.com/mupen64plus/mupen64plus-ui-python/blob/master/src/m64py/screensaver.py#L24 . Nothing changed there for 2 years.

@akien-mga
Copy link
Author

A bisect gave 68e6f39 as first bad commit. Maybe 0.2.3 used to default to SDL1 on my system? IIUC it has some autodetect logic, right?

@akien-mga
Copy link
Author

akien-mga commented Jan 21, 2017

I confirm that 0.2.3 gives the same error when started with m64py --sdl2. Same error when installing the python 2 flavour too.

Libraries:

  • Python 3.5.2 and 2.7.12
  • SDL2 2.0.5
  • PySDL2 0.9.5
  • PyQt5 5.6
  • dbus-python 1.2.4

@akien-mga akien-mga changed the title New version crashes on start with "arguments to dbus_connection_unref() were incorrect" SDL2 version crashes on start with "arguments to dbus_connection_unref() were incorrect" Jan 21, 2017
@gen2brain
Copy link
Member

SDL2 internaly use dbus on Linux but doesn't link to libdbus, instead it loads libdbus-1.so.3 https://hg.libsdl.org/SDL/file/e854440318d2/src/core/linux/SDL_dbus.c , so you can check that.

@gen2brain
Copy link
Member

And now, without SDL1, frontend can just call https://wiki.libsdl.org/SDL_DisableScreenSaver , no need for screensaver.py at all.

@loganmc10
Copy link
Member

I am getting the same problem in Fedora 25

M64Py - A frontend for Mupen64Plus version 0.2.4

Frontend: ERROR: None: cannot open shared object file: No such file or directory
Traceback (most recent call last):
  File "/home/loganmc10/mupen64plus-GLideN64/mupen64plus-ui-python/src/m64py/core/core.py", line 88, in core_load
    self.m64p = load(path)
  File "/home/loganmc10/mupen64plus-GLideN64/mupen64plus-ui-python/src/m64py/loader.py", line 87, in load
    raise ImportError(e)
ImportError: None: cannot open shared object file: No such file or directory
dbus[5502]: arguments to dbus_connection_ref() were incorrect, assertion "connection->generation == _dbus_current_generation" failed in file ../../dbus/dbus-connection.c line 2686.
This is normally a bug in some application using the D-Bus library.

dbus[5502]: arguments to dbus_connection_close() were incorrect, assertion "connection->generation == _dbus_current_generation" failed in file ../../dbus/dbus-connection.c line 2935.
This is normally a bug in some application using the D-Bus library.

Segmentation fault (core dumped)

@gen2brain
Copy link
Member

Doesn't look like exactly the same error. You have this
ImportError: None: cannot open shared object file: No such file or directory

@gen2brain
Copy link
Member

Can you try to comment in screensaver.py everything related to dbus? Just to confirm who is throwing that error, python-dbus or SDL2->dbus.

@loganmc10
Copy link
Member

Sorry that was just becuse I didn't have libmupen64plus.so in the right spot, I fixed that.

I commented out everything in def __init__(self) in screensaver.py and replacd it with print("hello")

the dbus error still happened

@loganmc10
Copy link
Member

"hello" was printed to the screen, so I know that code executed

@gen2brain
Copy link
Member

Ok, thanks. So if m64py doesn't touch dbus anymore then it must be SDL2 fault. Please also remove import dbus line, just to be sure.
As I wrote above, SDL2 tries to open libdbus like this https://hg.libsdl.org/SDL/file/e854440318d2/src/core/linux/SDL_dbus.c , doesn't link to it.

I have SDL2 version 2.0.5 and dbus 1.10.14 and it works ok.

@loganmc10
Copy link
Member

The import line was removed for my first test.

I'll do some more testing and see if I can figure out a solution

@loganmc10
Copy link
Member

loganmc10 commented Feb 3, 2017

I'm on Fedora 25, I also have SDL2 2.0.5, but the dbus version is 1.11.8 (PySDL2 installed from pip, so I assume it's the latest version).

EDIT: I filed a bug with SDL2 https://bugzilla.libsdl.org/show_bug.cgi?id=3580, maybe they will be able to fix it

@loganmc10
Copy link
Member

I haven't really tracked down what is causing this, but I get this same message in Ubuntu 16.04.

Although in Fedora 25, m64py closes instantly, in Ubuntu 16.04 m64py stays open and it works, but I get a ton of these dbus error messages in the terminal while it's running

@jamesrobb
Copy link

Using Manjaro with the same problem.

@zadeluca
Copy link

zadeluca commented Apr 20, 2017

I have the same problem on Manjaro as well. As an exercise I attempted to dig into it a little, but I admit that I am swimming in deep water and have yet to discover the cause (I am learning a lot though!)

However, in troubleshooting I did discover a workaround. If you rebuild/reinstall dbus and make sure the following options are passed to configure, the error goes away:

--disable-asserts
--disable-checks

I don't know how much this information is worth, or what the possible consequences are of setting these options, but it's working for me currently. I don't really know what to do next but if anyone has any suggestions, or would like me to test something etc., I would be glad to help.

@gen2brain
Copy link
Member

That is some clue. On Gentoo dbus is always built with --disable-asserts --disable-checks , so I never had that problem. Question is if this something that is enabled/forced on some distros since recently or they had that before and only now something (PySDL, PyQt, SDL) is triggering it.

@akien-mga
Copy link
Author

Question is if this something that is enabled/forced on some distros since recently or they had that before and only now something (PySDL, PyQt, SDL) is triggering it.

They had it before. At least in Mageia nothing changed packaging-wise for dbus, and given the number of reports from other distros, it can't be a coincidence, so the issue is triggered by one of the new dependencies in 0.2.4 IMO.

@gen2brain
Copy link
Member

There are no new dependencies in 0.2.4, PySDL2 is just unbundled from m64py source and must be installed now. I also tried with old PySDL2 sources on Fedora that were bundled and it doesn't help.

@akien-mga
Copy link
Author

I know, but as I diagnosed above already, before 0.2.4 the issue only happened when forcing the use of SDL2. I'd make an educated guess that all users of distros reporting 0.2.4 as not working were using the SDL1 flavour previously. So by "new dependency", I mean the fact that as per 0.2.4 everybody is using SDL2, while previously the autodetect was most of the time landing on SDL1. So the issue needs to be investigated around SDL2, PySDL2 or related dependencies: #91 (comment)

To be clearer, the issue did not start with the unbundling of SDL2. It started with the removal of the SDL1 alternative.

@gen2brain
Copy link
Member

I just recompiled my system dbus without --disable-asserts --disable-checks (modified ebuild) and it still works. Can someone try to remove SDL2 system lib and compile a new one from hg or latest tarball?

@ibrokemypie
Copy link

Any update for the average user?

@icculus
Copy link

icculus commented May 29, 2017

Hey, I haven't tried mupen64, but I'm one of the SDL developers, and we're trying to get a reproduction case for this issue. Can anyone seeing this get a backtrace from the error so we can see where this happens?

We aren't sure if it's an SDL bug, an incompatibility between D-Bus versions, bad luck, etc.

@gen2brain
Copy link
Member

Hi, I just tried to get backtrace in Fedora but nothing is reported. This only happens in python frontend, with PySDL2 bindings.
Usually I was able to get useful info with gdb python; run m64py; bt; and I think I installed everything needed with dnf debuginfo-install.

Simple test like this one https://stackoverflow.com/questions/41452558/d-bus-related-runtime-crash-when-trying-to-open-sdl2-window where someone experienced same error works though.
I also compiled SDL-2.0.5-11021 and replaced system SDL2 with that version but that also didn't work.

On Ubuntu it just print errors, but doesn't crash, on Fedora and Arch it crashes and on Gentoo it just works (even after recompiling dbus without --disable-asserts --disable-checks).

@zadeluca
Copy link

zadeluca commented May 29, 2017

@rcgordon For the record, I don't really know this all plays together (dbus, SDL, etc.). On Manjaro in order to enable backtraces, I have to rebuild dbus with --enable-asserts, and this is what I get when launching m64py. Let me know if I can help in any way.

M64Py - A frontend for Mupen64Plus version 0.2.4

7411: assertion failed "connection->generation == _dbus_current_generation" file "dbus-connection.c" line 1424 function _dbus_connection_ref_unlocked
  /usr/lib/libdbus-1.so.3(+0x4b7bf) [0x7fa0603ff7bf]
  /usr/lib/libdbus-1.so.3(+0x4e829) [0x7fa060402829]
  /usr/lib/libdbus-1.so.3(_dbus_real_assert+0x41) [0x7fa0603f1a41]
  /usr/lib/libdbus-1.so.3(_dbus_connection_ref_unlocked+0x60) [0x7fa0603c9bf0]
  /usr/lib/libdbus-1.so.3(_dbus_pending_call_new_unlocked+0x9d) [0x7fa0603e518d]
  /usr/lib/libdbus-1.so.3(dbus_connection_send_with_reply+0x154) [0x7fa0603ccdd4]
  /usr/lib/libQt5DBus.so.5(+0x23353) [0x7fa062b6e353]
  /usr/lib/libQt5Core.so.5(_ZN7QObject5eventEP6QEvent+0xe9) [0x7fa06ad7dba9]
  /usr/lib/libQt5Core.so.5(_ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent+0xfb) [0x7fa06ad5142b]
  /usr/lib/libQt5Core.so.5(_ZN23QCoreApplicationPrivate16sendPostedEventsEP7QObjectiP11QThreadData+0x2dd) [0x7fa06ad53bcd]
  /usr/lib/libQt5Core.so.5(+0x2dcc43) [0x7fa06ada5c43]
  /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x2a7) [0x7fa068bd95a7]
  /usr/lib/libglib-2.0.so.0(+0x4a810) [0x7fa068bd9810]
  /usr/lib/libglib-2.0.so.0(g_main_context_iteration+0x2c) [0x7fa068bd98bc]
  /usr/lib/libQt5Core.so.5(_ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE+0x5f) [0x7fa06ada604f]
  /usr/lib/libQt5Core.so.5(_ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE+0xfa) [0x7fa06ad4f89a]
  /usr/lib/libQt5Core.so.5(_ZN7QThread4execEv+0xc3) [0x7fa06ab71a73]
  /usr/lib/libQt5DBus.so.5(+0x16125) [0x7fa062b61125]
  /usr/lib/libQt5Core.so.5(+0xad6d8) [0x7fa06ab766d8]
  /usr/lib/libpthread.so.0(+0x72e7) [0x7fa06dd132e7]
  /usr/lib/libc.so.6(clone+0x3f) [0x7fa06da5454f]
Aborted

@Unrud
Copy link

Unrud commented Jun 21, 2017

The last line of Python code that gets executed before the crash:

mainwindow_ui.py(29):         self.menubar = QtWidgets.QMenuBar(MainWindow)

The problem can be circumvented by compiling Qt without dbus support (-no-dbus argument) and in release mode (-release argument). The release mode is necessary because the program calls functions from wrong threads, which causes assertions to fail.

@sebospc
Copy link

sebospc commented Oct 17, 2017

same problem in manjaro

@andoruB andoruB mentioned this issue Mar 22, 2018
@andoruB
Copy link

andoruB commented Mar 22, 2018

Experiencing the same issue on Debian Sid.
Any updates? Anything I can help with?

@icculus
Copy link

icculus commented Mar 22, 2018

fwiw, we fixed a similar D-Bus thing in SDL, so upgrading to SDL 2.0.8 might help, but @zadeluca's callstack suggest this isn't an SDL issue at all.

@andoruB
Copy link

andoruB commented Mar 23, 2018

I am currently using 2.0.8... so I'm guessing @zadeluca is right.

@SukkoPera
Copy link

Just tried V 0.2.5 and I stumbled upon this. I found a workaround, which is to run m64py as:

DBUS_FATAL_WARNINGS=0 m64py

You'll still get the message but the app will start and work fine as far as I can tell.

Hope it helps :).

@gen2brain
Copy link
Member

@SukkoPera Can you try to set ENV in the main m64py file, before try/except block that imports import QApplication ?

Just add one line in file and test:
os.environ["DBUS_FATAL_WARNINGS"] = "0"

@SukkoPera
Copy link

@gen2brain Yep, that works just as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests