Skip to content

Return from addConstant when constant limit is exceeded - #1231

Open
cuiweixie wants to merge 1 commit into
wren-lang:mainfrom
cuiweixie:fix/addconstant-return-on-max-constants
Open

cuiweixie wants to merge 1 commit into
wren-lang:mainfrom
cuiweixie:fix/addconstant-return-on-max-constants

Conversation

@cuiweixie

Copy link
Copy Markdown

Summary

In addConstant, when MAX_CONSTANTS is exceeded we call error() but previously did not return. Execution then fell through to return compiler->fn->constants.count - 1, which could emit bytecode with a bogus constant index.

Return -1 after reporting the error (consistent with other failure paths in the compiler).

Testing

python3 util/test.py limit
make -C projects/make.mac

Without returning after the error, execution fell through and returned
compiler->fn->constants.count - 1, which could emit invalid bytecode.
@cuiweixie
cuiweixie force-pushed the fix/addconstant-return-on-max-constants branch from 60c7cc9 to df29737 Compare March 27, 2026 06:12
TaxMachine pushed a commit to TaxMachine/wren that referenced this pull request Oct 11, 2026
Base: upstream wren-lang/wren @ 99d2f0b (fork main), tree previously
vendored as a depth-1 clone with .git stripped.

Delta (10 files, all in src/vm/): security backports of upstream
PRs wren-lang#1242-1246 (OOB/BOF clamps), fixes for wren-lang#1234 (runtimeError upvalue
leak), wren-lang#1212 (lazy string hashing), wren-lang#1141 (sort middle pivot), wren-lang#1056
(cyclic-print truncation), wren-lang#676 (createForeign stackTop), wren-lang#1036/wren-lang#1034/
wren-lang#1033 (error-message bounds), wren-lang#811 (unbound foreign ctor), wren-lang#1236
(fiber-stack UAF), wren-lang#1230 (String.find table), wren-lang#1088 (upvalue bound),
wren-lang#1102 (Range.contains), wren-lang#1228 (lexer overrun), wren-lang#814 (hex-escape UB),
wren-lang#897 (shift UB), wren-lang#1232/wren-lang#1233 (fromString/u64), wren-lang#803 (any/all Bool),
wren-lang#1000 (error hygiene), wren-lang#1012/wren-lang#1068 (warning hygiene), wren-lang#1231/wren-lang#1229
(error-path consistency), plus feurhax hardening (GC-rooted attribute
copy, MAX_NEST_DEPTH=512 parser cap, call-handle arity clamp) and the
64MB heap-cap / perf-audit follow-ups.

Full per-fix archaeology lives in the consumer tree at
feurhax-client/third_party/VENDORED.md (wren section). Built with
WREN_OPT_META=0 WREN_OPT_RANDOM=0; scripting_test + script_editor_test
green.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant