mate-desktop / atril

A document viewer for MATE
http://www.mate-desktop.org
GNU General Public License v2.0
205 stars 62 forks source link

thumbnail generation in epub backend is faulty #187

Open monsta opened 8 years ago

monsta commented 8 years ago

Originally reported at https://bugs.launchpad.net/bugs/1540018, reproduced by running atril-thumbnailer manually in LMDE 2.

Stacktrace:

(gdb) bt full
#0  0x00007ffff6b929bc in _cairo_surface_is_image (surface=0x69e0d0) at ../../../../src/cairo-image-surface-inline.h:77
No locals.
#1  INT_cairo_image_surface_get_width (surface=surface@entry=0x69e0d0) at ../../../../src/cairo-image-surface.c:613
        image_surface = 0x69e0d0
#2  0x00007ffff7bc104e in ev_document_misc_surface_rotate_and_scale (surface=0x69e0d0, dest_width=128, dest_height=173, dest_rotation=dest_rotation@entry=0)
    at ev-document-misc.c:301
        new_surface = <optimized out>
        cr = <optimized out>
        width = <optimized out>
        height = <optimized out>
        new_width = 128
        new_height = 173
#3  0x00007fffef1bcc35 in epub_document_thumbnails_get_thumbnail (document=<optimized out>, rc=<optimized out>, border=<optimized out>)
    at epub-document.c:128
        webpage = <optimized out>
        width = <optimized out>
        height = <optimized out>
#4  0x0000000000401bf8 in atril_thumbnail_pngenc_get (document=0x68b8e0, thumbnail=0x612890 "/home/monsta/atril-stuff/NASAsFirstA-ebook.epub", 
    size=<optimized out>) at atril-thumbnailer.c:171
        rc = 0x7fffe8008ed0
        width = 800
        height = 600
        pixbuf = <optimized out>
        page = 0x7fffe8008f00
#5  0x0000000000401892 in main (argc=1, argv=0x7fffffffe658) at atril-thumbnailer.c:323
        context = 0x68b8e0
        file = 0x6254e0
        error = 0x0

@rootAvish: please take a look at this piece of code. This is not right.

static GdkPixbuf *
epub_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
                                        EvRenderContext      *rc,
                                        gboolean              border)
{
    cairo_surface_t *webpage;
    GdkPixbuf *thumbnailpix = NULL ;
    gint width,height;
    epub_document_thumbnails_get_dimensions(document,rc,&width,&height);
    webpage = ev_document_misc_surface_rotate_and_scale(rc->page->backend_page,width,height,0);
    thumbnailpix = ev_document_misc_pixbuf_from_surface(webpage);
    return thumbnailpix;
}

In other parts of the same file, backend_page is treated as a pointer to gchar. So it should not be passed to a function that expects a pointer to cairo_surface_t. :confused:

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/31322528-thumbnail-generation-in-epub-backend-is-faulty?utm_campaign=plugin&utm_content=tracker%2F1323318&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1323318&utm_medium=issues&utm_source=github).
rootAvish commented 8 years ago

I don't know how, but this issue evaded me for the longest time, as in I missed the notification back in February(my fault as I was busy with university work and didn't check notifications for a month) and when I checked a bunch of them in the next month I didn't catch this. I'll fix it as soon as possible.

monsta commented 8 years ago

Thanks - would be nice to fix it, and I'm not really familiar with these parts of code.

raveit65 commented 8 years ago

fedora downstream report https://bugzilla.redhat.com/show_bug.cgi?id=1279102

monsta commented 8 years ago

@rootAvish: any progress on this?

monsta commented 8 years ago

Looks like I'll have to remove the thumbnails interface from epub backend completely. That code is incorrect anyway, so users would notice only the disappearance of segfault :smile:

monsta commented 8 years ago

Added workaround for now: https://github.com/mate-desktop/atril/commit/b479e541d113881b10ef7c0641688d62600c79a9

sc0w commented 6 years ago

Fixed with https://github.com/mate-desktop/atril/pull/299 ?

monsta commented 6 years ago

Nope. Still crashes if I enable the thumbnail generation for epubs again (revert https://github.com/mate-desktop/atril/commit/b479e541d113881b10ef7c0641688d62600c79a9). Looking at https://github.com/mate-desktop/atril/pull/299/commits/e3dc6ac882c947b1315ed78630450e9bc20e6bb6, I see that it only changed some spacing in the crashy code...