[Bug] RPC tracker TCPEventHandler._init_conn omits return after close() and PriorityScheduler has unlocked list/heap races

Aperta
#21,084 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

@Nanmur ci sta già lavorando.

Dal 29/11/2026.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Start in python/tvm/rpc/tracker.py at TCPEventHandler._init_conn() and PriorityScheduler (request(), _schedule(), put(), remove(), and summary()). Read the surrounding tracker code and existing tests for RPC handshakes and scheduler behavior. Done when malformed handshakes stop cleanly and concurrent scheduler operations no longer race; add or run focused tests for both cases.

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

Descrizione

needs-triage type: bug
Summary

In python/tvm/rpc/tracker.py:

  1. TCPEventHandler._init_conn() (tracker.py:201-212): Calls self.close() on invalid handshake length (len(message) != 4) and invalid magic without returning:
    if len(message) != 4:
        logger.warning("Invalid connection from %s", self.name())
        self.close()
    magic = struct.unpack("<i", message)[0]
    if magic != RPC_TRACKER_MAGIC:
        logger.warning("Invalid magic from %s", self.name())
        self.close()
    self.write_message(struct.pack("<i", RPC_TRACKER_MAGIC), binary=True)
    
    Non-4-byte payloads fall through to unhandled struct.error (not caught by TCPHandler._update_read, which only catches OSError), and invalid 4-byte magics fall through to write_message on a closed socket.
  2. PriorityScheduler (tracker.py:132-170): Acquires self._lock only around heapq.heappush in request() (lines 157-159), leaving _schedule(), put(), remove(), and summary() completely unlocked and racing on self._values and self._requests.
Affected Location
  • Repository: apache/tvm (main, python/tvm/rpc/tracker.py:132-170,201-212)
Minimal Standalone Reproduction
  • _init_conn(b"GET / HTTP/1.1") raises struct.error: unpack requires a buffer of 4 bytes.
  • _init_conn(b"BAD!") calls close() then write_message -> OSError: socket is already closed.
  • Concurrent threads calling PriorityScheduler.put(), request(), and remove() trigger ValueError: list.remove(x): x not in list / IndexError: pop from empty list.
Suggested Fix
  1. Add return after both self.close() calls in _init_conn().
  2. Protect put(), request(), remove(), summary(), and _schedule() with self._lock (using threading.RLock or releasing/avoiding re-entrant callbacks while mutating scheduler state).
Lingua principale
Python
Stelle
13.9k
Fork
4.1k
Merge medio
4g 22h
PR unite (30g)
22

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 apache/tvm

Tutte le issue di apache/tvm

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.