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

Version 1.2.1 causes to app to crash on 32bit devices #100

Open
harig074 opened this issue Apr 21, 2015 · 4 comments
Open

Version 1.2.1 causes to app to crash on 32bit devices #100

harig074 opened this issue Apr 21, 2015 · 4 comments

Comments

@harig074
Copy link

Thanks for this awesome module. I have been using version 1.2.1 on both iOS and Android.
It runs very well on my iPhone 6 running iOS 8.3 and also on all iOS simulators.

However, the app crashes on startup when run on iPhone 5 running iOS 8.3 and iPad 2 running iOS 8.2. I'm able to run the app in these devices if I remove the ti_touchdb module from my project.

This is what I could see from the logs from my iPad 2.

Incident Identifier: D0A21ACE-9BAF-4EAE-BB66-B08BD64FB835
CrashReporter Key:   4ae20e88fad868efb211a99b89486004d41339cb
Hardware Model:      iPad2,1
Process:             FieldNXT Service [164]
Path:                /private/var/mobile/Containers/Bundle/Application/BFC7169B-71E5-43CF-9547-7F21AE3D5996/FieldNXT Service.app/FieldNXT Service
Identifier:          com.codeirontech.fieldnxtservice
Version:             1.0 (1.0)
Code Type:           ARM (Native)
Parent Process:      launchd [1]

Date/Time:           2015-04-21 08:44:21.182 +0530
Launch Time:         2015-04-21 08:44:20.404 +0530
OS Version:          iOS 8.2 (12D508)
Report Version:      105

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Subtype: EXC_ARM_DA_ALIGN at 0x1566d2d1
Triggered by Thread:  5

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libsystem_kernel.dylib          0x3683549c 0x36834000 + 5276
1   libsystem_kernel.dylib          0x36835290 0x36834000 + 4752
2   CoreFoundation                  0x2827a7f6 0x281ac000 + 845814
3   CoreFoundation                  0x28278dbc 0x281ac000 + 839100
4   CoreFoundation                  0x281c5b4c 0x281ac000 + 105292
5   CoreFoundation                  0x281c595e 0x281ac000 + 104798
6   GraphicsServices                0x2f6d31a4 0x2f6ca000 + 37284
7   UIKit                           0x2b817c8c 0x2b7a9000 + 453772
8   FieldNXT Service                0x00031d62 0x2b000 + 28002
9   libdyld.dylib                   0x36782aac 0x36781000 + 6828

Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0   libsystem_kernel.dylib          0x3683524c 0x36834000 + 4684
1   libdispatch.dylib               0x367554ec 0x36743000 + 74988
2   libdispatch.dylib               0x3675521e 0x36743000 + 74270

Thread 2:
0   libsystem_kernel.dylib          0x368499c0 0x36834000 + 88512
1   libsystem_pthread.dylib         0x368c5e20 0x368c5000 + 3616
2   libsystem_pthread.dylib         0x368c5af8 0x368c5000 + 2808

Thread 3:
0   libsystem_kernel.dylib          0x368499c0 0x36834000 + 88512
1   libsystem_pthread.dylib         0x368c5e20 0x368c5000 + 3616
2   libsystem_pthread.dylib         0x368c5af8 0x368c5000 + 2808

Thread 4:
0   libsystem_kernel.dylib          0x368499c0 0x36834000 + 88512
1   libsystem_pthread.dylib         0x368c5e20 0x368c5000 + 3616
2   libsystem_pthread.dylib         0x368c5af8 0x368c5000 + 2808

Thread 5 name:  KrollContext<kroll$1>
Thread 5 Crashed:
0   FieldNXT Service                0x0004e4ee 0x2b000 + 144622
1   FieldNXT Service                0x002a63c2 0x2b000 + 2601922
2   FieldNXT Service                0x00342f88 0x2b000 + 3243912
3   FieldNXT Service                0x003412ee 0x2b000 + 3236590
4   FieldNXT Service                0x00348744 0x2b000 + 3266372
5   FieldNXT Service                0x0034461e 0x2b000 + 3249694

Thread 6 name:  JavaScriptCore::BlockFree
Thread 6:
0   libsystem_kernel.dylib          0x36848b2c 0x36834000 + 84780
1   libsystem_pthread.dylib         0x368c7360 0x368c5000 + 9056
2   libsystem_pthread.dylib         0x368c8270 0x368c5000 + 12912
3   FieldNXT Service                0x00451110 0x2b000 + 4350224
4   FieldNXT Service                0x0020bd66 0x2b000 + 1969510
5   FieldNXT Service                0x0020be56 0x2b000 + 1969750
6   FieldNXT Service                0x0044fd2a 0x2b000 + 4345130
7   FieldNXT Service                0x004501d6 0x2b000 + 4346326
8   libsystem_pthread.dylib         0x368c7de8 0x368c5000 + 11752
9   libsystem_pthread.dylib         0x368c7d5a 0x368c5000 + 11610
10  libsystem_pthread.dylib         0x368c5b04 0x368c5000 + 2820

