emscripten-core / emscripten-core/emscripten
Signed shift on memory access in library_webgl.js when using 4GB support
- Lingua principale
- C++
- Stelle
- 27.6k
- Fork
- 3.6k
- Merge medio
- 1g 14h
- PR unite (30g)
- 125
Descrizione
When using 4GB support, my understanding is that memory accesses are rewritten to use unsigned shifts. In library_webgl.js, [glUniform4fv](https://github.com/emscripten-core/emscripten/blob/0a6f54b1276481fab90e474f2c4fd35d00c5fa6b/src/library_webgl.js#L2663) is rewritten from:
```
value >>= 2;
for (var i = 0; i < 4 * count; i += 4) {
var dst = value + i;
view[i] = heap[dst];
view[i + 1] = heap[dst + 1];
view[i + 2] = heap[dst + 2];
view[i + 3] = heap[dst + 3];
}
```
to:
```
value >>= 2;
for (var i = 0; i < 4 * count; i += 4) {
var dst = value + i;
view[i] = heap[dst >>> 0];
view[i + 1] = heap[dst + 1 >>> 0];
view[i + 2] = heap[dst + 2 >>> 0];
view[i + 3] = heap[dst + 3 >>> 0];
}
```
The memory accesses inside the loop look correct but should `value >>= 2` be `value >>>= 2`? With `value >>= 2`, I get memory accesses that read out of bounds. Possibly the same issue [here](https://github.com/emscripten-core/emscripten/blob/0a6f54b1276481fab90e474f2c4fd35d00c5fa6b/src/library_webgl.js#L2813). Let me know if I'm misunderstanding the expected output.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Esamina il codice di glUniform4fv intorno alla riga 2663 in src/library_webgl.js, quindi confronta l’accesso simile intorno alla riga 2813. Esegui un caso con supporto per 4GB che eserciti queste letture della memoria WebGL e verifica che gli accessi rimangano entro i limiti e utilizzino l’indirizzamento riscritto previsto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, wasm
- Ambito
- computer-graphics
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100