Golang stack trace arguments not lining up meaningfully

Viewed 64

I am trying to map some arguments from a golang stack trace back to their original values.

The stack trace is as follows:

[Stack] goroutine 71093257 [running]:
runtime/debug.Stack(0xc0004d1260, 0xc00011e0b8, 0xc014650540)
        runtime/debug/stack.go:24 +0x9f
github.com/algorand/go-algorand/logging.logger.Errorf(0xc0004d1260, 0xc00011e0b8, 0x13692f7, 0x51, 0xc020bbefa0, 0x2, 0x2)
        github.com/algorand/go-algorand/logging/log.go:229 +0x4a
github.com/algorand/go-algorand/ledger.(*accountUpdates).getCreatorForRound(0xc000689b78, 0x15a7ee7, 0xa90ea3573b8d2957, 0x0, 0xc0269fff01, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/algorand/go-algorand/ledger/acctupdates.go:1434 +0x4c5
...

I am focusing on the "getCreatorForRound" method call. The signature looks like this:

func (au *accountUpdates) getCreatorForRound(rnd basics.Round, cidx basics.CreatableIndex, ctype basics.CreatableType, synchronized bool) (creator basics.Address, ok bool, err error) {

All 3 arguments are uint64 under the hood. The method body in question can be found here.

If I understand the documentation I have read correctly, the arguments should be [(pointer to receiver), ...arguments, ...returnValues]

If I map the stack trace arguments over the method signature, things do not look correct:

func (au *accountUpdates) getCreatorForRound(     0xc000689b78 // pointer to accountUpdates receiver
  rnd basics.Round,                               0x15a7ee7,   // round: 22707943 - correct, current round was 22707944
  cidx basics.CreatableIndex,                     0xa90ea3573b8d2957, // decimal: 12181853637140359511 ?? - well out of bounds
  ctype basics.CreatableType,                     0x0,                // valid for asset: AssetCreatable CreatableType = 0
  synchronized bool                               0xc0269fff01, // ?? this should be 0x1 for true. it is used meaningfully in the method body so it should not be omitted by go. decimal 825281740545
  ) (creator basics.Address,                      0x0,
  ok bool,                                        0x0,
  err error                                       0x0,          // this should not be 0x0
 ) {

cidx could be correct but the synchronized bool should be 0x1 as it is hardcoded to true in the specific execution call path.

I read that golang can omit the argument if it not used "meaningfully" in the method body but in this case synchronized is indeed used. The method starts like this:

func (au *accountUpdates) getCreatorForRound(rnd basics.Round, cidx basics.CreatableIndex, ctype basics.CreatableType, synchronized bool) (creator basics.Address, ok bool, err error) {
    unlock := false
    if synchronized {
        au.accountsMu.RLock()
        unlock = true
    }
...

I tried to reproduce the stack trace partially with some standalone code (passing in 3 uint64s and a bool and printing a stacktrace) and the uint64s are printed as hex properly, even for values larger than 2^32 (like 12181853637140359511)

Any pointers to what I am missing?

0 Answers
Related