division error in sqlite 3.5.9-5

Bug #254228 reported by Sep870
60
This bug affects 6 people
Affects Status Importance Assigned to Milestone
Python
Invalid
Undecided
Unassigned
Nominated for 2.5 by Trevor Caira
sqlite3 (Debian)
Fix Released
Unknown
sqlite3 (Ubuntu)
Fix Released
High
Unassigned
Intrepid
Fix Released
Undecided
Martin Pitt

Bug Description

Binary package hint: libsqlite3-0

Error occur in sqlite3 3.5.9-5 (command line interface) and python 2.5.2-10ubuntu1 (when connect do sqlite db).
When I try divide real number by real or integer sometimes I get null.

Example:
#sqlite3 test.db
SQLite version 3.5.9
Enter ".help" for instructions
sqlite> select 1.0/2;
0.5
sqlite> select 30/2;
15
sqlite> select 30.3/2;
15.15
sqlite> select 30.3/22; ---<------- ERROR

sqlite> select 30.3/2;
15.15
sqlite> select 30.3/3; ---<------- ERROR

sqlite> select 30.3/2;
15.15
sqlite> select 30.3/4;
7.575
sqlite> select 30.3/5; ---<------- ERROR

sqlite> select 30.3/6; ---<------- ERROR

sqlite> select 30.3/7; ---<------- ERROR

sqlite> select 30.3/8;
3.7875
sqlite> select 30.3/9; ---<------- ERROR

sqlite> select 30.3/10; ---<------- ERROR

sqlite> select 30.3/11; ---<------- ERROR

sqlite> select 30.3/12; ---<------- ERROR

sqlite> select 30.3/13; ---<------- ERROR

sqlite> select 30.3/14; ---<------- ERROR

sqlite> select 30.3/14.3; ---<------- ERROR

sqlite> select 30.3/15; ---<------- ERROR

sqlite> select 30.3/16;
1.89375
sqlite> select 30.3/16.0;
1.89375
sqlite> select 30.3/16.5; ---<------- ERROR

sqlite>

Regards
Sep

executive summary prepared by Rolf Leggewie as per https://wiki.ubuntu.com/StableReleaseUpdates:
2.1 impact: sqlite3 returns incorrect results, all packages using an sqlite3 backend are possibly affected by them. I know that at least anki (ichi2.net/anki/) is completely unusable in Intrepid because of this bug.

2.2 fix in .dev branch: dunno, but users report that jaunty packages (which are based off the same orig.tar.gz, I think) are not affected. somebody please comment.

2.3 minimal patch: http://launchpadlibrarian.net/21015612/sqlite3_3.5.9-3ubuntu1.debdiff which is attached to this bug report

2.4 test case: see original report above

2.5 regression potential: dunno, sorry. somebody please comment here.

Revision history for this message
Sep870 (sep870) wrote :

Solution:
Replace line in debian/rules:

DEB_OPT_FLAG := -O2 -fno-strict-aliasing -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_FTS3

to:

DEB_OPT_FLAG := -O2 -fno-strict-aliasing -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_FTS3 -fno-inline-small-functions

