gnolang / gno

Gno: An interpreted, stack-based Go virtual machine to build succinct and composable apps + Gno.land: a blockchain for timeless code and fair open-source.
https://gno.land/
Other
879 stars 362 forks source link

Uint64 overflow #2839

Open MalekLahbib opened 3 hours ago

MalekLahbib commented 3 hours ago

Description

I was going through the GRC20 package, and noticed in banker.gno file some comments form @moul // TODO: check for overflow. So I made a test and called a function with overflow and had this: Screenshot from 2024-09-24 11-23-23

From what I understand, it's not possible for the moment to check for the overflow in the file, as the panic message seems to come from the VM.

Am I right? Is this the way things are supposed to work?

I imagine that it's not necessary to check for overflow in the code if the VM will do it automatically and not let the function execute.

leohhhn commented 3 hours ago

Can you please provide the code you used?

Seems that the error you're getting is from strconv.ParseUint, not a VM panic.

MalekLahbib commented 1 hour ago

I tried to put a condition in the beginning of the function to verify the overflow: Screenshot from 2024-09-24 13-56-38

but I don't think the error message is from the function execution, I said VM as I still don't understand so much how it's working. It says in the beginning: --= Error =-- Data: internal error Msg Traces: 0 /home/malek/gno/tm2/pkg/crypto/keys/client/maketx.go:215 - deliver transaction failed: log:recovered: error parsing uint64 "18446744073709551616": strconv.ParseUint: parsing "18446744073709551616": value out of range

Am I wrong?

DIGIX666 commented 1 hour ago

I think you can change your condition to if amout > 18446744073709551615 because uint64 is never negative