Thread 7 name:  JavaScriptCore::Marking
Thread 7:
0   libsystem_kernel.dylib          0x36848b2c 0x36834000 + 84780
1   libsystem_pthread.dylib         0x368c7360 0x368c5000 + 9056
2   libsystem_pthread.dylib         0x368c8230 0x368c5000 + 12848
3   FieldNXT Service                0x00256fde 0x2b000 + 2277342
4   FieldNXT Service                0x002570dc 0x2b000 + 2277596
5   FieldNXT Service                0x0044fd2a 0x2b000 + 4345130
6   FieldNXT Service                0x004501d6 0x2b000 + 4346326
7   libsystem_pthread.dylib         0x368c7de8 0x368c5000 + 11752
8   libsystem_pthread.dylib         0x368c7d5a 0x368c5000 + 11610
9   libsystem_pthread.dylib         0x368c5b04 0x368c5000 + 2820

Thread 8 name:  com.apple.coremedia.player.async
Thread 8:
0   libsystem_kernel.dylib          0x368354ec 0x36834000 + 5356
1   libdispatch.dylib               0x36752b8e 0x36743000 + 64398
2   MediaToolbox                    0x29ccbb56 0x29cc7000 + 19286
3   CoreMedia                       0x28a21bb4 0x289f3000 + 191412
4   libsystem_pthread.dylib         0x368c7de8 0x368c5000 + 11752
5   libsystem_pthread.dylib         0x368c7d5a 0x368c5000 + 11610
6   libsystem_pthread.dylib         0x368c5b04 0x368c5000 + 2820

Thread 9:
0   libsystem_kernel.dylib          0x368499c0 0x36834000 + 88512
1   libsystem_pthread.dylib         0x368c5e20 0x368c5000 + 3616
2   libsystem_pthread.dylib         0x368c5af8 0x368c5000 + 2808

Thread 10 name:  CouchbaseLite
Thread 10:
0   libsystem_kernel.dylib          0x3683549c 0x36834000 + 5276
1   libsystem_kernel.dylib          0x36835290 0x36834000 + 4752
2   CoreFoundation                  0x2827a7f6 0x281ac000 + 845814
3   CoreFoundation                  0x28278dbc 0x281ac000 + 839100
4   CoreFoundation                  0x281c5b4c 0x281ac000 + 105292
5   CoreFoundation                  0x281c595e 0x281ac000 + 104798
6   Foundation                      0x28f2960c 0x28f1d000 + 50700
7   FieldNXT Service                0x0047c7be 0x2b000 + 4528062
8   Foundation                      0x28fee4b6 0x28f1d000 + 857270
9   libsystem_pthread.dylib         0x368c7de8 0x368c5000 + 11752
10  libsystem_pthread.dylib         0x368c7d5a 0x368c5000 + 11610
11  libsystem_pthread.dylib         0x368c5b04 0x368c5000 + 2820

Thread 11:
0   libsystem_kernel.dylib          0x368499c0 0x36834000 + 88512
1   libsystem_pthread.dylib         0x368c5e20 0x368c5000 + 3616
2   libsystem_pthread.dylib         0x368c5af8 0x368c5000 + 2808

Thread 12 name:  com.apple.NSURLConnectionLoader
Thread 12:
0   libsystem_kernel.dylib          0x3683549c 0x36834000 + 5276
1   libsystem_kernel.dylib          0x36835290 0x36834000 + 4752
2   CoreFoundation                  0x2827a7f6 0x281ac000 + 845814
3   CoreFoundation                  0x28278dbc 0x281ac000 + 839100
4   CoreFoundation                  0x281c5b4c 0x281ac000 + 105292
5   CoreFoundation                  0x281c595e 0x281ac000 + 104798
6   CFNetwork                       0x27d79722 0x27cfd000 + 509730
7   Foundation                      0x28fee4b6 0x28f1d000 + 857270
8   libsystem_pthread.dylib         0x368c7de8 0x368c5000 + 11752
9   libsystem_pthread.dylib         0x368c7d5a 0x368c5000 + 11610
10  libsystem_pthread.dylib         0x368c5b04 0x368c5000 + 2820

Thread 5 crashed with ARM Thread State (32-bit):
    r0: 0x1566d2d1    r1: 0x00000000      r2: 0x359ff1f1      r3: 0x00000003
    r4: 0xffffffff    r5: 0x005eb2c8      r6: 0x005aaf48      r7: 0x0243d218
    r8: 0x005aaf58    r9: 0x0244d8d8     r10: 0x005aaf28     r11: 0x005aaf38
    ip: 0x0059c758    sp: 0x0243cff0      lr: 0x0031827f      pc: 0x0004e4ee
  cpsr: 0x20000030
@harig074
Copy link
Author

This has something to do with sync.
I was able to run the app and use the module after disabling sync in my code.

@pegli
Copy link
Collaborator

pegli commented Apr 27, 2015

Thread 5 is crashing in FieldNXT Service, which sounds like it is probably the name of your app. Are you able to share the code that you're using to run replication? Also, are you listening for replication events?

@harig074
Copy link
Author

I had disabled push replication, but was using continuous pull replication.
Please see the code from alloy.js below

// Couchbase sync code

// turn on sync logging
Ti.App.Properties.setBool("Log", true);
Ti.App.Properties.setBool("LogSync", false);
Ti.App.Properties.setBool("LogSyncVerbose", false);

var server = require('com.obscure.titouchdb'),
    db = server.databaseManager.getDatabase(Alloy.CFG.dbname);

if (Alloy.CFG.remote_couchdb_server) {
    var pull = db.createPullReplication(Alloy.CFG.remote_couchdb_server);

    pull.continuous = true;
    pull.addEventListener('change', function(e) {
        Ti.API.info(String.format("pull: running: %d, total: %d, completed: %d", !!pull.isRunning, pull.changesCount, pull.completedChangesCount));
        switch(pull.status) {
        case server.REPLICATION_MODE_IDLE:
            Ti.App.fireEvent('empowerservice:sync_completed', {
                total : pull.changesCount,
                completed : pull.completedChangesCount
            });
            Ti.API.info('idle pull replication; fired update event');
            break;
        case server.REPLICATION_MODE_ACTIVE:
            Ti.App.fireEvent('empowerservice:sync_progress', {
                total : pull.changesCount,
                completed : pull.completedChangesCount
            });
            Ti.API.info('pull replication; fired progress event');
            break;
        }
    });
    pull.start();
/*
    // Disable Push for now
    var push = db.createPushReplication(Alloy.CFG.remote_couchdb_server);
    push.continuous = true;
    push.addEventListener('change', function(e) {
        Ti.API.info(String.format("push: running: %d, total: %d, completed: %d", !!pull.isRunning, pull.changesCount, pull.completedChangesCount));
        if (pull.status == server.REPLICATION_MODE_IDLE) {
            Ti.App.fireEvent('books:update_from_server');
            Ti.API.info("idle push replication; fired update event");
        }
    });
    push.start();*/

    // hold references to the replications
    Alloy.Globals.replications = {
        // push : push,
        pull : pull
    };

    // restart replication on app resume
    Ti.App.addEventListener('resume', function() {
        // Alloy.Globals.replications.push.start();
        Alloy.Globals.replications.pull.start();
    });
}

And I'm listening for replication events inside my controller. Wasn't doing anything useful with the events yet. Right now all of this code is disabled in my app due to the crash.

Ti.App.addEventListener('empowerservice:sync_completed', function(e) {
 console.log(String.format('Sync complete: Total=>%d  Completed=>%d', e.total, e.completed));
 });
Ti.App.addEventListener('empowerservice:sync_progress', function(e) {
 console.log('Pull object 2: ' + JSON.stringify(e));
 var progress = Math.round(100 * ((e.completed === 0 ? 1 : e.completed) / (e.total === 0 ? 1 : e.total)));
 console.log(String.format('Sync progress => %d%%', progress));
 });

@harig074
Copy link
Author

I tried running the app through XCode and managed to find the issue. Incidentally, the issue is in KrollContext that you had reported a while back in Appcelerator JIRA.

In method StringFormatCallback

            else if (TiValueIsNumber(jsContext, valueRef))
            {
                (*(double*)argList) = TiValueToNumber(jsContext, valueRef, NULL);
                argList += sizeof(double);
            }

https://jira.appcelerator.org/browse/TIMOB-15365

I followed the same fix you suggested in the bugreport and I'm able to run sync in both 32bit and 64bit iOS devices now.

            else if (TiValueIsNumber(jsContext, valueRef))
            {
                double tmp = TiValueToNumber(jsContext, valueRef, NULL);
                memcpy(argList, &tmp, sizeof(tmp));
                argList += sizeof(double);
            }

Any reasons why this issue reappered and any permanent solutions?

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