[from: http://<email address hidden>/msg35393.html]

Regards
sep

Revision history for this message
KUmo (shiragumo) wrote :

Bug and solution confirmed. Please fix.

The following bug seems to be associated.
http://www.sqlite.org/cvstrac/tktview?tn=3202

Revision history for this message
miraks (s-mankowski) wrote :
Changed in sqlite3:
status: New → In Progress
Revision history for this message
Rolf Leggewie (r0lf) wrote :

attaching debdiff (untested, but claims to be working as per comment 2) and subscribing u-m-s for sponsorship into Intrepid.

requesting verification that the fix is proper.

Revision history for this message
Rolf Leggewie (r0lf) wrote :

this is not a python bug.

Changed in python:
status: New → Incomplete
status: Incomplete → Invalid
Revision history for this message
Karol Będkowski (karol-bedkowski) wrote :

Confirm - patch works ok.

Regards
sep

Revision history for this message
Thierry Daucourt (thierry-daucourt) wrote :

I confirm the bug.
It affect division, but also addition, multiplication, substraction.
I am sorry, but I am unable to confirm that patch provided by Rolf works.
But I am able to confirm that everything works correctly if compiled from source (outside .deb packaging).
I suspect this bug to affect any debian derivative has the sqlite3_3.5.9-5.diff debian file does not have the compilation option "-fno-inline-small-functions" inside.

Revision history for this message
KUmo (shiragumo) wrote :

patch confirmed

Revision history for this message
miraks (s-mankowski) wrote :

Do you know when this fix will be officially in ubuntu 8.10 ?

Revision history for this message
Rolf Leggewie (r0lf) wrote :

I revisited this bug today and installed an Intrepid test environment in virtualbox. I am sorry to say that the patched package from my PPA still exhibits this problem. unsubscibing main sponsors until a proper fix has been found.

BTW, does this happen in Jaunty?

Revision history for this message
Sep870 (sep870) wrote :

Version 3.5.9-6 from Jaunty works fine.

Revision history for this message
miraks (s-mankowski) wrote :

Do you know when this fix will be officially in ubuntu 8.10 ?

Revision history for this message
Rolf Leggewie (r0lf) wrote :

Miraks, that's a rather unintelligent question given the fact that I reported that the compile flag fix is not working. I've yet to see a different fix being put forward.

To answer your question: It'll be in when it's in, maybe never. First a proper and minimal fix needs to be found. Once that is accomplished, an SRU exception will need to be granted. After that, it will take a few days or up to two weeks, I'd say. Right now, don't hold your breath.

BTW, I'm really angry at the two people confirming the patch was working fine when it now turns out they never really tried it.

Revision history for this message
miraks (s-mankowski) wrote :

Rolf,

Sorry for my unintelligent question, but this bug seems to be the same than:
this one: https://bugs.launchpad.net/ubuntu/+source/sqlite3/+bug/277870
this one: http://www.sqlite.org/cvstrac/tktview?tn=3202
and this one: http://www.sqlite.org/cvstrac/tktview?tn=3465,35

The solution (given by sqlite team) seems to be known: "If it is compiled with the --fast-math option, then sqlite strikes (what we believe to be) a gcc bug".

So, I don't understand why it's not corrected on 8.10 yet. (This is not a criticism, I don't know how to deliver it !)
I insist because I expect the correction to move to kubuntu 8.10.

Sorry again for my question and for my english.

Revision history for this message
Sep870 (sep870) wrote :

Rolf,
Today I install fresh Intrepid + apt-update. Result - bug as I have reported.
After I install libsqlite3-0 from your PPA and sqlite works fine.
Please - check again.

Revision history for this message
Rolf Leggewie (r0lf) wrote :

Sep870, thank you for retrying. I only updated the sqlite3 package itself, not the lib during my previous tests. It is indeed correct that the errors in the original report are fixed when installing both the lib and the package itself.

Revision history for this message
Rolf Leggewie (r0lf) wrote :

updated my debdiff patch so that the upload goes to intrepid-proposed as it should instead of intrepid itself

description: updated
Revision history for this message
Rolf Leggewie (r0lf) wrote :

I support the nomination to upload a patched version to intrepid-proposed.

Changed in sqlite3:
importance: Undecided → High
Rolf Leggewie (r0lf)
description: updated
Revision history for this message
Martin Pitt (pitti) wrote :

I confirm that I can reproduce this in intrepid, and that Jaunty works fine.

Changed in sqlite3:
status: In Progress → Fix Released
Revision history for this message
Martin Pitt (pitti) wrote :

I'd rather apply the upstream fix for that instead of fiddling with compiler options:

http://www.sqlite.org/cvstrac/chngview?cn=5396 . That's also done in Debian's 3.5.9-4 (which is why it is fixed in Jaunty).

Changed in sqlite3:
assignee: nobody → pitti
status: New → In Progress
Revision history for this message
Martin Pitt (pitti) wrote :

Uploaded to intrepid. Steve, please review.

Revision history for this message
Steve Langasek (vorlon) wrote :

Accepted into intrepid-proposed, please test and give feedback here. Please see https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in sqlite3:
status: In Progress → Fix Committed
Revision history for this message
Rolf Leggewie (r0lf) wrote :

fix verified for intrepid-proposed. Thank you. Please release.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package sqlite3 - 3.5.9-3ubuntu1

---------------
sqlite3 (3.5.9-3ubuntu1) intrepid-proposed; urgency=low

  * Add 05-improve-nan-testing-on-x86.patch: Improve NaN testing to work with
    divisions on highly optimized x86 code. This fixes empty results when
    doing e. g. "select 30.3/22". Patch from upstream
    (http://www.sqlite.org/cvstrac/chngview?cn=5396), taken from Debian's
    3.5.9-4 package. (LP: #254228)

 -- Martin Pitt <email address hidden> Tue, 27 Jan 2009 10:05:02 +0000

Changed in sqlite3:
status: Fix Committed → Fix Released
Changed in sqlite3 (Debian):
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.