Bug 254203 - Libpgf relevant : digiKam crashes while displaying thumbnails on Ultra-SPARC platform...
Summary: Libpgf relevant : digiKam crashes while displaying thumbnails on Ultra-SPARC ...
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Portability-Runtime (show other bugs)
Version: 1.5.0
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-14 22:48 UTC by Jean-Fred
Modified: 2012-06-27 10:41 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 1.6.0


Attachments
supposedly better endianess detection for libPGF (2.12 KB, patch)
2010-10-19 17:09 UTC, Raphael Schweizer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Fred 2010-10-14 22:48:38 UTC
Version:           1.5.0 (using KDE 4.4.5) 
OS:                Linux

This is for SPARC (Ultra10 workstation) only!!!

This issue has been observed on versions:
- 1.2.0 (debian "squeeze" pre-compiler pakage).
- 1.4.0 (build from tarball).
- 1.5.0 (build from tarball).

The first time digiKam is started, thumbnails are displayed correctly while they are created. If scrolling thumbnail area, digikam crashes.
Then the next time digikam is started, as soon as an album is selected, digikam crashes while trying to display 1st thumbnail. This is 100% repeatable.

Running digiKam under gdb, crash has been traced back to libpgf ("ClearBitBlock" function in "Decoder.cpp"). This bug seems to have been reported in the past (and fixed) on PPC platform.

Looking a bit forward, it appears that "__BIG_ENDIAN__" (should be managed somewhere in the Makefiles, as it is not provided by compiler) macro is never defined and then libpgf is compiled as "little endian" on a "big endian" machine...
For debug purpose "Hardcoding" a "#define __BIG_ENDIAN__" at the beginning of the files that requires it fixes the issue.

I've no idea on how to patch the cmake scripts to have a clean configuration for SPARC machines... Sorry sorry...

Reproducible: Always

Steps to Reproduce:
Case 1: digikam has never been run (or database files deleted):
- 1st build Thumbnails database.
- Then scroll through thumbnails.
=> Crash.

Case 2: digikam has alread been run, and a thumbnail database already exist.
- Select an album.
=> Crash.


Actual Results:  
- Crash with segmentation fault.

Expected Results:  
Display thumbnails!!!

SPARC platform (Ultra 10 workstation, running debian "Squeeze").
Comment 1 caulier.gilles 2010-10-15 10:29:41 UTC
Look like Cmake script check this for you :

-- ----------------------------------------------------------------------------------
--  kipi-plugins 1.6.0 dependencies results   <http://www.kipi-plugins.org>
-- 
--  libjpeg library found.................... YES
--  libtiff library found.................... YES
--  libpng library found..................... YES
--  libkipi library found.................... YES
--  libkexiv2 library found.................. YES
--  libkdcraw library found.................. YES
--  libxml2 library found.................... YES (optional)
--  libxslt library found.................... YES (optional)
--  libexpat library found................... YES (optional)
--  native threads support library found..... YES (optional)
--  libopengl library found.................. YES (optional)
--  Qt4 OpenGL module found.................. YES
--  libopencv library found.................. YES (optional)
--  libgpod library found.................... YES (optional)
--  Gdk library found........................ YES (optional)
--  libkdepim library found.................. YES (optional)
--  qca2 library found....................... YES (optional)
--  libkdcraw >= 1.1.0 library found......... YES (optional)
--  libkexiv2 >= 1.1.0 library found......... YES (optional)
--  OpenMP library found..................... YES (optional)
--  libX11 library found..................... YES (optional)
--  libksane library found................... YES (optional)
-- 
--  kipi-plugins will be compiled............ YES
--  Shwup will be compiled................... YES (optional)
--  HtmlExport will be compiled.............. YES (optional)
--  AdvancedSlideshow will be compiled....... YES (optional)
--  ImageViewer will be compiled............. YES (optional)
--  AcquireImages will be compiled........... YES (optional)
--  DNGConverter will be compiled............ YES (optional)
--  RemoveRedEyes will be compiled........... YES (optional)
--  IpodExport will be compiled.............. YES (optional)
--  Calendar will be compiled................ YES (optional)
-- ----------------------------------------------------------------------------------
-- 
-- Check if the system is big endian
-- Searching 16 bit integer
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian

It will be easy to reuse this flag in digiKam 

Gilles Caulier
Comment 2 caulier.gilles 2010-10-15 11:11:54 UTC
But there is more simple to get endianess using Qt4API :

http://lxr.kde.org/source/extragear/graphics/digikam/libs/dimg/dimg.cpp#1506

Gilles Caulier
Comment 3 caulier.gilles 2010-10-15 11:13:59 UTC
As libpgf do not depand of Qt4, this flag can be used instead :

http://lxr.kde.org/source/extragear/graphics/digikam/libs/threadimageio/pgfutils.cpp#68

Gilles Caulier
Comment 4 caulier.gilles 2010-10-15 12:10:48 UTC
In fact __BIG_ENDIAN__ is defined in the core system as well, thriugh C++ header (i think)

But look like littlecms library handle endianness:

http://github.com/mm2/Little-CMS/blob/master/include/lcms2.h#L169

I will patch svn trunk code in this way

