databendlabs/databend · error

MEMORY_EXCEEDS_LIMIT

MEMORY_EXCEEDS_LIMIT

Error message

memory allocation of {layout.size()} bytes failed

What it means

emit_walk_for_type handles Type::Path and a few other shapes; a Type::Path whose path has no final segment (an empty/degenerate path) produces this syn Error at compile time. It means the derive Walk/WalkMut encountered a field type it cannot even name.

Solutions

  1. Inspect the type at the reported span and replace the degenerate path with a concrete named type.
  2. Check whether a macro expansion is producing an empty type path; fix or work around that macro.
  3. If the type is legitimately unsupported (non-path, e.g. bare fn/trait object), expect error 406 instead and restructure it.

Example fix

// before
struct N { f: macro_returning_empty_path!() }
// after
struct N { f: ConcreteType }
Defensive patterns

Strategy: type-guard

Validate before calling

// compile-time check: field types must be nameable paths
fn assert_named_path<T>() {} // e.g. assert_named_path::<ConcreteFieldType>();

Prevention

When it happens

Trigger: A field whose type is a syntactically degenerate type path (no segments) inside a type deriving Visit/WalkMut.

Common situations: Macro-generated or heavily manipulated types (e.g. from another macro) that yield empty paths; unusual type syntax such as bare associated-type edges produced by nested macros.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11). Data as JSON: /api/errors/d4297b1487ebe38d. Report an issue: GitHub.

Appendix: source

Thrown at src/common/base/src/runtime/memory/alloc_error_hook.rs:48

    mark_alloc_error_panic();
}

pub fn take_alloc_error_panic() -> bool {
    ALLOC_ERROR_PANIC.with(|flag| flag.replace(false))
}

pub fn is_alloc_error_panic() -> bool {
    ALLOC_ERROR_PANIC.with(|flag| flag.get())
}

pub fn set_alloc_error_hook() {
    std::alloc::set_alloc_error_hook(|layout| {
        let _guard = LimitMemGuard::enter_unlimited();

        let out_of_limit_desc = ThreadTracker::replace_error_message(None);
        mark_alloc_error_panic();

        panic!(
            "{}",
            out_of_limit_desc
                .unwrap_or_else(|| format!("memory allocation of {} bytes failed", layout.size()))
        );
    })
}

View on GitHub (pinned to 288d84d76e)