segfault while creating thumbnails
#1
Hi,

I'm experiencing segfaults everytime xbmc tries to create a thumbnail. I'm using Slackware 12.0.

When browsing videos, gdb's backtrace is :

#0 0xef239fe3 in ?? ()
#1 0xb73ea736 in jinit_forward_dct () from /usr/lib/libjpeg.so.62
#2 0xb73e2f99 in jinit_compress_master () from /usr/lib/libjpeg.so.62
#3 0xb65c8f9c in xjpeg_start_compress ()
from /inc/zbuild/xbmc/XBMC/system/ImageLib-i486-linux.so
#4 0xb65316bf in CxImageJPG::Encode ()
from /inc/zbuild/xbmc/XBMC/system/ImageLib-i486-linux.so
#5 0xb65263ea in CxImage::Encode ()
from /inc/zbuild/xbmc/XBMC/system/ImageLib-i486-linux.so
#6 0xb652697b in CxImage::Encode ()
from /inc/zbuild/xbmc/XBMC/system/ImageLib-i486-linux.so
#7 0xb6526a3d in CxImage::Save ()
from /inc/zbuild/xbmc/XBMC/system/ImageLib-i486-linux.so
#8 0xb651a679 in CreateThumbnailFromSurface ()
from /inc/zbuild/xbmc/XBMC/system/ImageLib-i486-linux.so
#9 0x083db000 in DllImageLib::CreateThumbnailFromSurface (this=0xb03754a8,
p1=0xae818ef8 "(\035\031", p2=192, p3=108, p4=768,
p5=0x8bf845c "/home/inc/zbuild/xbmc/XBMC/UserData/Thumbnails/Video/d/auto-dfde9b64.tbn") at DllImageLib.h:96

When browsing images, backtrace is :

#0 0xb65e6c65 in xjpeg_consume_input ()
from /inc/zbuild/xbmc/XBMC/system/ImageLib-i486-linux.so
#1 0xb65e702f in xjpeg_read_header ()
from /inc/zbuild/xbmc/XBMC/system/ImageLib-i486-linux.so
#2 0xb65458ce in CxImageJPG:Big Grinecode ()
from /inc/zbuild/xbmc/XBMC/system/ImageLib-i486-linux.so
#3 0xb653bc4e in CxImage:Big Grinecode ()
from /inc/zbuild/xbmc/XBMC/system/ImageLib-i486-linux.so
#4 0xb653ccc9 in CxImage:Big Grinecode ()
from /inc/zbuild/xbmc/XBMC/system/ImageLib-i486-linux.so
#5 0xb653cef4 in CxImage::Load ()
from /inc/zbuild/xbmc/XBMC/system/ImageLib-i486-linux.so
#6 0xb652fb77 in CreateThumbnail ()
from /inc/zbuild/xbmc/XBMC/system/ImageLib-i486-linux.so
#7 0x083daf6c in DllImageLib::CreateThumbnail (this=0xb00aaa64,
p1=0x9109234 "/inc/misc_images/.thumbcache/test-pattern.1024x768.bmp",
p2=0x8cbfa84 "/home/inc/zbuild/xbmc/XBMC/UserData/Thumbnails/Pictures/a/ab7412c0.tbn", p3=192, p4=192, p5=true) at DllImageLib.h:93


Binaries nightmare Sad
Reply
#2
From what I understand, ImageLib is composed by ("but not limited to") :

- JBIG-KIT Version 1.5
- libpng version 1.2.5
- CxImage 5.80
- ... ?

I'm trying to solve the above issue.
So, I ask the developers : is there any way I could rebuild ImageLib-i486-linux.so ?

Thank you.
Reply
#3
ubikdood Wrote:So, I ask the developers : is there any way I could rebuild ImageLib-i486-linux.so ?

Thank you.

Got it here :

svn co https://xbmc.svn.sourceforge.net/svnroot...es/cximage cximage
Reply
#4
Ok, now we're talking.
Rebuilt ImageLib-i486-linux.so with debug info. Here's an updated backtrace :

(gdb) bt
#0 0xb66a92c0 in xjpeg_consume_input (cinfo=0xbffc70a0) at jdapimin.c:304
#1 0xb66a96ce in xjpeg_read_header (cinfo=0xbffc70a0, require_image=1 '\001')
at jdapimin.c:258
#2 0xb6609c8e in CxImageJPG::Decode (this=0xbffd7348, hFile=0xbffdab50,
iMaxWidth=@0xbffdb358, iMaxHeight=@0xbffdb354) at ximajpg.cpp:191
#3 0xb66010cf in CxImage::Decode (this=0xbffdacf4, hFile=0xbffdab50,
imagetype=3, iWidth=@0xbffdb358, iHeight=@0xbffdb354) at ximaenc.cpp:566
#4 0xb6601d26 in CxImage::Decode (this=0xbffdacf4, hFile=0x80b6fa4,
imagetype=3, iWidth=@0xbffdb358, iHeight=@0xbffdb354) at ximaenc.cpp:483
#5 0xb6601e51 in CxImage::Load (this=0xbffdacf4,
filename=0xbffdb3cd "/inc/misc_images/.thumbcache/test-pattern.1024x768.jpg", imagetype=3, iWidth=@0xbffdb358, iHeight=@0xbffdb354) at ximaenc.cpp:386
#6 0xb65f5860 in CreateThumbnail (
file=0xbffdb3cd "/inc/misc_images/.thumbcache/test-pattern.1024x768.jpg",
thumb=0xbffdb404 "/home/hugo/ab7412c0.tbn", maxWidth=192, maxHeight=192,
rotateExif=true) at DllInterface.cpp:322
#7 0x0808087c in DllImageLib::CreateThumbnail (this=0x80b56e0,
p1=0xbffdb3cd "/inc/misc_images/.thumbcache/test-pattern.1024x768.jpg",
p2=0xbffdb404 "/home/hugo/ab7412c0.tbn", p3=192, p4=192, p5=true)
at DllImageLib.h:93
#8 0x080807ce in main () at testThumbnail.cpp:29


