← Back to Pull requests

Add missing string validation and fix test #9295

Merged
kripken merged 2 files (82 lines) on Oct 23, 2026 20:23 UTC
View on GitHub
kripken kripken commented on Oct 22, 2026 20:10 UTC
Author

No description provided by author.

Diff: 82 lines (+70 / -12) across 2 files Reviewer: tlively Review duration: 1453m
All Vouch review confidence checks passed
Residual risk 0.03 = Change Risk (0.31) × (1 − Review Confidence (0.91)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.31 · 82 lines diff across 2 files
0.31
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.89 · 5 substantive comment(s)
0.89
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
90%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.264
Real PR Conversation Timeline
10 items
gemini-code-assist[bot] gemini-code-assist[bot] commented on Oct 22, 2026 20:11 UTC
Reviewer

Code Review

This pull request adds type validation checks for various WebAssembly string operations (such as string.measure, string.concat, string.eq, string.test, string.wtf16_get, and string.slice_wtf) in wasm-validator.cpp, ensuring inputs are subtypes of externref and index arguments are i32. It also updates associated tests to use noextern instead of none. The reviewer identified that validation for string.compare is missing and should be added. Additionally, the reviewer suggested simplifying redundant Type(Type::i32) constructor calls to Type::i32 in visitStringWTF16Get and visitStringSliceWTF for better readability.

gemini-code-assist[bot] gemini-code-assist[bot] commented on code on Oct 22, 2026 20:11 UTC
Code Review
src/wasm/wasm-validator.cpp:1
@@ -4419,30 +4423,72 @@ void FunctionValidator::visitStringConcat(StringConcat* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(curr->left->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.concat left should be an externref");
+  shouldBeSubTypeIgnoringShared(curr->right->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.concat right should be an externref");
 }
 
 void FunctionValidator::visitStringEq(StringEq* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(curr->left->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.eq left should be an externref");
+  shouldBeSubTypeIgnoringShared(curr->right->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.eq right should be an externref");

!high

It appears that visitStringCompare is missing from both the FunctionValidator class declaration and its implementation. Since string.compare is a standard string operation (and is used in the tests), it should be validated similarly to string.eq to ensure that the strings feature is enabled and that both operands are subtypes of externref (or stringref). Please add the declaration to FunctionValidator and implement visitStringCompare.

gemini-code-assist[bot] gemini-code-assist[bot] commented on code on Oct 22, 2026 20:11 UTC
Code Review
src/wasm/wasm-validator.cpp:1
@@ -4419,30 +4423,72 @@ void FunctionValidator::visitStringConcat(StringConcat* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(curr->left->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.concat left should be an externref");
+  shouldBeSubTypeIgnoringShared(curr->right->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.concat right should be an externref");
 }
 
 void FunctionValidator::visitStringEq(StringEq* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(curr->left->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.eq left should be an externref");
+  shouldBeSubTypeIgnoringShared(curr->right->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.eq right should be an externref");
 }
 
 void FunctionValidator::visitStringTest(StringTest* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(curr->ref->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.test input should be an externref");
 }
 
 void FunctionValidator::visitStringWTF16Get(StringWTF16Get* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(
+    curr->ref->type,
+    Type(HeapType::ext, Nullable),
+    curr,
+    "string.wtf16_get input should be an externref");
+  shouldBeSubType(curr->pos->type,
+                  Type(Type::i32),
+                  curr,
+                  "string.wtf16_get pos should be an i32");

!medium

The explicit construction Type(Type::i32) is redundant here. Type::i32 is an unscoped enum value that is implicitly convertible to Type and is already used directly elsewhere in this file (e.g., in ref.i31 validation). Simplifying it to Type::i32 improves readability.

  shouldBeSubType(curr->pos->type,
                  Type::i32,
                  curr,
                  "string.wtf16_get pos should be an i32");

gemini-code-assist[bot] gemini-code-assist[bot] commented on code on Oct 22, 2026 20:11 UTC
Code Review
src/wasm/wasm-validator.cpp:1
@@ -4419,30 +4423,72 @@ void FunctionValidator::visitStringConcat(StringConcat* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(curr->left->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.concat left should be an externref");
+  shouldBeSubTypeIgnoringShared(curr->right->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.concat right should be an externref");
 }
 
 void FunctionValidator::visitStringEq(StringEq* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(curr->left->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.eq left should be an externref");
+  shouldBeSubTypeIgnoringShared(curr->right->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.eq right should be an externref");
 }
 
 void FunctionValidator::visitStringTest(StringTest* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(curr->ref->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.test input should be an externref");
 }
 
 void FunctionValidator::visitStringWTF16Get(StringWTF16Get* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(
+    curr->ref->type,
+    Type(HeapType::ext, Nullable),
+    curr,
+    "string.wtf16_get input should be an externref");
+  shouldBeSubType(curr->pos->type,
+                  Type(Type::i32),
+                  curr,
+                  "string.wtf16_get pos should be an i32");
 }
 
 void FunctionValidator::visitStringSliceWTF(StringSliceWTF* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(
+    curr->ref->type,
+    Type(HeapType::ext, Nullable),
+    curr,
+    "string.slice_wtf input should be an externref");
+  shouldBeSubType(curr->start->type,
+                  Type(Type::i32),
+                  curr,
+                  "string.slice_wtf start should be an i32");
+  shouldBeSubType(curr->end->type,
+                  Type(Type::i32),
+                  curr,
+                  "string.slice_wtf end should be an i32");

!medium

The explicit construction Type(Type::i32) is redundant here. Simplifying it to Type::i32 improves readability and maintains consistency with other parts of the validator.

  shouldBeSubType(curr->start->type,
                  Type::i32,
                  curr,
                  "string.slice_wtf start should be an i32");
  shouldBeSubType(curr->end->type,
                  Type::i32,
                  curr,
                  "string.slice_wtf end should be an i32");

tlively tlively commented on code on Oct 22, 2026 21:46 UTC
Code Review
src/wasm/wasm-validator.cpp:1
@@ -4419,30 +4423,72 @@ void FunctionValidator::visitStringConcat(StringConcat* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(curr->left->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.concat left should be an externref");
+  shouldBeSubTypeIgnoringShared(curr->right->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.concat right should be an externref");

We should check that the LHS and RHS sharedness match as well. Same for StringEq below.

tlively tlively commented on code on Oct 22, 2026 21:48 UTC
Code Review
src/wasm/wasm-validator.cpp:1
@@ -4419,30 +4423,72 @@ void FunctionValidator::visitStringConcat(StringConcat* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(curr->left->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.concat left should be an externref");
+  shouldBeSubTypeIgnoringShared(curr->right->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.concat right should be an externref");
 }
 
 void FunctionValidator::visitStringEq(StringEq* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(curr->left->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.eq left should be an externref");
+  shouldBeSubTypeIgnoringShared(curr->right->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.eq right should be an externref");
 }
 
 void FunctionValidator::visitStringTest(StringTest* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(curr->ref->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.test input should be an externref");
 }
 
 void FunctionValidator::visitStringWTF16Get(StringWTF16Get* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(
+    curr->ref->type,
+    Type(HeapType::ext, Nullable),
+    curr,
+    "string.wtf16_get input should be an externref");
+  shouldBeSubType(curr->pos->type,
+                  Type(Type::i32),
+                  curr,
+                  "string.wtf16_get pos should be an i32");

This is not the case due to C++ type conversion shenanigans.

tlively tlively approved these changes on Oct 22, 2026 21:48 UTC
Approved Reviewer

LGTM % comments.

kripken kripken commented on code on Oct 22, 2026 22:58 UTC
Code Review
src/wasm/wasm-validator.cpp:1
@@ -4419,30 +4423,72 @@ void FunctionValidator::visitStringConcat(StringConcat* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(curr->left->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.concat left should be an externref");
+  shouldBeSubTypeIgnoringShared(curr->right->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.concat right should be an externref");
 }
 
 void FunctionValidator::visitStringEq(StringEq* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(curr->left->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.eq left should be an externref");
+  shouldBeSubTypeIgnoringShared(curr->right->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.eq right should be an externref");

StringCompare does not exist in the IR, so visitStringCompare is irrelevant. It is implemented as a StringEq opcode.

kripken kripken commented on code on Oct 22, 2026 22:59 UTC
Code Review
src/wasm/wasm-validator.cpp:1
@@ -4419,30 +4423,72 @@ void FunctionValidator::visitStringConcat(StringConcat* curr) {
   shouldBeTrue(!getModule() || getModule()->features.hasStrings(),
                curr,
                "string operations require strings [--enable-strings]");
+  shouldBeSubTypeIgnoringShared(curr->left->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.concat left should be an externref");
+  shouldBeSubTypeIgnoringShared(curr->right->type,
+                                Type(HeapType::ext, Nullable),
+                                curr,
+                                "string.concat right should be an externref");

Done.

Reviewers
Assignees
kripken kripken
Labels
risk: low confidence: 90.6% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 30.9% (LOW) · Higher = larger blast radius
30.9%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 90.6% · Lower = rushed or shallow review
90.6%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 2.9% · Safe to merge
2.9%