[sane-devel] Xscanimage Exits with Segmentation Fault using HP 5370C

Henning Meier-Geinitz henning at meier-geinitz.de
Sun Sep 25 11:23:27 UTC 2005


[segfault of xscanimage with avision backend]

On Sat, Sep 24, 2005 at 07:39:51AM -0500, Dan McGhee wrote:
> Starting program: /usr/bin/xscanimage
> 
> *[This is the point at which I clicked "scan" in the preview window]*
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x08057467 in gsg_sync (dialog=0x80ef4f0) at gtkglue.c:1424
> 1424 curve = GTK_GAMMA_CURVE (dialog->element[i].widget)->curve;
> (gdb) bt
> #0 0x08057467 in gsg_sync (dialog=0x80ef4f0) at gtkglue.c:1424

The code is:


      if (opt->type != SANE_TYPE_INT && opt->type != SANE_TYPE_FIXED)
        continue;

      if (opt->size == sizeof (SANE_Word))
        continue;

      /* ok, we're dealing with an active vector */

      optlen = opt->size / sizeof (SANE_Word);
      optval = alloca (optlen * sizeof (optval[0]));
      vector = alloca (optlen * sizeof (vector[0]));

      curve = GTK_GAMMA_CURVE (dialog->element[i].widget)->curve;

So I looked into the avision backend for a SANE_TYPE_INT or
SANE_TYPE_FIXED option with a length != SANE_Word. There are the four
gamma vectors but they look ok. The only thing that looks fishy is
this (avision.c):

  s->opt[OPT_NUM_OPTS].name = "";
  s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS;
  s->opt[OPT_NUM_OPTS].desc = "";
  s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT;
  s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT;
  s->opt[OPT_NUM_OPTS].size = sizeof(SANE_TYPE_INT);

The last line is wrong (it must be sizeof(SANE_Word)). SANE_TYPE_INT
is an enum. Is this automatically and "int" or can it be shorter? I'm
not sure if this is actually the problem but you could try that:

  s->opt[OPT_NUM_OPTS].size = sizeof (SANE_Word);

in avision.c and recompile+install.

If that's not the problem, I guess Rene has to do some debugging
because without a scanner supported by the avision backend I can't
help more.

Does the segfault also occur with sane-backends 1.0.16?

Bye,
  Henning

  



More information about the sane-devel mailing list