SGFragment::getAtomCoordinates warns on a bad index and then reads out of range
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 55/100
Línea de trabajo
Read src/viz/sgcommands/SGFragment.C around line 249 and inspect callers of Fragment::atomIndex, whose implementation is at src/tdat/chemistry/Fragment.C:3859. First check how callers handle the not-found INT_MAX result and whether getAtomCoordinates can safely return early. Done means invalid indices cannot reach the vector access, the boundary check rejects index == size(), and relevant callers are audited.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
SGFragment::getAtomCoordinates (src/viz/sgcommands/SGFragment.C:249) guards the index like this:
EE_RT_ASSERT(index<=p_atoms.size(), EE_WARNING, "index exceeds atoms");
const double *coords = p_atoms[index]->coordinates();
Two faults in two lines:
- The severity is
EE_WARNING, so a bad index logs a line and then falls straight intop_atoms[index]. The check does not protect anything. - The comparison is
<=, off by one:index == size()passes the guard and is still out of range.
The usual source of a bad index is Fragment::atomIndex, which returns INT_MAX when the atom is not found (src/tdat/chemistry/Fragment.C:3859). That return value is not exceptional: TAtm::operator== is identity-based (return (this == &atom);, src/tdat/chemistry/TAtm.C:237), so any atom belonging to a different Fragment yields INT_MAX, even when the two fragments hold the same molecule. p_atoms[INT_MAX] is then a read about 17 GB past the vector's data pointer — in practice a SIGSEGV, undefined behaviour in principle.
Found while diagnosing #1306, where a process-wide dragger event makes one Builder tab run its move callback against another tab's atoms and reach exactly this path. The scoping fix for #1306 closes that one caller; this guard is the shared hazard behind it, and every caller that passes an atomIndex result is exposed.
Suggested fix: make the guard an early return (or an EE_FATAL if callers cannot sensibly continue) and correct <= to <. Then audit the callers of Fragment::atomIndex for unchecked INT_MAX.
- Lenguaje dominante
- C
- Estrellas
- 10
- Forks
- 8
- Merge medio
- 6 h 32 min
- PR fusionados (30 d)
- 1
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de FriendsofECCE/ECCE
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
FriendsofECCE/ECCE#1358 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
FriendsofECCE/ECCE#1353 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
FriendsofECCE/ECCE#1348 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
FriendsofECCE/ECCE#1347 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
FriendsofECCE/ECCE#1345 ·
Todos los issues de FriendsofECCE/ECCE
Issues similares
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Life-Framework/Life-Framework#5378 ·
Los mantenedores suelen responder en 1 día
-
Bug Status: Needs Triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
bug status: planned ui
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
ChupathingyCE/chupathingyce#2126 ·
Los mantenedores suelen responder en 1 día
-
good first issue simulation
Dificultad 1/5 1-3 horas Aptitud para principiantes 92/100
MarcosAsh/Lattice_Fluid_Dynamics#270 ·
Los mantenedores suelen responder en 1 día
-
needs-kind
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
falcosecurity/libs#3173 · 1 comentario ·
Los mantenedores suelen responder en 1 día