Re: [sqlite] iPhone iOS 3.1.3 Sqlite3 Crashes Unless Compiled Without Optimizations

2011-12-01 Thread Gilles Vollant


The crash occur with sqlite 3.7.8 on line below:
  u.bp.pC->nullRow = (u8)u.bp.res;

  u.bp.pC did not reference a valid address.


here is the stack

(gdb) bt
#0  0x00055000 in sqlite3VdbeExec (p=0x18e9d8) at
/Volumes/hfsdata/sqliteTest/sqlite/sqlite3.c:68038
#1  0x96d2 in sqlite3_step (pStmt=0x18e9d8) at
/Volumes/hfsdata/sqliteTest/sqlite/sqlite3.c:61954
#2  0xc7f2 in sqlite3_exec (db=0xa85408, zSql=0x786688 "SELECT name,
rootpage, sql FROM 'main'.sqlite_master ORDER BY rowid", xCallback=0x3cfa5
, pArg=0x2fdfdec0, pzErrMsg=0x0) at
/Volumes/hfsdata/sqliteTest/sqlite/sqlite3.c:88791
#3  0x0003ce7a in sqlite3InitOne (db=0xa85408, iDb=0, pzErrMsg=0xa84410) at
/Volumes/hfsdata/sqliteTest/sqlite/sqlite3.c:91809
#4  0x0003ca6a in sqlite3Init (db=0xa85408, pzErrMsg=0xa84410) at
/Volumes/hfsdata/sqliteTest/sqlite/sqlite3.c:91875
#5  0xb9f2 in sqlite3ReadSchema [inlined] () at
/Volumes/hfsdata/sqliteTest/sqlite/sqlite3.c:91912
#6  0xb9f2 in sqlite3LocateTable (pParse=0xa84408, isView=0,
zName=0x786788 "base_version", zDbase=0x0) at
/Volumes/hfsdata/sqliteTest/sqlite/sqlite3.c:79437
#7  0x0003a604 in selectExpander (pWalker=0x2fdfe050, p=0x786708) at
/Volumes/hfsdata/sqliteTest/sqlite/sqlite3.c:95581
#8  0x00038560 in sqlite3WalkSelect (pWalker=0x2fdfe050, p=0x786708) at
/Volumes/hfsdata/sqliteTest/sqlite/sqlite3.c:71787
#9  0x00037bcc in sqlite3SelectPrep (pParse=0xa84408, p=0x786708,
pOuterNC=) at
/Volumes/hfsdata/sqliteTest/sqlite/sqlite3.c:95776
#10 0x0002a296 in sqlite3Select (pParse=0xa84408, p=0x786708,
pDest=0x2fdfe2c4) at /Volumes/hfsdata/sqliteTest/sqlite/sqlite3.c:96116
#11 0x000220e2 in yy_reduce (yypParser=0xab8208, yyruleno=112) at
/Volumes/hfsdata/sqliteTest/sqlite/sqlite3.c:107894
#12 0x000200ce in sqlite3Parser (yyp=0xab8208, yymajor=1, pParse=) at
/Volumes/hfsdata/sqliteTest/sqlite/sqlite3.c:108862
#13 0xdaa4 in sqlite3RunParser (pParse=0xa84408, zSql=0x68f87 "SELECT *
FROM base_version", pzErrMsg=0x2fdfe430) at
/Volumes/hfsdata/sqliteTest/sqlite/sqlite3.c:109699
#14 0x000520b0 in sqlite3Prepare (db=0xa85408, zSql=0x68f87 "SELECT * FROM
base_version", nBytes=,
saveSqlFlag=1, pReprepare=0x0, ppStmt=0x2fdfe4a8, pzTail=0x0) at
/Volumes/hfsdata/sqliteTest/sqlite/sqlite3.c:92089
#15 0xcfb6 in sqlite3LockAndPrepare (db=0xa85408, zSql=0x68f87 "SELECT *
FROM base_version", nBytes=-1, saveSqlFlag=1, pOld=0x0, ppStmt=0x2fdfe4a8,
pzTail=0x0) at /Volumes/hfsdata/sqliteTest/sqlite/sqlite3.c:92181
#16 0xd084 in sqlite3_prepare_v2 (db=, zSql=, nBytes=, ppStmt=, pzTail=0x0) at
/Volumes/hfsdata/sqliteTest/sqlite/sqlite3.c:92256
#17 0x232c in getDatabaseVersion [inlined] () at
/Volumes/hfsdata/sqliteTest/Classes/MainViewController.m:19
.

#38 0x21bc in main (argc=, argv=)
at /Volumes/hfsdata/sqliteTest/main.m:14
(gdb) 



On 3 Nov 2011, at 8:39am, Price,Ray wrote:

> I'm having a VERY odd problem with Sqlite at the moment.  I have an
application that works fine and has been working find for over a year, but
since updating to xcode 4 and the ios 5 SDK Sqlite crashes regularly, but
ONLY on older devices still running iOS 3.1.3.
> 
> However, if I compile the sqlite3.c module WITHOUT optimizations, the
crash goes away, but this is obviously FAR from ideal.
> 
> Has anyone else experienced this?

First, well done for identifying your workaround.  I use Xcode and iOS and
I've had situations where compiling without optimization cures crashes.  But
they haven't involved SQLite code.  I don't know how much optimization
improves sqlite's speed.  Might help a lot, might not.

One problem with sqlite is that it has to compile on a lot of platforms with
a lot of compilers and it's impossible to get rid of all warnings under
those conditions.

If possible play with each of the optimization levels and find out which
level is causing the problems.  If you can figure out what part of the C
code is causing the problem, or post an extract from the crash log which
gives symbol names, someone here might be able to figure out what to fix in
the code.

Simon.


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] iPhone iOS 3.1.3 Sqlite3 Crashes Unless Compiled Without Optimizations

2011-11-04 Thread Price,Ray
Interesting, I'll give that a try, thanks.  Good to know I'm not going crazy... 
my worry with this kind of thing is always that my memory management is not 
bulletproof and is having a knock-on effect somewhere.

Thanks
Ray

-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of James Berry
Sent: Thursday, November 03, 2011 3:56 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] iPhone iOS 3.1.3 Sqlite3 Crashes Unless Compiled Without 
Optimizations


On Nov 3, 2011, at 6:19 AM, James Berry wrote:

> I've seen this same problem. It crashes seemingly due to bugs in llvm-clang 
> when compiled for arm6 if, as you say, optimizations at any level are turned 
> on. I've worked around this issue by turning off optimizations for arm6. 
> Sqlite3, by the way, is not the only bit of my iOS app that encounters 
> problems with that arm6 optimization combination. arm6, fortunately, is 
> required by fewer and fewer devices these days.
> 
> Report bugs to apple, if you care.

Btw, somebody mentioned to me this morning that these issues can be worked 
around by disabling thumb mode when compiling for arm6 (as an alternative to 
disabling optimizations). That would be the -mno-thumb switch to the compiler. 
Note that these issues only manifest when compiling using the llvm/clang 
compiler.

James

> 
> 
> On Nov 3, 2011, at 1:39 AM, Price,Ray wrote:
> 
>> Hi All,
>> 
>> I'm having a VERY odd problem with Sqlite at the moment.  I have an 
>> application that works fine and has been working find for over a year, but 
>> since updating to xcode 4 and the ios 5 SDK Sqlite crashes regularly, but 
>> ONLY on older devices still running iOS 3.1.3.
>> 
>> However, if I compile the sqlite3.c module WITHOUT optimizations, the crash 
>> goes away, but this is obviously FAR from ideal.
>> 
>> Has anyone else experienced this?  Is there anything I can do to narrow down 
>> the problem, or is there anyone I could report this to?
>> 
>> Thanks
>> Ray
>> 
>> 
>> 
>> 
>> This e-mail message, including any attachments, is for the sole use of the 
>> person to whom it has been sent, and may contain information that is 
>> confidential or legally protected. If you are not the intended recipient or 
>> have received this message in error, you are not authorized to copy, 
>> distribute, or otherwise use this message or its attachments. Please notify 
>> the sender immediately by return e-mail and permanently delete this message 
>> and any attachments. Gartner makes no warranty that this e-mail is error or 
>> virus free.
>> ___
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] iPhone iOS 3.1.3 Sqlite3 Crashes Unless Compiled Without Optimizations

2011-11-03 Thread James Berry

On Nov 3, 2011, at 6:19 AM, James Berry wrote:

> I've seen this same problem. It crashes seemingly due to bugs in llvm-clang 
> when compiled for arm6 if, as you say, optimizations at any level are turned 
> on. I've worked around this issue by turning off optimizations for arm6. 
> Sqlite3, by the way, is not the only bit of my iOS app that encounters 
> problems with that arm6 optimization combination. arm6, fortunately, is 
> required by fewer and fewer devices these days.
> 
> Report bugs to apple, if you care.

