Re: pnm backend crashes graphical frontends (patch?)

From: Henning Meier-Geinitz (hmg-ml@gmx.de)
Date: Mon Sep 25 2000 - 12:09:44 PDT

  • Next message: Henning Meier-Geinitz: "SANE BeOS port"

    Hi,

    On Mon, Sep 25, 2000 at 10:50:47AM +0200, mh wrote:
    > I don't know, whether this is of interest, since I can't find it on the
    > TODO list.

    If something crashes in SANE it will be always of interest :-)

    > It seems that the pnm backend (still) randomly crashes the graphical
    > frontends.
    > (activate "Three-Pass Simulation"->scan preview->deactivate
    > "Three-Pass Simulation"->activate "Grayify" and "Hand-Scanner
    > Simulation"->scan preview->crash)

    I can't reproduce this here (no crash) but this needn't mean anything.

    > IMHO the problem is a static variable which is used as a counter
    > for an array. This one "points" outside the array under several
    > circumstances.

    Are you talking about rgbleftover? Where exactly does the pnm backend crash?

    > Can someone test the attached patch (for pnm.c in Sane-1.0.3) and
    > confirm that it fixes the problem? (it does for me)

    I didn't look too close at the code but are you sure that moving the three
    variables inside the function will cure the segfaults? Isn't this just good
    luck?

    Could you locate the exact problem with gdb?

    While trying to reproduce "your" bug I found another one: pnm.c doesn't like
    changing the frame type and bit depth during runtime! If you load a 1 bit
    lineart pnm and than a 8 bit gray --> segfault (in the frontend preview). If
    you load a grayscale (8 bit) and then color (3*8 bit) -> segfault. pnm.c
    initializes params.dpth and ppm_type at the beginning but not after a change
    of the input image (at least not in every case).

    This reveals another problem: xscanimage doesn't test if it gets too much
    data from the backend (at least in preview mode).

    Here is a patch for pnm.c (against latest cvs). This is just a quick hack. I
    will look more closely at pnm.c during the next days/weeks. Maybe I can find
    other bugs. Any ideas for fixes or addional features?

    Bye,
      Henning

    Index: backend/pnm.c
    ===================================================================
    RCS file: /cvsroot/external/sane/backend/pnm.c,v
    retrieving revision 1.2
    diff -u -r1.2 pnm.c
    --- pnm.c 2000/08/12 15:09:29 1.2
    +++ pnm.c 2000/09/25 19:06:19
    @@ -414,17 +414,21 @@
         {
           /* Binary monochrome. */
           parms.depth = 1;
    - gray = SANE_TRUE;
    -
           ppm_type = ppm_bitmap;
         }
       else if (!strncmp (buf, "P5", 2))
         {
           /* Grayscale. */
    - gray = SANE_TRUE;
    + parms.depth = 8;
           ppm_type = ppm_greyscale;
    + }
    + else if (!strncmp (buf, "P6", 2))
    + {
    + /* Color. */
    + parms.depth = 8;
    + ppm_type = ppm_color;
         }
    - else if (strncmp (buf, "P6", 2))
    + else
         {
           DBG(2, "%s is not a recognized PPM\n", filename);
           fclose (fn);
    @@ -444,7 +448,7 @@
         parms.lines = -1;
       else
         parms.lines = y;
    - if (gray)
    + if ((ppm_type == ppm_greyscale) || (ppm_type == ppm_bitmap) || gray)
         parms.format = SANE_FRAME_GRAY;
       else
         {

    --
    Source code, list archive, and docs: http://www.mostang.com/sane/
    To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com
    



    This archive was generated by hypermail 2b29 : Mon Sep 25 2000 - 11:59:44 PDT