Skip to content

[Particle I/O] Potential bug from AI-agent audit: host_idcpu sizing mismatch in ReadParticles #4964

@hanfluid

Description

@hanfluid

Baseline checked on 2026-02-22:

  • development: 98bce0678fe1129b3df19e558c0fb21350e5f0b0 (2026-02-21)
  • release 26.02: 33007cb7d8798b53082323275ae70ead3e1e9ffa (2026-02-02)

In ReadParticles, host_idcpu is sized with current runtime finest level, while other host vectors are sized with finest_level_in_file:

  • Src/Particle/AMReX_ParticleIO.H:982-998

Current code:

host_particles.resize(finest_level_in_file+1);
host_real_attribs.resize(finest_level_in_file+1);
host_int_attribs.resize(finest_level_in_file+1);
host_idcpu.resize(finestLevel()+1); // mismatch

Restart() explicitly supports reading files with more levels than current run (finest_level_in_file > finestLevel()), and ReadParticles then indexes by lev from file context.

Trigger

SoA path when restarting from checkpoint with more levels than current run.

Expected

host_idcpu.resize(finest_level_in_file+1);

Impact

Out-of-bounds access risk on host_idcpu[lev] for lev > finestLevel().

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions