sane-project-website/old-archive/2000-09/0267.html

224 wiersze
8.0 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>sane-devel: Re: pnm backend crashes graphical frontends (patch?)</TITLE>
<META NAME="Author" CONTENT="mh (moloch@nikocity.de)">
<META NAME="Subject" CONTENT="Re: pnm backend crashes graphical frontends (patch?)">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Re: pnm backend crashes graphical frontends (patch?)</H1>
<!-- received="Tue Sep 26 10:25:59 2000" -->
<!-- isoreceived="20000926172559" -->
<!-- sent="Mon, 25 Sep 2000 22:40:18 +0200" -->
<!-- isosent="20000925204018" -->
<!-- name="mh" -->
<!-- email="moloch@nikocity.de" -->
<!-- subject="Re: pnm backend crashes graphical frontends (patch?)" -->
<!-- id="00092523420200.02394@slowcrap" -->
<!-- inreplyto="20000925210944.C10590@hmg1.vortex.swb.de" -->
<STRONG>From:</STRONG> mh (<A HREF="mailto:moloch@nikocity.de?Subject=Re:%20pnm%20backend%20crashes%20graphical%20frontends%20(patch?)&In-Reply-To=&lt;00092523420200.02394@slowcrap&gt;"><EM>moloch@nikocity.de</EM></A>)<BR>
<STRONG>Date:</STRONG> Mon Sep 25 2000 - 13:40:18 PDT
<P>
<!-- next="start" -->
<LI><STRONG>Next message:</STRONG> <A HREF="0268.html">Massimiliano Origgi: "Re: SANE BeOS port"</A>
<UL>
<LI><STRONG>Previous message:</STRONG> <A HREF="0266.html">kwlee: "Porting Visioneer USB scanner on SANE issues"</A>
<LI><STRONG>In reply to:</STRONG> <A HREF="0260.html">Henning Meier-Geinitz: "Re: pnm backend crashes graphical frontends (patch?)"</A>
<!-- nextthread="start" -->
<LI><STRONG>Next in thread:</STRONG> <A HREF="0281.html">Henning Meier-Geinitz: "Re: pnm backend crashes graphical frontends (patch?)"</A>
<LI><STRONG>Reply:</STRONG> <A HREF="0281.html">Henning Meier-Geinitz: "Re: pnm backend crashes graphical frontends (patch?)"</A>
<!-- reply="end" -->
<LI><STRONG>Messages sorted by:</STRONG>
<A HREF="date.html#267">[ date ]</A>
<A HREF="index.html#267">[ thread ]</A>
<A HREF="subject.html#267">[ subject ]</A>
<A HREF="author.html#267">[ author ]</A>
</UL>
<HR NOSHADE><P>
<!-- body="start" -->
<P>
Henning Meier-Geinitz, Mon, 25 Sep 2000 :
<BR>
[...]
<BR>
<EM>&gt; &gt; It seems that the pnm backend (still) randomly crashes the graphical
</EM><BR>
<EM>&gt; &gt; frontends.
</EM><BR>
<EM>&gt; &gt; (activate &quot;Three-Pass Simulation&quot;-&gt;scan preview-&gt;deactivate
</EM><BR>
<EM>&gt; &gt; &quot;Three-Pass Simulation&quot;-&gt;activate &quot;Grayify&quot; and &quot;Hand-Scanner
</EM><BR>
<EM>&gt; &gt; Simulation&quot;-&gt;scan preview-&gt;crash)
</EM><BR>
<EM>&gt;
</EM><BR>
<EM>&gt; I can't reproduce this here (no crash) but this needn't mean anything.
</EM><BR>
<EM>&gt;
</EM><BR>
<EM>&gt; &gt; IMHO the problem is a static variable which is used as a counter
</EM><BR>
<EM>&gt; &gt; for an array. This one &quot;points&quot; outside the array under several
</EM><BR>
<EM>&gt; &gt; circumstances.
</EM><BR>
<EM>&gt;
</EM><BR>
<EM>&gt; Are you talking about rgbleftover? Where exactly does the pnm backend crash?
</EM><BR>
<EM>&gt;
</EM><BR>
<EM>&gt; &gt; Can someone test the attached patch (for pnm.c in Sane-1.0.3) and
</EM><BR>
<EM>&gt; &gt; confirm that it fixes the problem? (it does for me)
</EM><BR>
<EM>&gt;
</EM><BR>
<EM>&gt; I didn't look too close at the code but are you sure that moving the three
</EM><BR>
<EM>&gt; variables inside the function will cure the segfaults? Isn't this just good
</EM><BR>
<EM>&gt; luck?
</EM><BR>
&nbsp;
<BR>
<EM>&gt; Could you locate the exact problem with gdb?
</EM><BR>
<EM>&gt;
</EM><BR>
<EM>&gt; While trying to reproduce &quot;your&quot; bug I found another one: pnm.c doesn't like
</EM><BR>
<EM>&gt; changing the frame type and bit depth during runtime! If you load a 1 bit
</EM><BR>
<EM>&gt; lineart pnm and than a 8 bit gray --&gt; segfault (in the frontend preview). If
</EM><BR>
<EM>&gt; you load a grayscale (8 bit) and then color (3*8 bit) -&gt; segfault. pnm.c
</EM><BR>
<EM>&gt; initializes params.dpth and ppm_type at the beginning but not after a change
</EM><BR>
<EM>&gt; of the input image (at least not in every case).
</EM><BR>
<EM>&gt;
</EM><BR>
<P>Hi Henning,
<BR>
I think I should have explained better, why I thought the patch
<BR>
(if it is one at all) fixes the problem.
<BR>
I ran into this problem when I did some tests with my frontend.
<BR>
It seemed, that the problem was a call to sane_read() in the
<BR>
pnm backend, which ignored the value in max_length.
<BR>
Therefore the buffer allocated by the frontend is just to
<BR>
small sometimes.
<BR>
A search in the list archive revealed, that this problem was
<BR>
first reported in 1999 (or 1998 ?) by Nick Lamb (IIRC).
<BR>
<P>I'm not sure, whether my patch was just good luck,
<BR>
I thought I've tracked it down to the static variable
<BR>
rgblength, which holds its value between calls to sane_read().
<BR>
Setting this value to 0 at the beginning of sane_read() seemed
<BR>
to cure the problem, because this leads to a recalculation of rgblength
<BR>
and a reallocation of rgbbuf.
<BR>
Finally I couldn't find a single reason, why this variable (and also
<BR>
rgbbuf and rgbleftover) is static, so I moved it in sane_read().
<BR>
(But it's, of course, also possible that this is complete nonsense;-)
<BR>
<P>The bt always looks like this (and didn't help much):
<BR>
<P>Program received signal SIGSEGV, Segmentation fault.
<BR>
0x4001c101 in sane_pnm_read () at pnm.c:464
<BR>
464 }
<BR>
(gdb) bt
<BR>
#0 0x4001c101 in sane_pnm_read () at pnm.c:464
<BR>
#1 0x40017a06 in sane_dll_read () at dll.c:472
<BR>
#2 0x40017ca9 in sane_read () at dll-s.c:34
<BR>
#3 0x8050edd in input_available (data=0x20202621, source=606150947,
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;cond=639902240) at preview.c:536
<BR>
#4 0x1d191819 in ?? ()
<BR>
<P>This isn't 100% reproduceable. You normally have to do several scans with
<BR>
different settings until it crashes. However, with my patch, I can't reproduce
<BR>
it at all :-) ... and with your patch the problem you described is gone too :-)
<BR>
<P><P><EM>&gt; This reveals another problem: xscanimage doesn't test if it gets too much
</EM><BR>
<EM>&gt; data from the backend (at least in preview mode).
</EM><BR>
<P>Are you sure? No frontend can handle the case, when a call to sane_read()
<BR>
retrieves more data then specified in max_length.
<BR>
<P>bb
<BR>
<P>Michael
<BR>
<P>BTW
<BR>
Is it really necessary that a frontend can handle scanning of a grayscale image
<BR>
in three pass mode with a line number that isn't known a priori? I'm just
<BR>
wondering whether such a hardware exists ...
<BR>
<P><PRE>
--
Source code, list archive, and docs: <A HREF="http://www.mostang.com/sane/">http://www.mostang.com/sane/</A>
To unsubscribe: echo unsubscribe sane-devel | mail <A HREF="mailto:majordomo@mostang.com?Subject=Re:%20pnm%20backend%20crashes%20graphical%20frontends%20(patch?)&In-Reply-To=&lt;00092523420200.02394@slowcrap&gt;">majordomo@mostang.com</A>
</PRE>
<P><!-- body="end" -->
<HR NOSHADE>
<UL>
<!-- next="start" -->
<LI><STRONG>Next message:</STRONG> <A HREF="0268.html">Massimiliano Origgi: "Re: SANE BeOS port"</A>
<LI><STRONG>Previous message:</STRONG> <A HREF="0266.html">kwlee: "Porting Visioneer USB scanner on SANE issues"</A>
<LI><STRONG>In reply to:</STRONG> <A HREF="0260.html">Henning Meier-Geinitz: "Re: pnm backend crashes graphical frontends (patch?)"</A>
<!-- nextthread="start" -->
<LI><STRONG>Next in thread:</STRONG> <A HREF="0281.html">Henning Meier-Geinitz: "Re: pnm backend crashes graphical frontends (patch?)"</A>
<LI><STRONG>Reply:</STRONG> <A HREF="0281.html">Henning Meier-Geinitz: "Re: pnm backend crashes graphical frontends (patch?)"</A>
<!-- reply="end" -->
<LI><STRONG>Messages sorted by:</STRONG>
<A HREF="date.html#267">[ date ]</A>
<A HREF="index.html#267">[ thread ]</A>
<A HREF="subject.html#267">[ subject ]</A>
<A HREF="author.html#267">[ author ]</A>
</UL>
<!-- trailer="footer" -->
<HR NOSHADE>
<P>
<SMALL>
<EM>
This archive was generated by <A HREF="http://www.hypermail.org/">hypermail 2b29</A>
: <EM>Tue Sep 26 2000 - 10:27:12 PDT</EM>
</EM>
</SMALL>
</BODY>
</HTML>