Skip to content

dmrg: refuse MEASURE_* parameters with a clear error instead of SIGSEGV - #101

Open
skilledwolf wants to merge 1 commit into
ALPSim:masterfrom
skilledwolf:fix/dmrg-measure-segv
Open

dmrg: refuse MEASURE_* parameters with a clear error instead of SIGSEGV#101
skilledwolf wants to merge 1 commit into
ALPSim:masterfrom
skilledwolf:fix/dmrg-measure-segv

Conversation

@skilledwolf

Copy link
Copy Markdown
Collaborator

Problem

The classic dmrg binary crashes with SIGSEGV on every input that requests MEASURE_LOCAL, MEASURE_AVERAGE, MEASURE_CORRELATIONS, or MEASURE_STRUCTURE_FACTOR: dmtk::System::rotate_hami dereferences the result of System::operator()(op) without a null check, and the lookup legitimately returns 0 while a measurement operator's site is not yet covered by the current block layout during early final_sweep iterations near the chain endpoints. Diagnosed with lldb: BasicOp::is_diagonal called on this == 0x0 via rotate_hami.

A skip-null guard at the call sites is not a fix: it compiles but silently drops legitimate measurement terms wholesale (a Sz_total=2 local-Sz sum comes out as 0.15 instead of 2). Correctly fixing the legacy path needs the block operator-set bookkeeping re-derived so measurement operators are guaranteed present at every iteration.

Fix

Until someone does that surgery, fail fast in DMRGTask::dostep with an actionable message when any MEASURE_* parameter is present. Since #92 removed the mps_optim application (which supported the same MEASURE_* syntax), the message suggests dropping the MEASURE_* parameters (energy/entropy still work) or using an ALPS release that still ships mps_optim.

How to reproduce

Save as parm:

LATTICE="open chain lattice"
MODEL="spin"
local_S=1/2
CONSERVED_QUANTUMNUMBERS="Sz"
Sz_total=0
J=1
L=8
SWEEPS=2
NUMBER_EIGENVALUES=1
MAXSTATES=32
MEASURE_LOCAL[Local Sz]=Sz
{}
parameter2xml parm
dmrg parm.in.xml ; echo "exit=$?"
  • on master: exit=139 (SIGSEGV) mid-sweep, empty stderr
  • with the fix: clean nonzero exit with a single-line explanation of what is unsupported and why
  • delete the MEASURE_LOCAL line and the identical run completes unchanged (exit=0) — the guard only fires when a MEASURE_* parameter is present

The same crash reproduces with MEASURE_AVERAGE, MEASURE_CORRELATIONS, and MEASURE_STRUCTURE_FACTOR (the old dmrg-03/dmrg-04 tutorial inputs were public reproducers before the tutorials were removed).

Provenance

Diagnosed and guarded in a downstream ALPS modernization fork, where the guard is pinned by an API regression test asserting the non-signal exit code and the actionable stderr text.

The classic dmrg binary crashes with SIGSEGV on every input that
requests MEASURE_LOCAL, MEASURE_AVERAGE, MEASURE_CORRELATIONS, or
MEASURE_STRUCTURE_FACTOR (tutorials dmrg-03 and dmrg-04 are visible
consumers): dmtk::System::rotate_hami dereferences the result of
System::operator()(op) without a null check, and the lookup
legitimately returns 0 while a measurement operator's site is not yet
covered by the current block layout during early final_sweep
iterations near the chain endpoints.
A skip-null guard at the call sites is NOT a fix: it compiles but
silently drops legitimate measurement terms wholesale (Sz_total=2
sums to 0.15 instead of 2). Correctly fixing the legacy path needs
the block operator-set bookkeeping re-derived so measurement
operators are guaranteed present at every iteration. Until someone
does that surgery, fail fast in DMRGTask::dostep with an actionable
message pointing at the mps_optim binary, which accepts the same
parameter-file syntax and measures correctly.
Before: rc=139 (SIGSEGV), empty stderr. After: clean nonzero exit
with a single-line explanation.
Diagnosed (lldb: BasicOp::is_diagonal called on this=0x0 via
rotate_hami) and fixed by the ALPS modernization fork, where the
guard is pinned by an API regression test asserting the non-signal
exit code and the actionable stderr text.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

v2: reworded the guidance — mps_optim was removed upstream (PR ALPSim#92), so the error now suggests dropping MEASURE_* or using a release that still ships mps_optim.
@skilledwolf
skilledwolf marked this pull request as ready for review July 19, 2026 13:44
@egull

egull commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

@afeiguin give me a sign of life here – do you have capacity to deal with this or should we sign up others?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants