liutao-liu added the bug label to Issue #7401.
liutao-liu opened issue #7401:
### Test Case
NaSteps to Reproduce
When I input "target/debug/wasmtime run my.wasm --invoke my_func_name 1.1" in the command line, i got an error "invalid digit found in string".
Expected Results
The entered parameter "1.1" can be parsed successfully.
Actual Results
Got an error:"invalid digit found in string"。
Versions and Environment
Wasmtime version or commit: wasmtime-cli 13.0.0
Operating system: Ubuntu 20.04
Architecture: Na
Extra Info
【Root Cause】
https://github.com/bytecodealliance/wasmtime/blob/519808fc5c2565f11f9b6a7f5fe3d2385f9f95e8/src/commands/run.rs#L507The function
invoke_func
attempted to cast a floating-point string to F32/F64,which is actually a u32/u64 type.【Solution】
I think this conversion should be written like this:let val: f32 = val.parse()?; let ptr = &val as *const f32 as *const u32; let val = unsafe { *ptr }; ~~~
bjorn3 commented on issue #7401:
You can use .to_bits() on f32 to avoid unsafe code.
liutao-liu edited issue #7401:
### Test Case
NaSteps to Reproduce
When I input "target/debug/wasmtime run my.wasm --invoke my_func_name 1.1" in the command line, i got an error "invalid digit found in string".
Expected Results
The entered parameter "1.1" can be parsed successfully.
Actual Results
Got an error:"invalid digit found in string"。
Versions and Environment
Wasmtime version or commit: wasmtime-cli 13.0.0
Operating system: Ubuntu 20.04
Architecture: Na
Extra Info
【Root Cause】
https://github.com/bytecodealliance/wasmtime/blob/519808fc5c2565f11f9b6a7f5fe3d2385f9f95e8/src/commands/run.rs#L507The function
invoke_func
attempted to cast a floating-point string to F32/F64,which is actually a u32/u64 type.【Solution】
I think this conversion should be written like this:let val: f32 = val.parse()?; let val = val.to_bits(); ~~~
liutao-liu commented on issue #7401:
You can use .to_bits() on f32 to avoid unsafe code.
You're right, I've revised it as you suggested.
alexcrichton commented on issue #7401:
Can you share the WebAssembly module that is being run? If the argument is of type
i32
in wasm then it doesn't accept a floating point number as an argument (e.g. it won't callto_bits()
).
liutao-liu commented on issue #7401:
Can you share the WebAssembly module that is being run? If the argument is of type
i32
in wasm then it doesn't accept a floating point number as an argument (e.g. it won't callto_bits()
).(module (type $f_t (func (param f32) (result f32))) (func $f_f (type $f_t) (param $a f32) (result f32) local.get $a) (export "ret_f32" (func $f_f)))
alexcrichton commented on issue #7401:
Can you paste the full wasm module? Or upload it? The input you have provided does not have a function export called
my_func_name
which you're trying to invoke from the command line
liutao-liu edited a comment on issue #7401:
Can you share the WebAssembly module that is being run? If the argument is of type
i32
in wasm then it doesn't accept a floating point number as an argument (e.g. it won't callto_bits()
).(module (type $f_t (func (param f32) (result f32))) (func $f_f (type $f_t) (param $a f32) (result f32) local.get $a) (export "my_func_name" (func $f_f)))
liutao-liu commented on issue #7401:
Can you paste the full wasm module? Or upload it? The input you have provided does not have a function export called
my_func_name
which you're trying to invoke from the command line(module (type $f_t (func (param f32) (result f32))) (func $f_f (type $f_t) (param $a f32) (result f32) local.get $a) (export "my_func_name" (func $f_f)))
liutao-liu edited a comment on issue #7401:
Can you paste the full wasm module? Or upload it? The input you have provided does not have a function export called
my_func_name
which you're trying to invoke from the command line(module (type $f_t (func (param f32) (result f32))) (func $f_f (type $f_t) (param $a f32) (result f32) local.get $a) (export "my_func_name" (func $f_f)))
target/debug/wasmtime run my.wasm --invoke my_func_name 1.1
liutao-liu edited a comment on issue #7401:
Can you paste the full wasm module? Or upload it? The input you have provided does not have a function export called
my_func_name
which you're trying to invoke from the command line
wat:
(module (type $f_t (func (param f32) (result f32))) (func $f_f (type $f_t) (param $a f32) (result f32) local.get $a) (export "my_func_name" (func $f_f)))invoke command:
target/debug/wasmtime run my.wasm --invoke my_func_name 1.1
liutao-liu edited a comment on issue #7401:
Can you paste the full wasm module? Or upload it? The input you have provided does not have a function export called
my_func_name
which you're trying to invoke from the command linewat:
(module (type $f_t (func (param f32) (result f32))) (func $f_f (type $f_t) (param $a f32) (result f32) local.get $a) (export "my_func_name" (func $f_f)))invoke command:
target/debug/wasmtime run my.wasm --invoke my_func_name 1.1
liutao-liu edited a comment on issue #7401:
Can you paste the full wasm module? Or upload it? The input you have provided does not have a function export called
my_func_name
which you're trying to invoke from the command linemy.wat:
(module (type $f_t (func (param f32) (result f32))) (func $f_f (type $f_t) (param $a f32) (result f32) local.get $a) (export "my_func_name" (func $f_f)))invoke command:
target/debug/wasmtime run my.wat --invoke my_func_name 1.1
liutao-liu edited a comment on issue #7401:
Can you paste the full wasm module? Or upload it? The input you have provided does not have a function export called
my_func_name
which you're trying to invoke from the command linemy.wat:
(module (type $f_t (func (param f32) (result f32))) (func $f_f (type $f_t) (param $a f32) (result f32) local.get $a) (export "my_func_name" (func $f_f)))
invoke command:
target/debug/wasmtime run my.wat --invoke my_func_name 1.1
alexcrichton commented on issue #7401:
Thanks for the clarification, this should be fixed in https://github.com/bytecodealliance/wasmtime/pull/7440
pchickey closed issue #7401:
### Test Case
NaSteps to Reproduce
When I input "target/debug/wasmtime run my.wasm --invoke my_func_name 1.1" in the command line, i got an error "invalid digit found in string".
Expected Results
The entered parameter "1.1" can be parsed successfully.
Actual Results
Got an error:"invalid digit found in string"。
Versions and Environment
Wasmtime version or commit: wasmtime-cli 13.0.0
Operating system: Ubuntu 20.04
Architecture: Na
Extra Info
【Root Cause】
https://github.com/bytecodealliance/wasmtime/blob/519808fc5c2565f11f9b6a7f5fe3d2385f9f95e8/src/commands/run.rs#L507The function
invoke_func
attempted to cast a floating-point string to F32/F64,which is actually a u32/u64 type.【Solution】
I think this conversion should be written like this:let val: f32 = val.parse()?; let val = val.to_bits(); ~~~
Last updated: Nov 22 2024 at 16:03 UTC