Skip to content

Commit

Permalink
Merge pull request #541 from CosmWasm/chipshort/workaround-optimizer-bug
Browse files Browse the repository at this point in the history
Avoid checking `errOut.is_none` for unused errOut
  • Loading branch information
chipshort authored Jun 7, 2024
2 parents 8bf2938 + 973cc64 commit 953c615
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions internal/api/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ func cGet(ptr *C.db_t, gasMeter *C.gas_meter_t, usedGas *cu64, key C.U8SliceView
// we received an invalid pointer
return C.GoError_BadArgument
}
if !(*val).is_none || !(*errOut).is_none {
// errOut is unused and we don't check `is_none` because of https://github.com/CosmWasm/wasmvm/issues/536
if !(*val).is_none {
panic("Got a non-none UnmanagedVector we're about to override. This is a bug because someone has to drop the old one.")
}

Expand Down Expand Up @@ -185,9 +186,7 @@ func cSet(ptr *C.db_t, gasMeter *C.gas_meter_t, usedGas *cu64, key C.U8SliceView
// we received an invalid pointer
return C.GoError_BadArgument
}
if !(*errOut).is_none {
panic("Got a non-none UnmanagedVector we're about to override. This is a bug because someone has to drop the old one.")
}
// errOut is unused and we don't check `is_none` because of https://github.com/CosmWasm/wasmvm/issues/536

gm := *(*types.GasMeter)(unsafe.Pointer(gasMeter))
kv := *(*types.KVStore)(unsafe.Pointer(ptr))
Expand All @@ -210,9 +209,7 @@ func cDelete(ptr *C.db_t, gasMeter *C.gas_meter_t, usedGas *cu64, key C.U8SliceV
// we received an invalid pointer
return C.GoError_BadArgument
}
if !(*errOut).is_none {
panic("Got a non-none UnmanagedVector we're about to override. This is a bug because someone has to drop the old one.")
}
// errOut is unused and we don't check `is_none` because of https://github.com/CosmWasm/wasmvm/issues/536

gm := *(*types.GasMeter)(unsafe.Pointer(gasMeter))
kv := *(*types.KVStore)(unsafe.Pointer(ptr))
Expand Down Expand Up @@ -286,7 +283,8 @@ func cNext(ref C.IteratorReference, gasMeter *C.gas_meter_t, usedGas *cu64, key
// we received an invalid pointer
return C.GoError_BadArgument
}
if !(*key).is_none || !(*val).is_none || !(*errOut).is_none {
// errOut is unused and we don't check `is_none` because of https://github.com/CosmWasm/wasmvm/issues/536
if !(*key).is_none || !(*val).is_none {
panic("Got a non-none UnmanagedVector we're about to override. This is a bug because someone has to drop the old one.")
}

Expand Down Expand Up @@ -337,7 +335,8 @@ func nextPart(ref C.IteratorReference, gasMeter *C.gas_meter_t, usedGas *cu64, o
// we received an invalid pointer
return C.GoError_BadArgument
}
if !(*output).is_none || !(*errOut).is_none {
// errOut is unused and we don't check `is_none` because of https://github.com/CosmWasm/wasmvm/issues/536
if !(*output).is_none {
panic("Got a non-none UnmanagedVector we're about to override. This is a bug because someone has to drop the old one.")
}

Expand Down

0 comments on commit 953c615

Please sign in to comment.