soundness: an assignment to a `const` is accepted, and a `roarray` const is written in place
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 76/100
Direzione di ricerca
Inizia dal TODO in lang/check/type.go intorno alle righe 625–634, dove il checker risolve un nome a cui viene assegnato un valore come const; confronta i controlli del parser sugli assignee in lang/parse/parse.go intorno alle righe 960–975. Aggiungi o esegui un test di regressione del checker per entrambi i repro dell’issue, quello con roarray e quello scalare. Il lavoro è concluso quando il checking rifiuta le assegnazioni ai nomi const.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hi,
General context of this work is in #188, including the AI-disclaimers.
No in-tree codec is affected by this issue; std never assigns to a const. Claude judges the prospective risk of it as "moderate": assigning to a roarray const writes static const storage, crashing under MSVC and gcc -O0; gcc -O1 drops the write. Assigning to a scalar const generates C that does not compile.
The following is Sol 6.1's writeup of the issue. Includes two repros, generated C, MSVC and gcc driver runs for the array case, and gcc and clang compile errors for the scalar case. The cause is reasoned from source.
The checker accepts an assignment to a const. For a roarray const, cgen emits a memcpy into the static const array; for a scalar const, it emits the constant's value as the assignee.
Minimal repro:
pri const T : roarray[2] base.u8 = [1, 2]
pub struct tester?(
d : array[2] base.u8,
)
pub func tester.set!() {
T = this.d
}
Actual: at b36a81d3, wuffs-c gen -package_name repro array.wuffs exits 0 with empty stderr. T is emitted as static const uint8_t WUFFS_REPRO__T[2], and set as:
memcpy(WUFFS_REPRO__T,self->private_impl.f_d, sizeof(WUFFS_REPRO__T));
MSVC 19.51 warns at that line. A driver that calls set crashes with exit code -1073741819 (0xC0000005):
...\array-release.c(26165): warning C4090: 'function': different 'const' qualifiers
calling set!(), T = {1, 2}
exit code: -1073741819
gcc 13.3 warns passing argument 1 of ‘memcpy’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]. Its -O0 build of the same driver exits with SIGSEGV (139); its -O1 build drops the write and prints returned, T = {1, 2}.
The scalar form, pri const N : base.u32 = 5 with N = 6 in the same function, is also accepted. It generates 5u = 6u;, which neither gcc nor clang compiles:
scalar-release.c:26162:6: error: lvalue required as left operand of assignment
scalar-release.c:26162:6: error: expression is not assignable
Expected: the checker rejects assignments to a const.
Cause: the parser rejects literals and a fixed set of names as assignees, but does not check for const names:
The checker resolves the name to the const and has a TODO for this check:
- Lingua principale
- C
- Stelle
- 4.9k
- Fork
- 150
- Merge medio
- 4g 1h
- PR unite (30g)
- 3
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di google/wuffs
-
codegen: `io_reader.match7` with an empty prefix shifts a `uint64_t` by 64 and reports a mismatchAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 67/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 56/100
Tutte le issue di google/wuffs
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
JustAResearcher/gpu-unlock-ada#145 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
-
`PiecewiseChebyshevGate` produces incorrect target rotations outside the supplied breakpointsApertabug mod: circuit
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
area:tools type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Offline trigger silently replaces an existing /system-update link from another tool (dnf5 offline)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
PackageKit/PackageKit#1040 ·
I maintainer di solito rispondono entro 1 giorno