0chain / gosdk

A client SDK in Go to interface the blockchain and storage platform, and other smart contracts
MIT License
32 stars 29 forks source link

wasm sdk: recover from panic #941

Closed boddumanohar closed 1 year ago

boddumanohar commented 1 year ago

when ever there is an panic within wasm functions, for example:

https://github.com/0chain/gosdk/blob/fc71195dd1e876de6d9d375005aea8a98e8972ae/wasmsdk/allocation.go#L52-L53

In this wasm function, datashards is expected to be int. But if you pass dataShards as string, then gowasm crashes and returns an error

Go instance is not active

To fix this, the go wasm instance should be able to recover from panic during its execution.

cnlangzi commented 1 year ago

please convert it into number before call it.

boddumanohar commented 1 year ago

The fix doesn't seems solve the isse completely. whenever there is a panic in wasm, the web-apps breatks.

cnlangzi commented 1 year ago

it fixed input panicking issue. but don't catch generic panicking issue in code.

boddumanohar commented 1 year ago

fixed by: https://github.com/0chain/gosdk/pull/1071