NetBSD Problem Report #59096
From tsutsui@ceres.dti.ne.jp Mon Feb 24 10:10:31 2025
Return-Path: <tsutsui@ceres.dti.ne.jp>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
client-signature RSA-PSS (2048 bits) client-digest SHA256)
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 9BD381A923A
for <gnats-bugs@gnats.NetBSD.org>; Mon, 24 Feb 2025 10:10:31 +0000 (UTC)
Message-Id: <202502241010.51OAALwr016360@ceres.dti.ne.jp>
Date: Mon, 24 Feb 2025 19:10:22 +0900 (JST)
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Reply-To: tsutsui@ceres.dti.ne.jp
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: qt6 apps with qt6-qtbase don't work on NetBSD/earmv7hf 10.1
X-Send-Pr-Version: 3.95
>Number: 59096
>Category: pkg
>Synopsis: qt6 apps with qt6-qtbase don't work on NetBSD/earmv7hf 10.1
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: pkg-manager
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Feb 24 10:15:01 +0000 2025
>Closed-Date: Sat Sep 13 15:09:00 +0000 2025
>Last-Modified: Sat Sep 13 15:09:00 +0000 2025
>Originator: Izumi Tsutsui
>Release: NetBSD 10.1
>Organization:
>Environment:
System: NetBSD armv7 10.1 NetBSD 10.1 (GENERIC) #0: Mon Dec 16 13:08:11 UTC 2024 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/evbarm/compile/GENERIC evbarm
Architecture: earmv7hf
Machine: evbarm
>Description:
It looks all qt6 applications (like PC6001VX) get SIGABRT on loading
qt6 plugins during startup:
---
armv7-% PC6001VX
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Abort (core dumped)
armv7-%
---
The following simple Qt6 applications (one window with a quit button)
also gets SIGABRT:
---
armv7-# PKG_PATH=https://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/earmv7hf/10.1/All pkg_add -uv qt6-qtbase qt6-qttools
armv7-# exit
armv7$ cat > sample.pro <<EOF
QT += core gui
CONFIG += c++17
SOURCES += main.cpp
greaterThan(QT_MAJOR_VERSION, 5): QT += widgets
EOF
armv7$ cat > main.cpp <<EOF
#include <QApplication>
#include <QPushButton>
#include <QWidget>
#include <QVBoxLayout>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QWidget window;
window.setWindowTitle("Main Window");
QVBoxLayout layout;
QPushButton button("Quit");
layout.addWidget(&button);
QObject::connect(&button, &QPushButton::clicked, &app, &QApplication::quit);
window.setLayout(&layout);
window.resize(200, 100);
window.show();
return app.exec();
}
EOF
armv7$ /usr/pkg/qt6/bin/qmake sample.pro
Info: creating stash file /r/work/win/qt6-test/.qmake.stash
armv7$ make
c++ -c -O2 -O2 -D_NETBSD_SOURCE -I/usr/pkg/include -I/usr/include -I/usr/include/krb5 -I/usr/pkg/lib/dbus-1.0/include/dbus -I/usr/pkg/include/glib-2.0 -I/usr/pkg/include/gio-unix-2.0 -I/usr/pkg/lib/glib-2.0/include -I/usr/pkg/include/harfbuzz -I/usr/pkg/include/freetype2 -I/usr/pkg/include/python3.12 -I/usr/X11R7/include -I/usr/X11R7/include/libdrm -Wall -Wextra -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -O2 -D_NETBSD_SOURCE -I/usr/pkg/include -I/usr/include -I/usr/include/krb5 -I/usr/pkg/lib/dbus-1.0/include/dbus -I/usr/pkg/include/glib-2.0 -I/usr/pkg/include/gio-unix-2.0 -I/usr/pkg/lib/glib-2.0/include -I/usr/pkg/include/harfbuzz -I/usr/pkg/include/freetype2 -I/usr/pkg/include/python3.12 -I/usr/X11R7/include -I/usr/X11R7/include/libdrm -Wno-register -std=gnu++1z -Wall -Wextra -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I/usr/pkg/qt6/include -I/usr/pkg/qt6/include/QtWidgets -I/usr/pkg/qt6/include/QtGui -I/usr/pkg/qt6/include/QtCore -I. -I/u!
sr/X11R7/include -I/usr/X11R7/include -I/usr/pkg/include -I/usr/pkg/qt6/mkspecs/netbsd-g++ -o main.o main.cpp
g++ -lexecinfo -Wl,-R/usr/pkg/qt6/lib -L/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -Wl,-R/usr/pkg/lib -L/usr/X11R7/lib -Wl,-R/usr/X11R7/lib -latomic -Wl,-O1 -pthread -Wl,-rpath,/usr/pkg/qt6/lib -o sample main.o -L/usr/pkg/lib -L/usr/X11R7/lib /usr/pkg/qt6/lib/libQt6Widgets.so /usr/pkg/qt6/lib/libQt6Gui.so /usr/pkg/qt6/lib/libQt6Core.so -lGL
armv7$ ./sample
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Abort (core dumped)
armv7$
---
Per debug messages by "QT_DEBUG_PLUGINS=1" it looks
all plugin files under /usr/pkg/qt6/plugins/platforms/ are not
recoginized properly?
---
armv7$ QT_DEBUG_PLUGINS=1 ./sample
qt.core.plugin.factoryloader: checking directory path "/usr/pkg/qt6/plugins/platforms" ...
qt.core.plugin.factoryloader: looking at "libqeglfs.so"
qt.core.plugin.loader: Failed to find metadata in lib /usr/pkg/qt6/plugins/platforms/libqeglfs.so: '/usr/pkg/qt6/plugins/platforms/libqeglfs.so' is not a Qt plugin (metadata not found)
qt.core.plugin.factoryloader: "Failed to extract plugin meta data from '/usr/pkg/qt6/plugins/platforms/libqeglfs.so': '/usr/pkg/qt6/plugins/platforms/libqeglfs.so' is not a Qt plugin (metadata not found)"
not a plugin
qt.core.plugin.factoryloader: looking at "libqminimal.so"
qt.core.plugin.loader: Failed to find metadata in lib /usr/pkg/qt6/plugins/platforms/libqminimal.so: '/usr/pkg/qt6/plugins/platforms/libqminimal.so' is not a Qt plugin (metadata not found)
qt.core.plugin.factoryloader: "Failed to extract plugin meta data from '/usr/pkg/qt6/plugins/platforms/libqminimal.so': '/usr/pkg/qt6/plugins/platforms/libqminimal.so' is not a Qt plugin (metadata not found)"
not a plugin
qt.core.plugin.factoryloader: looking at "libqminimalegl.so"
qt.core.plugin.loader: Failed to find metadata in lib /usr/pkg/qt6/plugins/platforms/libqminimalegl.so: '/usr/pkg/qt6/plugins/platforms/libqminimalegl.so' is not a Qt plugin (metadata not found)
qt.core.plugin.factoryloader: "Failed to extract plugin meta data from '/usr/pkg/qt6/plugins/platforms/libqminimalegl.so': '/usr/pkg/qt6/plugins/platforms/libqminimalegl.so' is not a Qt plugin (metadata not found)"
not a plugin
qt.core.plugin.factoryloader: looking at "libqoffscreen.so"
qt.core.plugin.loader: Failed to find metadata in lib /usr/pkg/qt6/plugins/platforms/libqoffscreen.so: '/usr/pkg/qt6/plugins/platforms/libqoffscreen.so' is not a Qt plugin (metadata not found)
qt.core.plugin.factoryloader: "Failed to extract plugin meta data from '/usr/pkg/qt6/plugins/platforms/libqoffscreen.so': '/usr/pkg/qt6/plugins/platforms/libqoffscreen.so' is not a Qt plugin (metadata not found)"
not a plugin
qt.core.plugin.factoryloader: looking at "libqvnc.so"
qt.core.plugin.loader: Failed to find metadata in lib /usr/pkg/qt6/plugins/platforms/libqvnc.so: '/usr/pkg/qt6/plugins/platforms/libqvnc.so' is not a Qt plugin (metadata not found)
qt.core.plugin.factoryloader: "Failed to extract plugin meta data from '/usr/pkg/qt6/plugins/platforms/libqvnc.so': '/usr/pkg/qt6/plugins/platforms/libqvnc.so' is not a Qt plugin (metadata not found)"
not a plugin
qt.core.plugin.factoryloader: looking at "libqxcb.so"
qt.core.plugin.loader: Failed to find metadata in lib /usr/pkg/qt6/plugins/platforms/libqxcb.so: '/usr/pkg/qt6/plugins/platforms/libqxcb.so' is not a Qt plugin (metadata not found)
qt.core.plugin.factoryloader: "Failed to extract plugin meta data from '/usr/pkg/qt6/plugins/platforms/libqxcb.so': '/usr/pkg/qt6/plugins/platforms/libqxcb.so' is not a Qt plugin (metadata not found)"
not a plugin
qt.core.plugin.factoryloader: checking directory path "/r/work/win/qt6-test/platforms" ...
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Abort (core dumped)
armv7$
---
The same sample program works fine on NetBSD/i386 10.1:
---
i386$ QT_DEBUG_PLUGINS=1 ./sample
qt.core.plugin.factoryloader: checking directory path "/usr/pkg/qt6/plugins/platforms" ...
qt.core.plugin.factoryloader: looking at "libqeglfs.so"
qt.core.plugin.loader: Found metadata in lib /usr/pkg/qt6/plugins/platforms/libqeglfs.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"eglfs"
]
},
"archlevel": 0,
"className": "QEglFSIntegrationPlugin",
"debug": false,
"version": 395264
}
qt.core.plugin.factoryloader: Got keys from plugin meta data QList("eglfs")
qt.core.plugin.factoryloader: looking at "libqminimal.so"
qt.core.plugin.loader: Found metadata in lib /usr/pkg/qt6/plugins/platforms/libqminimal.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"minimal"
]
},
"archlevel": 0,
"className": "QMinimalIntegrationPlugin",
"debug": false,
"version": 395264
}
qt.core.plugin.factoryloader: Got keys from plugin meta data QList("minimal")
qt.core.plugin.factoryloader: looking at "libqminimalegl.so"
qt.core.plugin.loader: Found metadata in lib /usr/pkg/qt6/plugins/platforms/libqminimalegl.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"minimalegl"
]
},
"archlevel": 0,
"className": "QMinimalEglIntegrationPlugin",
"debug": false,
"version": 395264
}
qt.core.plugin.factoryloader: Got keys from plugin meta data QList("minimalegl")
qt.core.plugin.factoryloader: looking at "libqoffscreen.so"
qt.core.plugin.loader: Found metadata in lib /usr/pkg/qt6/plugins/platforms/libqoffscreen.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"offscreen"
]
},
"archlevel": 0,
"className": "QOffscreenIntegrationPlugin",
"debug": false,
"version": 395264
}
qt.core.plugin.factoryloader: Got keys from plugin meta data QList("offscreen")
qt.core.plugin.factoryloader: looking at "libqvnc.so"
qt.core.plugin.loader: Found metadata in lib /usr/pkg/qt6/plugins/platforms/libqvnc.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"vnc"
]
},
"archlevel": 0,
"className": "QVncIntegrationPlugin",
"debug": false,
"version": 395264
}
:
---
>How-To-Repeat:
See above.
>Fix:
No idea.
---
Izumi Tsutsui
>Release-Note:
>Audit-Trail:
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@netbsd.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: pkg/59096: qt6 apps with qt6-qtbase don't work on NetBSD/earmv7hf
10.1
Date: Mon, 8 Sep 2025 04:28:56 +0900
> >Synopsis: qt6 apps with qt6-qtbase don't work on NetBSD/earmv7hf 10.1
This is caused by incorrect alignment rounding in ELF note parser.
src/corelib/plugin/qelfparser_p.cpp:scanProgramHeadersForNotes()
has the following calculations to search and parse note sections:
https://github.com/qt/qtbase/blob/6.8.3/src/corelib/plugin/qelfparser_p.cpp#L619-L630
```
// overflow check: calculate where the next note will be, if it exists
T::Off next_offset = offset;
next_offset += sizeof(T::Nhdr); // can't overflow (we checked above)
next_offset += NoteAlignment - 3; // offset is aligned, this can't overflow
if (qAddOverflow<T::Off>(next_offset, n_namesz, &next_offset))
break;
next_offset &= -NoteAlignment;
next_offset += NoteAlignment - 3; // offset is aligned, this can't overflow
if (qAddOverflow<T::Off>(next_offset, n_descsz, &next_offset))
break;
next_offset &= -NoteAlignment;
```
I'm not sure where 'NoteAlignment - 3' comes from (3 should be 1?),
but NetBSD/earmv7hf binaries has .note.netbsd.march section where
n_descsz==9 and in that case the above rounding calculation add
only 8 bytes to `next_offset` rather than 12 bytes, so it fails
to find the next .note.qt.metadata section.
It would be simpler to use explicit roundup calculations
(pulled from local patches/patch-src_corelib_plugin_qelfparser__p.cpp):
```
$NetBSD$
- fix wrong alignment calculations that could fail on NetBSD/earmv7hf
where n_descsz==9 in .note.netbsd.march section just before
.not.qt.metadata
--- src/corelib/plugin/qelfparser_p.cpp.orig 2024-10-01 10:46:30.000000000 +0000
+++ src/corelib/plugin/qelfparser_p.cpp
@@ -619,15 +619,15 @@ static QLibraryScanResult scanProgramHea
// overflow check: calculate where the next note will be, if it exists
T::Off next_offset = offset;
next_offset += sizeof(T::Nhdr); // can't overflow (we checked above)
- next_offset += NoteAlignment - 3; // offset is aligned, this can't overflow
- if (qAddOverflow<T::Off>(next_offset, n_namesz, &next_offset))
+ // roundup n_namesz and n_descsz to NoteAlignment
+ const T::Off AlignOffset = T::Off(NoteAlignment - 1);
+ const T::Off AlignMask = ~AlignOffset;
+ const T::Off round_namesz = (T::Off(n_namesz) + AlignOffset) & AlignMask;
+ const T::Off round_descsz = (T::Off(n_descsz) + AlignOffset) & AlignMask;
+ if (qAddOverflow<T::Off>(next_offset, round_namesz, &next_offset))
break;
- next_offset &= -NoteAlignment;
-
- next_offset += NoteAlignment - 3; // offset is aligned, this can't overflow
- if (qAddOverflow<T::Off>(next_offset, n_descsz, &next_offset))
+ if (qAddOverflow<T::Off>(next_offset, round_descsz, &next_offset))
break;
- next_offset &= -NoteAlignment;
if (next_offset > end_offset)
break;
```
---
Izumi Tsutsui
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@netbsd.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: pkg/59096: qt6 apps with qt6-qtbase don't work on NetBSD/earmv7hf10.1
Date: Mon, 8 Sep 2025 23:12:59 +0900
The following minimum diff also works.
(not sure what "offset is aligned, this can't overflow" comments meant)
```
$NetBSD$
- fix wrong alignment calculations that could fail on NetBSD/earmv7hf
where n_descsz==9
--- src/corelib/plugin/qelfparser_p.cpp.orig 2024-10-01 10:46:30.000000000 +0000
+++ src/corelib/plugin/qelfparser_p.cpp
@@ -619,12 +619,12 @@ static QLibraryScanResult scanProgramHea
// overflow check: calculate where the next note will be, if it exists
T::Off next_offset = offset;
next_offset += sizeof(T::Nhdr); // can't overflow (we checked above)
- next_offset += NoteAlignment - 3; // offset is aligned, this can't overflow
+ next_offset += NoteAlignment - 1; // offset is aligned, this can't overflow
if (qAddOverflow<T::Off>(next_offset, n_namesz, &next_offset))
break;
next_offset &= -NoteAlignment;
- next_offset += NoteAlignment - 3; // offset is aligned, this can't overflow
+ next_offset += NoteAlignment - 1; // offset is aligned, this can't overflow
if (qAddOverflow<T::Off>(next_offset, n_descsz, &next_offset))
break;
next_offset &= -NoteAlignment;
```
---
Izumi Tsutsui
From: "Izumi Tsutsui" <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59096 CVS commit: pkgsrc/x11/qt6-qtbase
Date: Sat, 13 Sep 2025 14:31:53 +0000
Module Name: pkgsrc
Committed By: tsutsui
Date: Sat Sep 13 14:31:53 UTC 2025
Modified Files:
pkgsrc/x11/qt6-qtbase: Makefile distinfo
Added Files:
pkgsrc/x11/qt6-qtbase/patches:
patch-src_corelib_plugin_qelfparser__p.cpp
Log Message:
qt6-qtbase: add a patch for PR/59096 (qt6 apps fails on NetBSD/earmv7hf).
Bump PKGREVISION.
To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 pkgsrc/x11/qt6-qtbase/Makefile
cvs rdiff -u -r1.22 -r1.23 pkgsrc/x11/qt6-qtbase/distinfo
cvs rdiff -u -r0 -r1.4 \
pkgsrc/x11/qt6-qtbase/patches/patch-src_corelib_plugin_qelfparser__p.cpp
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sat, 13 Sep 2025 15:09:00 +0000
State-Changed-Why:
Fix applied.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.49 2026/05/14 01:52:41 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.