Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Runtime: GuestThread::stack holds a base after CreateThread but a top after SetupThread

Abierto
#259 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 5 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cpp, reverse-engineering

Línea de trabajo

Start in ps2xRuntime/include/runtime/ee_scheduler.h and the CreateThread, SetupThread/InitMainThread, and startThread paths that write or read GuestThread::stack. Align SetupThread so it stores a base like CreateThread (or add an explicit stackTop) so consumers can recover the stack extent without guessing from RAM size. Confirm every use of thread.stack still computes the same SP after the change.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

What happens

GuestThread::stack (ps2xRuntime/include/runtime/ee_scheduler.h) does not mean the same thing depending on how the thread was created:

  • CreateThread stores the base: thread.stack = params.stack, and startThread computes the top as stack + stackSize.
  • SetupThread / InitMainThread stores the top: it writes the sp it has just computed into the same field.

Any consumer that wants a thread's stack extent therefore cannot trust the field. This surfaced while deriving an allocation ceiling from the declared thread stacks (companion issue about invocation stacks aliasing thread stacks).

Workaround used downstream

Disambiguating on the arithmetic, since a base plus a size cannot exceed RAM:

uint32_t base = thread.stack;
if (static_cast<uint64_t>(thread.stack) + thread.stackSize > PS2_RAM_SIZE)
{
    if (thread.stack < thread.stackSize) { continue; }
    base = thread.stack - thread.stackSize;   // it was a top
}

It works, but it is a guess recovered from a value that should not have been ambiguous.

Suggested fix

Make SetupThread record a base, as CreateThread does, and let startThread derive the top. Or, if both conventions must coexist, give GuestThread an explicit stackTop field instead of overloading one.


Found while statically recompiling Ridge Racer V (NTSC-U, SLUS_200.02) with PS2Recomp.
Tested on commit 75d729ce; main was c5a9d02 at the time of writing, one README-only commit ahead.
Host: Windows 11 x64, clang-cl 22.1.3 + Ninja, MSVC toolset 14.51.36231, Windows SDK 10.0.26100.0, CMake 4.2.3.
None of these are specific to this game.

Lenguaje dominante
C++
Estrellas
3.3k
Forks
149
Merge medio
5 d 10 h
PR fusionados (30 d)
4

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

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ran-j/PS2Recomp

Todos los issues de ran-j/PS2Recomp

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.