There's something wrong with the context. Most likely a bad function pointer.
Anyway, when/if I find a solution, I'll post it here. Ich will succeed !
Reply
#5
Lightbulb 
Got it.

Here's what's happening. The dynamic loader is using functions from libjpeg.so instead of using ImageLib's functions. Is this supposed to happen ?

Although they have the same names, the semantics seem to have changed considerably over time. These invocations incorrectly initialize the structures passed to them. Many members are incorrectly set to NULL which cause segment violations et al.

Some of the functions being mis-called :
- jinit_input_controller
- jinit_memory_mgr
- jinit_marker_reader
(and many others, I suppose)

One way to workaround would be to prevent libjpeg.so from being used. libjpeg is needed by libSDL_image (both in Slackware and Ubuntu). However, if we remove -lSDL_image from the linker XboxMediaCenter will not build, since TextureManager requires IMG_Load (which is provided by libSDL_image) :

Code:
./guilib/TextureManager.cpp:864:      SDL_Surface *original = IMG_Load(texturePath.c_str());

The other workaround would be to rename many functions in ImageLib to prevent them from having identical names to libjpeg's functions.
(I believe the same has been done with many structures)
Reply
#6
Workaround n. 3 : use LD_PRELOAD

Quote: LD_PRELOAD
A whitespace-separated list of additional, user-specified, ELF
shared libraries to be loaded before all others. This can be
used to selectively override functions in other shared
libraries. For set-user-ID/set-group-ID ELF binaries, only
libraries in the standard search directories that are also set-
user-ID will be loaded.

So, even if XboxMediaCenter is linked with -lSDL_image, this forces the dynamic linker to use ImageLib-i486-linux.so functions before libjpeg's functions :

Code:
LD_PRELOAD=system/ImageLib-i486-linux.so ./XboxMediaCenter
Reply
#7
I think the issue stems from the fact that on Ubuntu, SDL Image is not compiled with JPEG or TIFF support, so libjpeg doesn't get preloaded, whereas it appears that on Slackware, it is. I think recompiling ImageLib with the latest version of libjpeg ought to fix the issue.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Please read and follow the forum rules.
For troubleshooting and bug reporting, please make sure you read this first.


Image
Reply
#8
d4rk Wrote:I think the issue stems from the fact that on Ubuntu, SDL Image is not compiled with JPEG or TIFF support, so libjpeg doesn't get preloaded, whereas it appears that on Slackware, it is.

Slackware :

Code:
$ ldd /usr/lib/libSDL_image-1.2.so.0.1.4 | grep jpeg
        libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0xb7f40000)

A few days ago I downloaded libsdl-image1.2 from packages.ubuntu.com, just to check whether it was being linked against libjpeg. Doing the above showed jpeg being linked. But now that you mentioned it, I checked again and found out that I was testing libsdl-image1.2 from Dapper. But Feisty and Gutsy no longer link against lijpeg ! That explains it.


Quote:I think recompiling ImageLib with the latest version of libjpeg ought to fix the issue.

We're all using libjpeg 6b (http://www.ijg.org/files/). It hasn't been updated since 2001.
I guess you meant recompiling sdl_image disabling jpeg support (?).

Anyway, the mistery has been solved. Thank you.
Reply
#9
I have submitted a patch to sourceforge to apply to the CxImage library for those that are having this problem. Debian has the same issue. Make sure you have libjpeg-dev, libpng-dev and libjasper-dev installed.

http://sourceforge.net/tracker/index.php...tid=581840
Reply
#10
gnif Wrote:I have submitted a patch to sourceforge to apply to the CxImage library for those that are having this problem. Debian has the same issue. Make sure you have libjpeg-dev, libpng-dev and libjasper-dev installed.

http://sourceforge.net/tracker/index.php...tid=581840

thanks a lot! this is working for me on debian.
Reply
#11
I was having a similar problem using Ubuntu 8.04 (Hardy). Reinstalled Gutsy and all good
Reply
#12
thanks for the patch .. thumbnails without a crash within debian/sid and ubuntu/hardy.
Reply
#13
Ok,
I got this working on Fedora 7. The cximage patch applied fine but I was unable to build ImageLib because I was missing "jpegint.h" which did not seem to be included in the libjpeg-devel package. Grabbed the source for libjpeg and copied jpegint.h to /usr/include and all build well. Copied the ImageLib into the BUILD/system folder and now all seems good, no more crashes.
Reply
#14
Rainbow 
gnif Wrote:I have submitted a patch to sourceforge to apply to the CxImage library for those that are having this problem. Debian has the same issue. Make sure you have libjpeg-dev, libpng-dev and libjasper-dev installed.

http://sourceforge.net/tracker/index.php...tid=581840

Hi, i'm having the same problem on Hardy, could you give instructions on how to apply the patch?

Cheers,

Nurgle
Reply
#15
Big Grin 
UP !!!! please No
Reply

Logout Mark Read Team Forum Stats Members Help
segfault while creating thumbnails0