slint-ui/slint · warning · RuntimeError

unsupported MaybeUninit layout for SharedVector element type

Error message

unsupported MaybeUninit layout for SharedVector element type

What it means

The GDB pretty printer for Rust's SharedVector cannot extract the element type from the vector's internal MaybeUninit storage layout. It expects a struct field named value, __0, or 0 inside the element type; the compiled layout (variant of Rust stdlib version / debug info) doesn't match, so the printer aborts.

Solutions

  1. Update to the latest Slint version so the pretty printer matches your Rust stdlib layout.
  2. If you must patch locally, extend the field-name list in _element_type (gdb_pretty_printers.py) to match your stdlib's actual field names (`ptype raw_buf` in gdb reveals them).
  3. Debug with a stable toolchain matching the one the pretty printers were written against, or inspect the vector manually via its raw pointer/length fields.

Example fix

// before (in gdb_pretty_printers.py _element_type)
for sub in val_type.fields():
    if sub.name in ("value", "__0", "0"):
        return sub.type

// after: add the layout your stdlib uses
for sub in val_type.fields():
    if sub.name in ("value", "__0", "0", "manual"):
        return sub.type
Defensive patterns

Strategy: fallback

Prevention

When it happens

Trigger: Debugging (gdb with the slint pretty printers loaded) a process whose debug info presents SharedVector's raw internal buffer with an unexpected MaybeUninit layout — typically after a Rust/nightly stdlib change altering std::mem::MaybeUninit or RawVec internals.

Common situations: Using an older slint gdb_pretty_printers.py with a newer Rust toolchain whose layout changed; printing SharedVector values in optimized builds with incomplete debug info; nightly stdlib churn.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16). Data as JSON: /api/errors/e7bb546da51c053b. Report an issue: GitHub.

Appendix: source

Thrown at internal/core/gdb_pretty_printers.py:49

                yield f"[{i}]", (data_ptr + i).dereference()
        except Exception as e:
            yield "<error>", f"error reading elements: {e}"

    def display_hint(self):
        return "array"

    @staticmethod
    def _element_type(maybe_uninit_val):
        ty = maybe_uninit_val.type
        for field in ty.fields():
            if field.name == "value":
                val_type = field.type
                if val_type.code == gdb.TYPE_CODE_STRUCT:
                    for sub in val_type.fields():
                        if sub.name in ("value", "__0", "0"):
                            return sub.type
                return val_type
        raise RuntimeError(
            "unsupported MaybeUninit layout for SharedVector element type"
        )


class SharedVectorSubPrinter(gdb.printing.SubPrettyPrinter):
    def __init__(self):
        super().__init__("SharedVector")

    def __call__(self, val):
        if not self.enabled:
            return None
        t = val.type.strip_typedefs()
        if t.code == gdb.TYPE_CODE_PTR:  # also support reference to SharedVector
            try:
                val = val.dereference()
                t = val.type.strip_typedefs()
            except gdb.error:
                return None

View on GitHub (pinned to bb937076de)