Files
RedBear-OS/local/patches/libwayland/redox.patch
T
vasilito cb424d7448 build: static patch-sanity linter (shift-left the malformed-patch class)
verify-patch-sanity.py validates every active recipe .patch has internally-
consistent hunk line counts — catching the 'malformed patch at line N' failure
at commit/CI/preflight time instead of hours into a cook. This cycle hit that
class three times (qtwaylandscanner, sddm, xwayland), each only discovered when
cookbook tried to apply the patch.

Running it across the repo found 29 latent malformed patches (validated against
GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22').
They were harmless only because they sit in vendored recipes (baked, not re-
applied) — but would fail on any version-bump re-derivation. --fix recounts the
hunk headers (body untouched) and repaired all 29.

Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test
(test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats
(empty placeholders, bare-@@ git hunks).
2026-08-01 05:13:02 +03:00

102 lines
2.9 KiB
Diff

--- a/src/wayland-client.c.orig
+++ b/src/wayland-client.c
@@ -645,5 +645,24 @@ wl_proxy_add_listener(struct wl_proxy *proxy,
void (**implementation)(void), void *data)
{
+ /* Root-cause fix for the Qt6 Wayland null+8 crash. When the
+ * upstream proxy is NULL (e.g. wl_display_get_registry returns
+ * NULL because the handshake failed, or a wlr-style filter
+ * removed the global from the registry), the original code
+ * dereferences proxy at offset 8 — the listener vtable pointer
+ * — which is a NULL+8 page-fault on most ABIs. Return -1 here
+ * and log the caller's address so the failure can be diagnosed.
+ * Qt6 Wayland's qtwaylandscanner-generated init_listener()
+ * is the primary call site; with this guard, the call becomes
+ * a no-op when the bind failed, and the Qt frontend falls
+ * back to the standard "global not available" code path.
+ */
+ if (!proxy) {
+ fprintf(stderr,
+ "FATAL: wl_proxy_add_listener(NULL proxy) caller=%p -- returning error\n",
+ __builtin_return_address(0));
+ errno = EINVAL;
+ return -1;
+ }
if (proxy->flags & WL_PROXY_FLAG_WRAPPER)
wl_abort("Proxy %p is a wrapper\n", proxy);
@@ -2452,6 +2462,10 @@ WL_EXPORT uint32_t
WL_EXPORT uint32_t
wl_proxy_get_version(struct wl_proxy *proxy)
{
+ if (!proxy) {
+ errno = EINVAL;
+ return 0;
+ }
if (proxy->flags & WL_PROXY_FLAG_WRAPPER)
return proxy->version;
@@ -2470,4 +2490,8 @@ WL_EXPORT void
wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data)
{
+ if (!proxy) {
+ errno = EINVAL;
+ return;
+ }
proxy->user_data = user_data;
}
@@ -2480,4 +2510,8 @@ WL_EXPORT void *
wl_proxy_get_user_data(struct wl_proxy *proxy)
{
+ if (!proxy) {
+ errno = EINVAL;
+ return NULL;
+ }
return proxy->user_data;
}
@@ -2493,4 +2533,7 @@ WL_EXPORT void
wl_proxy_destroy(struct wl_proxy *proxy)
{
+ if (!proxy) {
+ return;
+ }
wl_proxy_destroy_common(proxy, 0);
}
--- a/src/wayland-server.c.orig
+++ b/src/wayland-server.c
@@ -2434,3 +2434,7 @@ wl_resource_set_user_data(struct wl_resource *resource, void *user_data)
{
+ if (!resource) {
+ errno = EINVAL;
+ return;
+ }
resource->data = user_data;
}
@@ -2444,3 +2449,7 @@ wl_resource_get_user_data(struct wl_resource *resource)
{
+ if (!resource) {
+ errno = EINVAL;
+ return NULL;
+ }
return resource->data;
}
@@ -2453,3 +2456,7 @@ wl_resource_get_version(struct wl_resource *resource)
{
+ if (!resource) {
+ errno = EINVAL;
+ return 0;
+ }
return resource->version;
}
--- a/src/meson.build.orig
+++ b/src/meson.build
@@ -81,7 +81,6 @@ endif
if meson.is_cross_build() or not get_option('scanner')
- scanner_dep = dependency('wayland-scanner', native: true, version: meson.project_version())
- wayland_scanner_for_build = find_program(scanner_dep.get_variable(pkgconfig: 'wayland_scanner'))
+ wayland_scanner_for_build = find_program('wayland-scanner', native: true)
else
wayland_scanner_for_build = wayland_scanner
endif