Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app crashes while trying to call dcrlibwallet getTransactions() function #750

Open
dreacot opened this issue May 16, 2021 · 0 comments
Open

Comments

@dreacot
Copy link
Contributor

dreacot commented May 16, 2021

The client app crashes while switching between the Overview and Transactions pages in quick successions.

The function which causes the crash was narrowed to the dcrlibwalletgetTransactions() function.

The lines of code which triggers the crash for the Overview Page and Transaction page respectively are linked below;
Overview Page: https://github.com/planetdecred/dcrios/blob/master/Decred%20Wallet/Extensions/Dcrlibwallet.swift#L245
Transactions Page: https://github.com/planetdecred/dcrios/blob/master/Decred%20Wallet/Extensions/Dcrlibwallet.swift#L148

The crashlog can be seen below;

decode allTransactionsJson error: The data couldn’t be read because it is missing.
fatal error: bulkBarrierPreWrite: unaligned arguments

goroutine 17 [running, locked to thread]: runtime.throw(0x102c89be7, 0x28) /usr/local/go/src/runtime/panic.go:1117 +0x54 fp=0x13c819d40 sp=0x13c819d10 pc=0x1025d17a4 runtime.bulkBarrierPreWrite(0x16daa552c, 0x13c819e68, 0x8) /usr/local/go/src/runtime/mbitmap.go:554 +0x44c fp=0x13c819de0 sp=0x13c819d40 pc=0x1025b2d6c runtime.typedmemmove(0x103004ba0, 0x16daa552c, 0x13c819e68) /usr/local/go/src/runtime/mbarrier.go:161 +0xa4 fp=0x13c819e20 sp=0x13c819de0 pc=0x1025b1f24 _cgoexp_2239270f2453_proxydcrlibwallet_MultiWallet_GetTransactions(0x16daa5514) _cgo_gotypes.go:1592 +0xe8 fp=0x13c819e80 sp=0x13c819e20 pc=0x102bf85c8 runtime.cgocallbackg1(0x102bf84e0, 0x16daa5514, 0x0) /usr/local/go/src/runtime/cgocall.go:292 +0x140 fp=0x13c819f40 sp=0x13c819e80 pc=0x1025a24f0 runtime.cgocallbackg(0x102bf84e0, 0x16daa5514, 0x0) /usr/local/go/src/runtime/cgocall.go:228 +0xb0 fp=0x13c819fb0 sp=0x13c819f40 pc=0x1025a2320 runtime.cgocallback(0x0, 0x0, 0x0) /usr/local/go/src/runtime/asm_arm64.s:1055 +0x98 fp=0x13c819fe0 sp=0x13c819fb0 pc=0x102605388 runtime.goexit() /usr/local/go/src/runtime/asm_arm64.s:1130 +0x4 fp=0x13c819fe0 sp=0x13c819fe0 pc=0x102605464

The crash long points to a fatal error: bulkBarrierPreWrite: unaligned arguments error. It also points to dcrlibwallet getTransactions() function (https://github.com/planetdecred/dcrlibwallet/blob/master/transactions.go#L103) which is called in the Overview and Transactions pages.

Another error was observed which seemed to be related to a decoding error

This error seen above, decode allTransactionsJson error: The data couldn’t be read because it is missing. is triggered from https://github.com/planetdecred/dcrios/blob/master/Decred%20Wallet/Extensions/Dcrlibwallet.swift#L164

The same crash can't be replicated on dcrandroid, so we ruled out the dcrlibwallet getTransactions() function to be the issue, and took a closer look at the fatal error: bulkBarrierPreWrite: unaligned arguments error

We found a similar issue here golang/go#28460, it pointed to go's lack of support for unaligned pointer writes.
In order to test their solution, we replaced the logic of the dcrlibwallet getTransactions() function with the code they claimed would fix the error *(*[2]uintptr)(unsafe.Pointer(uintptr(mem) + 1)) = [2]uintptr{} but the crash still ocured, so that doesn't seem to be the same case for us so we had to keep investigating.

Here's another similar issue golang/go#29264, it pointed to The compiler rejecting too-deep types and exiting gracefully, again that doesn't seem to be the case for us

We tried calling the getTransaction in a loop when the client app launches just to see if the the user not interacting with the UI would produce a different result, but the crash still occurred.

A similar issue here https://www.gitmemory.com/issue/golang/go/46893/868749896. suggests that the issue can be solved by removing the integer as the first input to the function and putting other types first.
In our case that would be changing
func (mw *MultiWallet) GetTransactionsRaw(offset, limit, txFilter int32, newestFirst bool) ([]Transaction, error) {
to
func (mw *MultiWallet) GetTransactionsRaw(newestFirst bool, offset, limit, txFilter int32) ([]Transaction, error) {
but the crash still occurs.

Since the crash wasn't occurring for dcrandroid, we had reason to believe the underlying issue had to do with the way gomobile compiles for arm devices.

How to replicate?
Switch between the Overview and Transactions pages multiple times in quick successions

@dreacot dreacot changed the title app crashes while trying to fetch transactions during wallet syncing app crashes while trying to call dcrlibwallet getTransactions() function Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant