Skip to content

codegen: a module global demoted to runtime init inside a bundle fails silently (zeroed data or a late ICE) #2219

Closed

Description

@ehartford

Found on #2218 (D102). gen_module_constant folds a global's initializer with try_eval_const_llvm; a field it cannot fold demotes the WHOLE global to runtime init (queue_module_runtime_init). In a .wo bundle / standalone runtime object that init never runs (the comment at CodegenTraits.w try_eval_const_llvm, #880, records the class: pcre2's default match context lost heap_limit), and a body in another unit that takes the global's address hits BUG: reference rvalue N: place M has no address (mir_bind_global_locals binds only globals in module_constants).

Two silent tools:

  • with check … --validate-all says ok — the MIR is valid, so the validator is not the right place; but nothing between folding and codegen says "this global is runtime-initialized in an object whose init will not run".
  • the demotion itself is silent: it should be a loud refusal in bundle/standalone-object mode (name the global and the field that did not fold), never zeroed storage.

The D102 instance (Option[extern "C" fn] fields holding Some(fn)) is folded on #2218 (try_eval_const_option_pointer_llvm); this issue is the guard that would have caught it at the global instead of in a downstream body.

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