Gilles Caulier
Comment 5 caulier.gilles 2010-10-15 12:36:03 UTC
SVN commit 1186191 by cgilles:

at this place endianess can be handle using Qt4 api
CCBUGS: 254203


 M  +29 -16    pgfutils.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1186191
Comment 6 caulier.gilles 2010-10-15 12:45:13 UTC
I CC libpgf maintainer for info...

Gilles Caulier
Comment 7 caulier.gilles 2010-10-15 13:01:58 UTC
SVN commit 1186197 by cgilles:

fix endiannes detection into libpgf. If it work properly unde SPARC architecture, this patch must be backported to libpgf as well.
CCBUGS: 254203
CCMAIL: rschweizer@schweizer-informatik.ch


 M  +30 -3     PGFplatform.h  
 M  +2 -2      PGFtypes.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1186197
Comment 8 caulier.gilles 2010-10-15 13:03:12 UTC
to jfc31,

I commited a patch to KDE repository. Please checkout code from svn trunk and try again on your SPARC computer. Thanks in advance

Gilles Caulier
Comment 9 Raphael Schweizer 2010-10-19 17:09:15 UTC
Created attachment 52681 [details]
supposedly better endianess detection for libPGF
Comment 10 Raphael Schweizer 2010-10-19 17:11:29 UTC
Gilles,

I tested your patch and found no problems so far. It will be integrated in the
next libPGF release (no specific date yet).
Encoder and Decoder have endian specific code too, the attached patch will fix
this and remove a redundant check from the lcms2 code.

@jfc31: Please test this patch too.

Thanks, Raphael

PS: ah, I'll never get used to the "Add an attachment" process ;-)
Comment 11 caulier.gilles 2010-10-20 10:19:10 UTC
SVN commit 1187700 by cgilles:

apply endianness patch #52681 from Raphael Schweizer
CCBUGS: 254203


 M  +2 -2      Decoder.cpp  
 M  +4 -4      Encoder.cpp  
 M  +0 -6      PGFplatform.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1187700
Comment 12 caulier.gilles 2010-10-20 10:36:58 UTC
SVN commit 1187707 by cgilles:

Fix endianness detection into LensFun library, as LibPGF do.
CCBUGS: 254203
CCMAIL: zap@homelink.ru


 M  +22 -1     rgbpixel.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1187707
Comment 13 caulier.gilles 2010-10-20 10:41:01 UTC
jfc31,

I fixed also an endianness detection issue in lensfun library included in digiKam core.

Please can you checkout digikam source code from svn trunk (1.6.0) and check if all is fine for you ?

Thanks in advance

Gilles Caulier
Comment 14 Jean-Fred 2010-10-22 23:52:19 UTC
Gilles, Raphael,

It took me quite some time to test the fixes... Sorry for that, I'm at least as slow as my old computer ;)...

I did the tests with the 21-Oct-2010-#2PM svn image.

First of all everything compiles well.

But at run time things are not that nice as the libpgf issue is still there (the code seems now to be a bit more talkative and I've some error message before crash pointing out PGF code).
I digged a bit more in the files and came up with the following thing:

Something is incorrectly set in PGFplatform.h, on line 40 we should have 

#if defined(__sgi__) || defined(__sgi) || defined(__powerpc__) || defined(sparc) || defined(__sparc__)

and not:
#if defined(__sgi__) || defined(__sgi) || defined(__powerpc__) || defined(sparc) || defined(sparc)

-> The correct macro that gcc uses to define SPARC processors is __sparc__

(see http://predef.sourceforge.net/prearch.html  a good summarry of how the various compilers indicates which processor they are targetting... a real mess indeed...)

Thanks a lot for all this work, this great software and for beeing so reactive fixing things!

Gilles,

I didn't had opportunity to test lensfun stuff. I'll do that later (I still need to learn digiKam a bit more)...


Jean-Fred
Comment 15 caulier.gilles 2010-10-23 18:39:46 UTC
SVN commit 1188992 by cgilles:

fix sparc macro from gcc
CCBUGS: 254203


 M  +1 -1      PGFplatform.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1188992
Comment 16 caulier.gilles 2010-10-23 18:42:26 UTC
Jean-Fred,

PGF is patch in svn. Forget lensfun, the code affected is not used by digiKam and i removed it as well.

Please recompile digiKam using trunk code including my fix, run it, and look if it crash again. If yes, post a gdb backtrace in this report.

Thanks in advance

Gilles Caulier
Comment 17 Jean-Fred 2010-10-29 09:22:42 UTC
Gilles,

DigiKam is not crashing anymore while displaying thumbnails!
Thanks,

    Jean-Fred
Comment 18 caulier.gilles 2010-10-29 09:39:21 UTC
Thanks Jean-Fred... I close this file now...

Raphael,

please take a care about the small adjustment in libpgf source code done by commit http://websvn.kde.org/?view=rev&revision=1188992

Look comment #14 for details

Best

Gilles Caulier
Comment 19 Raphael Schweizer 2010-10-29 13:21:30 UTC
Thanks for reporting and testing.
I patched our code base, so the changes will eventually also show up on SourceForge.

Best, Raphael