Btw, somebody mentioned to me this morning that these issues can be worked 
around by disabling thumb mode when compiling for arm6 (as an alternative to 
disabling optimizations). That would be the -mno-thumb switch to the compiler. 
Note that these issues only manifest when compiling using the llvm/clang 
compiler.

James

> 
> 
> On Nov 3, 2011, at 1:39 AM, Price,Ray wrote:
> 
>> Hi All,
>> 
>> I'm having a VERY odd problem with Sqlite at the moment.  I have an 
>> application that works fine and has been working find for over a year, but 
>> since updating to xcode 4 and the ios 5 SDK Sqlite crashes regularly, but 
>> ONLY on older devices still running iOS 3.1.3.
>> 
>> However, if I compile the sqlite3.c module WITHOUT optimizations, the crash 
>> goes away, but this is obviously FAR from ideal.
>> 
>> Has anyone else experienced this?  Is there anything I can do to narrow down 
>> the problem, or is there anyone I could report this to?
>> 
>> Thanks
>> Ray
>> 
>> 
>> 
>> 
>> This e-mail message, including any attachments, is for the sole use of the 
>> person to whom it has been sent, and may contain information that is 
>> confidential or legally protected. If you are not the intended recipient or 
>> have received this message in error, you are not authorized to copy, 
>> distribute, or otherwise use this message or its attachments. Please notify 
>> the sender immediately by return e-mail and permanently delete this message 
>> and any attachments. Gartner makes no warranty that this e-mail is error or 
>> virus free.
>> ___
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] iPhone iOS 3.1.3 Sqlite3 Crashes Unless Compiled Without Optimizations

2011-11-03 Thread James Berry
I've seen this same problem. It crashes seemingly due to bugs in llvm-clang 
when compiled for arm6 if, as you say, optimizations at any level are turned 
on. I've worked around this issue by turning off optimizations for arm6. 
Sqlite3, by the way, is not the only bit of my iOS app that encounters problems 
with that arm6 optimization combination. arm6, fortunately, is required by 
fewer and fewer devices these days.

Report bugs to apple, if you care.

James


On Nov 3, 2011, at 1:39 AM, Price,Ray wrote:

> Hi All,
> 
> I'm having a VERY odd problem with Sqlite at the moment.  I have an 
> application that works fine and has been working find for over a year, but 
> since updating to xcode 4 and the ios 5 SDK Sqlite crashes regularly, but 
> ONLY on older devices still running iOS 3.1.3.
> 
> However, if I compile the sqlite3.c module WITHOUT optimizations, the crash 
> goes away, but this is obviously FAR from ideal.
> 
> Has anyone else experienced this?  Is there anything I can do to narrow down 
> the problem, or is there anyone I could report this to?
> 
> Thanks
> Ray
> 
> 
> 
> 
> This e-mail message, including any attachments, is for the sole use of the 
> person to whom it has been sent, and may contain information that is 
> confidential or legally protected. If you are not the intended recipient or 
> have received this message in error, you are not authorized to copy, 
> distribute, or otherwise use this message or its attachments. Please notify 
> the sender immediately by return e-mail and permanently delete this message 
> and any attachments. Gartner makes no warranty that this e-mail is error or 
> virus free.
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] iPhone iOS 3.1.3 Sqlite3 Crashes Unless Compiled Without Optimizations

2011-11-03 Thread Simon Slavin

On 3 Nov 2011, at 8:39am, Price,Ray wrote:

> I'm having a VERY odd problem with Sqlite at the moment.  I have an 
> application that works fine and has been working find for over a year, but 
> since updating to xcode 4 and the ios 5 SDK Sqlite crashes regularly, but 
> ONLY on older devices still running iOS 3.1.3.
> 
> However, if I compile the sqlite3.c module WITHOUT optimizations, the crash 
> goes away, but this is obviously FAR from ideal.
> 
> Has anyone else experienced this?

First, well done for identifying your workaround.  I use Xcode and iOS and I've 
had situations where compiling without optimization cures crashes.  But they 
haven't involved SQLite code.  I don't know how much optimization improves 
sqlite's speed.  Might help a lot, might not.

One problem with sqlite is that it has to compile on a lot of platforms with a 
lot of compilers and it's impossible to get rid of all warnings under those 
conditions.

If possible play with each of the optimization levels and find out which level 
is causing the problems.  If you can figure out what part of the C code is 
causing the problem, or post an extract from the crash log which gives symbol 
names, someone here might be able to figure out what to fix in the code.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users