-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a panic with an invalid name section (#3509)
This commit fixes a panic which can happen on a module with an invalid name section where one of the functions named has the index `u32::MAX`. Previously Wasmtime would create a new `FuncIndex` with the indices found in the name section but the sentinel `u32::MAX` causes a panic. Cranelift otherwise limits the number of functions through `wasmparser` which has a hard limit (lower than `u32::MAX`) so this commit applies a fix of only recording function names for function indices that are actually present in the module.
- Loading branch information
1 parent
6bcee7f
commit 6be0f82
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,46 @@ | ||
(module (func (export "empty"))) | ||
|
||
(invoke "empty") | ||
|
||
(module binary | ||
"\00asm\01\00\00\00" ;; module header | ||
|
||
"\00" ;; custom section id 0 | ||
"\0e" ;; section size | ||
"\04name" ;; this is the `name` custom section | ||
"\01" ;; function name subsection | ||
"\07" ;; function name subsection size | ||
"\01" ;; 1 function name mapping | ||
"\ff\ff\ff\ff\0f" ;; index == u32::MAX | ||
"\00" ;; empty string name | ||
) | ||
|
||
(module binary | ||
"\00asm\01\00\00\00" ;; module header | ||
|
||
"\00" ;; custom section id 0 | ||
"\10" ;; section size | ||
"\04name" ;; this is the `name` custom section | ||
"\02" ;; local name subsection | ||
"\09" ;; local name subsection size | ||
"\01" ;; 1 indirect name map | ||
"\ff\ff\ff\ff\0f" ;; index == u32::MAX (function) | ||
"\01" ;; 1 name mapping | ||
"\00" ;; index == 0 (local) | ||
"\00" ;; empty string name | ||
) | ||
|
||
(module binary | ||
"\00asm\01\00\00\00" ;; module header | ||
|
||
"\00" ;; custom section id 0 | ||
"\10" ;; section size | ||
"\04name" ;; this is the `name` custom section | ||
"\02" ;; local name subsection | ||
"\09" ;; local name subsection size | ||
"\01" ;; 1 indirect name map | ||
"\00" ;; index == 0 (function) | ||
"\01" ;; 1 name mapping | ||
"\ff\ff\ff\ff\0f" ;; index == u32::MAX (local) | ||
"\00" ;; empty string name | ||
) |