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 when blockchain download is (nearly) done #3

Closed
turcane opened this issue Sep 29, 2016 · 7 comments
Closed

App Crashes when blockchain download is (nearly) done #3

turcane opened this issue Sep 29, 2016 · 7 comments

Comments

@turcane
Copy link

turcane commented Sep 29, 2016

Steps to reproduce:

  1. Create Parameters with Main Net
  2. Create a seed from mnemonic and iso date (seed has balance, transactions and two accounts)
  3. Create store with parameters
  4. Create wallet with seed and parameteres
  5. Create downloader with store and wallet
  6. Create peer group with paramteres
  7. Start connections on peer group
  8. Start download on peer group

App will crash when download is finished or nearly finished

2016-09-29 09:27:58.525635 Mana[1394:355331] *** Terminating app due to uncaught exception 'IllegalArgument', reason: 'No implicit path set, call saveToPath: first'
*** First throw call stack:
(0x18316c1c0 0x181ba455c 0x18316c094 0x1000e3d2c 0x1000edfe4 0x1000f1c2c 0x1000f13b8 0x1000d3a38 0x1000cdc28 0x10011da90 0x100112b64 0x100cf125c 0x100cf121c 0x100cfeb54 0x100cf4ce4 0x100cff0f0 0x100d00e6c 0x100d00bb8 0x1821fd2c8 0x1821fcdb4)

libc++abi.dylib: terminating with uncaught exception of type NSException

  • thread High CPU usage during sync #2: tid = 0x56c03, 0x000000018213a014 libsystem_kernel.dylib__pthread_kill + 8, queue = 'WSPeerGroup', stop reason = signal SIGABRT frame #0: 0x000000018213a014 libsystem_kernel.dylib__pthread_kill + 8
    frame Use in production environments #1: 0x0000000182201460 libsystem_pthread.dylibpthread_kill + 112 frame #2: 0x00000001820ae3f4 libsystem_c.dylibabort + 140
    frame App Crashes when blockchain download is (nearly) done #3: 0x0000000181b792d4 libc++abi.dylibabort_message + 132 frame #4: 0x0000000181b96cc0 libc++abi.dylibdefault_terminate_handler() + 304
    frame The file DDTTYLogger.h can't be found #5: 0x0000000181ba4844 libobjc.A.dylib_objc_terminate() + 124 frame #6: 0x0000000181b9366c libc++abi.dylibstd::__terminate(void (*)()) + 16
    frame is there a demo ? #7: 0x0000000181b92f84 libc++abi.dylib__cxa_throw + 136 frame #8: 0x0000000181ba4690 libobjc.A.dylibobjc_exception_throw + 364
    frame Question: Create, sign and broadcast raw transaction #9: 0x000000018316c094 CoreFoundation`+[NSException raise:format:arguments:] + 104
    • frame [TESTNET] Pending transaction is rejected: Non-canonical signature: S value is unnecessarily high #10: 0x00000001000e3d2c ManaWSExceptionCheck(condition=NO, name=@"IllegalArgument", format=@"No implicit path set, call saveToPath: first") + 136 at WSErrors.m:60 frame #11: 0x00000001000edfe4 Mana-[WSHDWallet save](self=0x0000000174151930, _cmd="save") + 80 at WSHDWallet.m:672
      frame #12: 0x00000001000f1c2c Mana-[WSHDWallet registerTransaction:didGenerateNewAddresses:batch:](self=0x0000000174151930, _cmd="registerTransaction:didGenerateNewAddresses:batch:", transaction=0x0000000170470fc0, didGenerateNewAddresses=NO, batch=NO) + 1708 at WSHDWallet.m:1144 frame #13: 0x00000001000f13b8 Mana-[WSHDWallet registerTransaction:didGenerateNewAddresses:](self=0x0000000174151930, _cmd="registerTransaction:didGenerateNewAddresses:", transaction=0x0000000170470fc0, didGenerateNewAddresses=NO) + 88 at WSHDWallet.m:1095
      frame #14: 0x00000001000d3a38 Mana-[WSBlockChainDownloader handleReceivedTransaction:](self=0x0000000174123340, _cmd="handleReceivedTransaction:", transaction=0x0000000170470fc0) + 432 at WSBlockChainDownloader.m:956 frame #15: 0x00000001000cdc28 Mana-[WSBlockChainDownloader peerGroup:peer:didReceiveTransaction:](self=0x0000000174123340, _cmd="peerGroup:peer:didReceiveTransaction:", peerGroup=0x000000017416e640, peer=0x0000000170114250, transaction=0x0000000170470fc0) + 136 at WSBlockChainDownloader.m:492
      frame #16: 0x000000010011da90 Mana-[WSPeerGroup peer:didReceiveTransaction:](self=0x000000017416e640, _cmd="peer:didReceiveTransaction:", peer=0x0000000170114250, transaction=0x0000000170470fc0) + 444 at WSPeerGroup.m:672 frame #17: 0x0000000100112b64 Mana__27-[WSPeer receiveTxMessage:]_block_invoke((null)=0x0000000170856320) + 92 at WSPeer.m:650
      frame #18: 0x0000000100cf125c libdispatch.dylib_dispatch_call_block_and_release + 24 frame #19: 0x0000000100cf121c libdispatch.dylib_dispatch_client_callout + 16
      frame #20: 0x0000000100cfeb54 libdispatch.dylib_dispatch_queue_serial_drain + 1136 frame #21: 0x0000000100cf4ce4 libdispatch.dylib_dispatch_queue_invoke + 672
      frame #22: 0x0000000100cff0f0 libdispatch.dylib_dispatch_queue_override_invoke + 496 frame #23: 0x0000000100d00e6c libdispatch.dylib_dispatch_root_queue_drain + 584
      frame #24: 0x0000000100d00bb8 libdispatch.dylib_dispatch_worker_thread3 + 140 frame #25: 0x00000001821fd2c8 libsystem_pthread.dylib_pthread_wqthread + 1288
      frame #26: 0x00000001821fcdb4 libsystem_pthread.dylib`start_wqthread + 4
