Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#259 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 5 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp, reverse-engineering

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
C++
Stelle
3.3k
Fork
149
Merge medio
5g 10h
PR unite (30g)
4

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ran-j/PS2Recomp

Tutte le issue di ran-j/PS2Recomp

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.