[nvidia] totem crashes on startup (assert !xcb_xlib_unknown_req_in_deq) in _XReply because XInitThreads is not called early enough by libx11 (patch included)

Bug #2000409 reported by xtknight
This bug affects 3 people
Affects Status Importance Assigned to Milestone
totem (Ubuntu)
In Progress

Bug Description

Distributor ID: Ubuntu
Description: Ubuntu 22.10
Release: 22.10
Codename: kinetic

totem 43.0-2ubuntu1
proprietary nvidia-driver-525 525.60.11-0ubuntu0.22.10.1
libx11-6 2:1.8.1-2

Totem crashes (most of the time) when opening a video file. When it does crash, it crashes before playing the video at all.

It doesn't crash often when being run under gdb, profilers, or other utilities that may slow down execution. That indicated it may be a threading issue or race condition, and after digging deeper the issue is evident from the assert message.

  [xcb] Unknown sequence number while processing queue
  [xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
  [xcb] Aborting, sorry about that.

A similar issue happened in SDL, where XInitThreads was *supposed* to be called but wasn't called early enough, specifically by the NVIDIA libGL implementation which I also happen to be using.


(Attempted to use apport to report this, but for some reason it doesn't want to upload or show me the report. I've included the gdb stack trace here.)

andy@andy-i9:/var/crash$ gdb totem totem/CoreDump
GNU gdb (Ubuntu 12.1-3ubuntu2) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from totem...

This GDB supports auto-downloading debuginfo from the following URLs:
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
Reading symbols from /home/andy/.cache/debuginfod_client/c3e79ca1f76831bf9e6750481740ad73e5fce85d/debuginfo...

warning: Can't open file /memfd:/.glXXXXXX (deleted) during file-backed mapping note processing

warning: Can't open file /run/user/1000/orcexec.iAL97R (deleted) during file-backed mapping note processing

warning: Can't open file /memfd:pulseaudio (deleted) during file-backed mapping note processing

warning: Can't open file /memfd:/.nvidia_drv.XXXXXX (deleted) during file-backed mapping note processing

warning: Can't open file /home/andy/.local/share/gvfs-metadata/root-636ea0d4.log during file-backed mapping note processing

warning: Can't open file /SYSV00000000 (deleted) during file-backed mapping note processing
[New LWP 747582]
[New LWP 747566]
[New LWP 747568]
[New LWP 747567]
[New LWP 747570]
[New LWP 747572]
[New LWP 747583]
[New LWP 747586]
[New LWP 747578]
[New LWP 747589]
[New LWP 747588]
[New LWP 747590]
[New LWP 747584]
[New LWP 747593]
[New LWP 747587]
[New LWP 747601]
[New LWP 747581]
[New LWP 747597]
[New LWP 747606]
[New LWP 747603]
[New LWP 747579]
[New LWP 747598]
[New LWP 747592]
[New LWP 747591]
[New LWP 747599]
[New LWP 747594]
[New LWP 747596]
[New LWP 747605]
[New LWP 747595]
[New LWP 747602]
[New LWP 747585]
[New LWP 747569]
[New LWP 747600]
[New LWP 747604]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
--Type <RET> for more, q to quit, c to continue without paging--
Core was generated by `totem C0109.MP4'.
Program terminated with signal SIGABRT, Aborted.
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44
Download failed: Invalid argument. Continuing without source file ./nptl/./nptl/pthread_kill.c.
44 ./nptl/pthread_kill.c: No such file or directory.
[Current thread is 1 (Thread 0x7fde2beff6c0 (LWP 747582))]
(gdb) bt
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44
#1 __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
#2 __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3 0x00007fde5e83bc46 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4 0x00007fde5e8227fc in __GI_abort () at ./stdlib/abort.c:79
#5 0x00007fde5e82271b in __assert_fail_base
    (fmt=0x7fde5e9bac30 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x7fde5df7ba67 "!xcb_xlib_unknown_req_in_deq", file=0x7fde5df7ba14 "../../src/xcb_io.c", line=175, function=<optimized out>)
    at ./assert/assert.c:92
#6 0x00007fde5e833596 in __GI___assert_fail
    (assertion=assertion@entry=0x7fde5df7ba67 "!xcb_xlib_unknown_req_in_deq", file=file@entry=0x7fde5df7ba14 "../../src/xcb_io.c", line=line@entry=175, function=function@entry=0x7fde5df7c410 <__PRETTY_FUNCTION__.6> "dequeue_pending_request") at ./assert/assert.c:101
#7 0x00007fde5df04dea in dequeue_pending_request (dpy=dpy@entry=0x556f5fdc57d0, req=req@entry=0x556f613b9970) at ../../src/xcb_io.c:175
#8 0x00007fde5df0d0f3 in _XReply (dpy=0x556f5fdc57d0, rep=0x7fde2befc680, extra=0, discard=0) at ../../src/xcb_io.c:736
#9 0x00007fde3bce05e8 in () at /lib/x86_64-linux-gnu/libGLX_nvidia.so.0
#10 0x00007fde3bc92f8a in () at /lib/x86_64-linux-gnu/libGLX_nvidia.so.0
#11 0x00007fde3bcde831 in () at /lib/x86_64-linux-gnu/libGLX_nvidia.so.0
#12 0x00007fde3bcdec30 in () at /lib/x86_64-linux-gnu/libGLX_nvidia.so.0
#13 0x00007fde3a05008b in () at /lib/x86_64-linux-gnu/libnvidia-glcore.so.525.60.11
#14 0x00007fde3a05209f in () at /lib/x86_64-linux-gnu/libnvidia-glcore.so.525.60.11
#15 0x00007fde3a145a0a in () at /lib/x86_64-linux-gnu/libnvidia-glcore.so.525.60.11
#16 0x00007fde3a0fe5f3 in () at /lib/x86_64-linux-gnu/libnvidia-glcore.so.525.60.11
#17 0x00007fde3a0d674a in () at /lib/x86_64-linux-gnu/libnvidia-glcore.so.525.60.11
#18 0x00007fde3a132f0a in () at /lib/x86_64-linux-gnu/libnvidia-glcore.so.525.60.11
#19 0x00007fde3a13c910 in () at /lib/x86_64-linux-gnu/libnvidia-glcore.so.525.60.11
#20 0x00007fde3a0aadca in () at /lib/x86_64-linux-gnu/libnvidia-glcore.so.525.60.11
#21 0x00007fde39d4d468 in () at /lib/x86_64-linux-gnu/libnvidia-glcore.so.525.60.11
#22 0x00007fde39dc3b25 in () at /lib/x86_64-linux-gnu/libnvidia-glcore.so.525.60.11
#23 0x00007fde3a0f95ce in () at /lib/x86_64-linux-gnu/libnvidia-glcore.so.525.60.11
#24 0x00007fde39d3dfcd in () at /lib/x86_64-linux-gnu/libnvidia-glcore.so.525.60.11
#25 0x00007fde39d3e154 in () at /lib/x86_64-linux-gnu/libnvidia-glcore.so.525.60.11
#26 0x00007fde58114931 in _attach_renderbuffer (rb=0x7fde248be210 [None], attachment_point=33306, fb=0x7fddf8067460) at ../gst-libs/gst/gl/gstglframebuffer.c:448
#27 gst_gl_framebuffer_attach (fb=fb@entry=0x7fddf8067460, attachment_point=attachment_point@entry=33306, mem=mem@entry=0x7fde248be210 [None]) at ../gst-libs/gst/gl/gstglframebuffer.c:493
#28 0x00007fde58114b7a in gst_gl_framebuffer_new_with_default_depth (context=<optimized out>, width=<optimized out>, height=1080) at ../gst-libs/gst/gl/gstglframebuffer.c:254
#29 0x00007fde58103774 in _init_convert_fbo (convert=0x556f5fe2ac90) at ../gst-libs/gst/gl/gstglcolorconvert.c:2683
#30 _init_convert (convert=<optimized out>) at ../gst-libs/gst/gl/gstglcolorconvert.c:2620
#31 _do_convert (context=0x556f6030e210, convert=<optimized out>) at ../gst-libs/gst/gl/gstglcolorconvert.c:2923
#32 0x00007fde58126ae7 in _run_message_sync (message=0x7fddafffdd50) at ../gst-libs/gst/gl/gstglwindow.c:635
#33 0x00007fde58126aa6 in _run_message_async (message=0x556f5ff76f80) at ../gst-libs/gst/gl/gstglwindow.c:702
#34 0x00007fde5f5e73cf in g_main_dispatch (context=0x556f60bc4f50) at ../../../glib/gmain.c:3444
#35 g_main_context_dispatch (context=0x556f60bc4f50) at ../../../glib/gmain.c:4162
#36 0x00007fde5f63c228 in g_main_context_iterate.constprop.0 (context=0x556f60bc4f50, block=<optimized out>, dispatch=1, self=<optimized out>) at ../../../glib/gmain.c:4238
#37 0x00007fde5f5e6a7f in g_main_loop_run (loop=0x556f60bc5070) at ../../../glib/gmain.c:4438
#38 0x00007fde5810bd8c in gst_gl_context_create_thread (context=0x556f6030e210) at ../gst-libs/gst/gl/gstglcontext.c:1392
#39 0x00007fde5f616371 in g_thread_proxy (data=0x556f610bd5e0) at ../../../glib/gthread.c:831
#40 0x00007fde5e890402 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#41 0x00007fde5e91f590 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

* The commits that cause the problem are:

commit 140d9eea70c3101ef3234abb4de5974cb84b13db
Author: Bastien Nocera <email address hidden>
Date: Wed May 4 11:38:02 2022 +0200

    main: Rely on libX11 initialising threads

commit 2610b4536f73493587e4a5a38e01c9961fcabb96
Author: Bastien Nocera <email address hidden>
Date: Wed May 4 11:37:37 2022 +0200

    backend: Rely on libX11 initialising threads

Although they were definitely made with good intention, unfortunately they don't play well with the current state of NVIDIA libGL and cause an immediate crash. For now, I've settled on calling XInitThreads in totem again. But it would be better to solve the race condition that calls XInitThreads to be called too late. It seems like this would be happening for anyone using the NVIDIA proprietary driver, but I am not certain on what exact conditions cause this.

Revision history for this message
xtknight (xt-knight) wrote :
description: updated
description: updated
Changed in totem:
status: Unknown → New
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "ensure XInitThreads gets called early. reverts totem commits 2610b4536f73493587e4a5a38e01c9961fcabb96 and 140d9eea70c3101ef3234abb4de5974cb84b13db" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

This seems to be a fairly common crash but a bug in our crash tracker prevents us from linking the issues... https://errors.ubuntu.com/?release=Ubuntu%2022.10&package=totem&period=week

Please propose patches at https://gitlab.gnome.org/GNOME/totem/-/merge_requests

Changed in totem (Ubuntu):
assignee: nobody → xtknight (xt-knight)
importance: Undecided → High
status: New → In Progress
tags: added: kinetic regression-release rls-kk-incoming
tags: added: nvidia
summary: - totem crashes on startup (assert !xcb_xlib_unknown_req_in_deq) in
- _XReply because XInitThreads is not called early enough by libx11 (patch
- included)
+ [nvidia] totem crashes on startup (assert !xcb_xlib_unknown_req_in_deq)
+ in _XReply because XInitThreads is not called early enough by libx11
+ (patch included)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.