@turcane
Copy link
Author

turcane commented Sep 29, 2016

Tested also with a seed with just 1 transaction and 1 account.
Same result -> Crash

@keeshux
Copy link
Owner

keeshux commented Sep 29, 2016

At least it's a "controlled crash", i.e. the library itself is raising an exception, because the path for the WSHDWallet object was not set. As suggested, you must invoke saveToPath: at least once when autosave is enabled, otherwise the wallet wouldn't know where to save. I understand it's not so obvious and can be improved, but it's how it is now.

Can you please post the code you described in the above steps instead?

@turcane
Copy link
Author

turcane commented Sep 29, 2016

I've created bridging header, this is my code:

    let parameters = WSParametersForNetworkType(WSNetworkTypeMain)
    let seed = WSSeedMakeFromISODate("...some mnemonic...", "2016-09-29")
    let store = WSMemoryBlockStore.init(parameters: parameters)
    let wallet = WSHDWallet.init(parameters: parameters, seed: seed)
    wallet?.save(toPath: "/")
    let downloader = WSBlockChainDownloader.init(store: store, wallet: wallet)
    let peerGroup = WSPeerGroup.init(parameters: parameters)
    peerGroup?.startConnections()
    peerGroup?.startDownload(with: downloader)

Also crashing if "shouldAutoSave" is set to false.
I can provide you whole project, if this helps

@keeshux
Copy link
Owner

keeshux commented Sep 29, 2016

I think it's the quickest option, send it over to me via email.

@turcane
Copy link
Author

turcane commented Sep 29, 2016

I will invite you to the private project. Please don't spend coin, which are on the seed. But you can use them for testing purposes :)

/edit
Invited. I tried it with a real device (iPhone 7) and iPhone 5 Simulator. Same result. On iOS10 of course.

@keeshux
Copy link
Owner

keeshux commented Sep 29, 2016

@JediWed

- (BOOL)saveToPath:(NSString *)path
{
    WSExceptionCheckIllegal(path);

    @synchronized (self) {
        if (![NSKeyedArchiver archiveRootObject:self toFile:path]) {
            return NO;
        }
        DDLogInfo(@"Saved wallet to %@", path);
        _path = path;
        return YES;
    }
}

I hadn't noticed that you're trying to save to /, the result is that archiveRootObject obviously fails. You should save files to app's sandbox directories instead. Generally speaking, you must ensure that saveToPath: succeeds before serializing the wallet.

I'm adding a warning just in case, but this is a non-issue. Closing.

@keeshux keeshux closed this as completed Sep 29, 2016
@turcane
Copy link
Author

turcane commented Sep 29, 2016

Great, thank you very much!

@keeshux keeshux mentioned this issue Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants