Skip to content

Internal consistency check failure ({{x,_},not_live} at allocate_heap) #11368

Description

@fixeria

Describe the bug
Compiling the module below fails with an internal consistency check failure on OTP 29.0.3. The same module compiles fine on OTP 29.0.1, so this appears to be a regression introduced in one of the 29.0.2/29.0.3 patch releases.

The trigger seems to be two chained setelement/3 calls on a tuple of unknown shape, where the first setelement stores a freshly built cons cell. Compiling with +no_type_opt (or +no_ssa_opt) makes the error go away, which points at the SSA type-optimization pass.

Originally observed while building the gen_netlink application (function netlink:prepare_request/2).

To Reproduce
Compile the following module with plain erlc repro.erl:

-module(repro).
-export([prepare_request/2]).

prepare_request(Msg0, Seq) ->
    Flags = element(3, Msg0),
    Msg1 = setelement(3, Msg0, [request | Flags]),
    setelement(4, Msg1, Seq).

Output on OTP 29.0.3:

repro:1: function prepare_request/2+7:
  Internal consistency check failed - please report this bug.
  Instruction: {allocate_heap,1,2,4}
  Error:       {{x,2},not_live}:

Notes:

  • Compiles cleanly on OTP 29.0.1.
  • erlc +no_type_opt repro.erl and erlc +no_ssa_opt repro.erl both succeed on 29.0.3.
  • Swapping the order of the two setelement/3 calls (setting element 4 first, then element 3) also avoids the failure:
prepare_request(Msg0, Seq) ->
    Flags = element(3, Msg0),
    Msg1 = setelement(4, Msg0, Seq),
    setelement(3, Msg1, [request | Flags]).

Expected behavior
The module compiles without errors, as it does on OTP 29.0.1.

Affected versions

  • Fails: OTP 29.0.3 (Erlang/OTP 29 [erts-17.0.3])
  • Works: OTP 29.0.1 (Erlang/OTP 29 [erts-17.0.1])

OTP 29.0.2 not tested.

Additional context

  • OS: Debian GNU/Linux forky/sid (x86_64), OTP 29.0.3 from Debian packages (erlang 1:29.0.3+dfsg-1).
  • Emulator: [64-bit] [smp:16:16] [jit:ns]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue is reported as a bug

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions