Skip to content

[GTK3] Gdk-CRITICAL from gdk_threads_set_lock_functions when a second Display is created in the same JVM #3556

Description

@minduch

Describe the bug

On Linux/GTK3, SWT emits a Gdk-CRITICAL from gdk_threads_set_lock_functions:

(SWT:1664323): Gdk-CRITICAL **: 15:19:27.874: gdk_threads_set_lock_functions: assertion 'gdk_threads_lock == NULL && gdk_threads_unlock == NULL' failed

gdk_threads_set_lock_functions() has been deprecated since GTK 3.6, and its
implementation asserts that the lock functions have not already been installed. The
assertion therefore fails on any call after the first one in a process. This appears
to happen whenever a second Display is created in the same JVM.

Nothing fails as a result — the tests pass and the process does not crash — but the
CRITICAL is emitted on stderr on every affected run, which makes it noise in build
logs where a real GTK CRITICAL would matter.

Seen while running Tycho UI tests (org.eclipse.tycho.surefire.osgibooter.uitest),
where an Equinox workbench is provisioned per test module. The display is a normal
Xorg X11 session, not Xvfb and not headless.

To Reproduce

Run this on Linux/GTK3:

import org.eclipse.swt.widgets.Display;

public class Snippet {
    public static void main(String[] args) {
        Display d1 = new Display();
        d1.dispose();
        Display d2 = new Display();   // Gdk-CRITICAL is emitted here
        d2.dispose();
    }
}

Expected behavior

Creating a second Display in the same process should not emit a GTK CRITICAL. SWT
should either not call the deprecated gdk_threads_set_lock_functions() at all, or
call it only once per process.

Screenshots

Not applicable — the symptom is stderr output.

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc)

    Ubuntu 24.04.4 LTS, aarch64, kernel 6.17.0-1031-nvidia.
    GTK 3.24.41-4ubuntu1.3 (libgtk-3-0t64:arm64). No GTK4 package installed and
    SWT_GTK4 is unset, so this is the GTK3 binding.
    Real X session: XDG_SESSION_TYPE=x11, Xorg on vt2 under gdm, DISPLAY=:0.
    Not headless, not Xvfb, not Xwayland.
    NVIDIA GPU present (PCI 10de:2e12).

  2. JRE/JDK version

    Eclipse Temurin 25.0.4.1+1 (OpenJDK 25.0.4.1 LTS), aarch64

Version since

Unknown. First observed with org.eclipse.swt.gtk.linux.aarch64 3.135.0 on the
Eclipse 2026-09 RC1 (4.41) target platform. Not checked against earlier versions,
so this is first-observed rather than a regression point.

Workaround (or) Additional context

No workaround known; the message is diagnostic only and nothing observable fails.

This is a pre-release target platform (2026-09 RC1), not a final release build.
SWT bundle qualifier:

Two further messages appear in the same runs. They are noted here only so they are
not mistaken for part of this issue:

  • (SWT:1664323): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate widget with width -1 and height -1 — a separate SWT/GTK issue, not reported here.
  • pci id for fd 232: 10de:2e12, driver (null) — Mesa probing DRM file descriptors
    for an NVIDIA device it has no driver mapping for. Not SWT.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions