Titanium JIRA Archive
Appcelerator Community (AC)

[AC-3089] Running a large number of queries on a database causes crash

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionDuplicate
Resolution Date2011-09-07T07:12:08.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labels1.7.2, database, defect, ios
ReporterMartin Slater
AssigneePaul Dowsett
Created2011-08-10T11:45:54.000+0000
Updated2016-03-08T07:48:08.000+0000

Description

Copy this code into a newly created project {noformat} var num_rows = 100; var dbname = 'user_db5.db'; var db = Titanium.Database.open(dbname); db.execute('DROP TABLE IF EXISTS playlist'); db.execute('CREATE TABLE IF NOT EXISTS playlist (category_id INTEGER KEY PRIMARY KEY)'); for(var i = 0; i < num_rows; ++i) { db.execute('INSERT INTO playlist(category_id) VALUES(?)', i); } db.close(); var win1 = Ti.UI.createWindow({backgroundColor:'blue'}); win1.addEventListener('focus', function(){ var db = Titanium.Database.open(dbname); for(var j = 0; j < num_rows * 100; ++j) { var r = j % 100; var rows = db.execute('SELECT * FROM playlist WHERE category_id=?', r); var id = rows.fieldByName('category_id'); Ti.API.info('id = ' + id); rows.close(); } db.close(); }); var win2 = Ti.UI.createWindow({backgroundColor:'red'}); var tab_group = Ti.UI.createTabGroup(); tab_group.addTab( Ti.UI.createTab({window:win1}) ); tab_group.addTab( Ti.UI.createTab({window:win2}) ); tab_group.open(); {noformat} Run in IOS simulator Switch between tabs until crash occurs. In Studio the application will just exit, running under XCode gives a EXC_BAD_ACCESS with the following callstack {noformat} #0 0x002d7bab in _Z4toJSPN2TI10TiExcStateEPK13OpaqueTiValue [inlined] at /Users/stiv/src/appcelerator/tijscore/TiCore/API:75 #1 0x002d7bab in TiObjectSetProperty at /Users/stiv/src/appcelerator/tijscore/TiCore/API/TiObjectRef.cpp:295 #2 0x00056291 in -[KrollObject noteObject:forTiString:context:] at /Users/martinslater/code/EasyLang/mobile/EasyLang Mobile/build/iphone/Classes/KrollObject.m:1302 #3 0x0005155b in KrollGetProperty () #4 0x002da7ff in TI::TiCallbackObject::getOwnPropertySlot(TI::TiExcState*, TI::Identifier const&, TI::PropertySlot&) () #5 0x002b8b2a in _ZN2TI6TiCell22fastGetOwnPropertySlotEPNS_10TiExcStateERKNS_10IdentifierERNS_12PropertySlotE [inlined] () #6 0x002b8b2a in TI::TiValue::get(TI::TiExcState*, TI::Identifier const&, TI::PropertySlot&) const () #7 0x002b6126 in cti_op_get_by_id_generic () #8 0x0c3f9746 in () #9 0x00273415 in TI::Interpreter::execute(TI::FunctionExecutable*, TI::TiExcState*, TI::TiFunction*, TI::TiObject*, TI::ArgList const&, TI::ScopeChainNode*, TI::TiValue*) at /Users/stiv/src/appcelerator/tijscore/TiCore/jit/JITCode.h:84 #10 0x002c4bed in TI::TiFunction::call(TI::TiExcState*, TI::TiValue, TI::ArgList const&) () #11 0x0023c30b in TI::call(TI::TiExcState*, TI::TiValue, TI::CallType, TI::CallData const&, TI::TiValue, TI::ArgList const&) () #12 0x002d7816 in TiObjectCallAsFunction () #13 0x00056d53 in -[KrollObject triggerEvent:withObject:thisObject:] () #14 0x000492a1 in -[KrollEvent invoke:] () #15 0x0004800d in -[KrollContext invoke:] () #16 0x00046bee in -[KrollContext main] () #17 0x0067acf4 in -[NSThread main] () {noformat} See [Q&A](http://developer.appcelerator.com/question/123951/crash-updating-window-from-focus-event-while-querying-database--ios-43--sdk-172)

Comments

  1. Paul Dowsett 2011-08-10

    Martin There are problems with your usecase that may be impacting the stability of your app. Please make sure you have received adequate advice in the Q&A before you consider a crash must be the result of a bug. I will make some suggestions in your question, and hopefully we can get to the bottom of it. I will close this ticket for the moment, and we will open it again if it turns out, in actual fact, to be a bug. Note that this ticket is missing some information. Please follow the [Jira Ticket Checklist](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-Summary%3AJiraTicketChecklist) when raising tickets. Thanks
  2. Martin Slater 2011-08-17

    Hey Paul, Just wondering when you will be able to get a fix in for this. I am about 3-4 weeks away from release and this is one of 2 issues currently that will hold that back. (other is a sound issue in 1.7.2 that I'm still trying to get a solid repro for where they start playing and cut out) thanks Martin
  3. Paul Dowsett 2011-09-07

    Martin Please watch the linked ticket for the ongoing status of this issue. Thank you.
  4. Paul Dowsett 2011-12-27

    Ticket resolved and not updated since last curator action.

JSON Source