This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bug report: fig2dev -L latex segfaults on cygwin


On Fri, 7 Apr 2006, ilya beilin wrote:

> Hello,
> fig2dev version 3.2.4 crashes when converting certain line styles to
> latex.
> I could reproduce the crash only on Cygwin, on Linux the
> translation works somehow (the line style is apparently not supported
> and is replaced by the default one).
>
> Here is the test case:
> $ cat crashes-on-cygwin.fig
> #FIG 3.2
> Portrait
> Center
> Inches
> Letter
> 100.00
> Single
> -2
> 1200 2
> 2 4 3 1 0 7 50 -1 -1 4.000 0 0 7 0 0 5
>          1125 2850 600 2850 600 2250 1125 2250 1125 2850
> $ fig2dev.exe -L latex crashes-on-cygwin.fig
> \setlength{\unitlength}{3947sp}%
> %
> \begingroup\makeatletter\ifx\SetFigFont\undefined%
> \gdef\SetFigFont#1#2#3#4#5{%
>   \reset@font\fontsize{#1}{#2pt}%
>   \fontfamily{#3}\fontseries{#4}\fontshape{#5}%
>   \selectfont}%
> \fi\endgroup%
> \begin{picture}(549,624)(589,-2023)
> \thinlines
> {\color[rgb]{0,0,0}\put(706,-1906){\oval(210,210)[bl]}
> \put(706,-1516){\oval(210,210)[tl]}
> \put(1021,-1906){\oval(210,210)[br]}
> \put(1021,-1516){\oval(210,210)[tr]}
> Segmentation fault (core dumped)
>
> The example and the system details are in the attachment.

Ilya,

FYI, the attachment did not come through to the Cygwin list.  However,
this is a genuine fig2dev bug (not Cygwin-specific), though it manifests
only on Cygwin for some reason.  In your case, the crash occurs in
put_arc_box() in dev/genlatex.c, when it tries to call put_line().  Now,
put_line is a function pointer that is set in the switch in lines 429-441,
which only sets it for 3 line styles (SOLID_LINE, DASHED_LINE, and
DOTTED_LINE), and doesn't have a default clause, so for more elaborate
line styles (from the newer xfig), the program jumps into
never-never-land.  Don't know why it works on Linux -- perhaps it's
picking up an old value off the stack from the previous call that ends up
being something reasonable (like put_solidline)...

In general, it's good programming practice to have default clauses in all
switch statements...  In any case, here's a patch that will fix the issue
for you ('ware the Tab characters):

--- dev/genlatex.c-orig	2006-04-07 10:31:19.137862400 -0400
+++ dev/genlatex.c	2006-04-07 10:30:13.914075200 -0400
@@ -438,6 +438,9 @@ double	val;
 		fprintf(stderr, "Dotted arc boxes approximated with solid arcs\n");
 	        put_line = put_dotline;
 		break;
+	    default:
+		fprintf(stderr, "Unknown line style -- approximating with solid lines\n");
+	        put_line = put_solidline;
 	    }
 	fprintf(tfp,
 		"\\put(%3d,%3d){\\oval(%3d,%3d)[bl]}\n"

HTH,
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_	    pechtcha@cs.nyu.edu | igor@watson.ibm.com
ZZZzz /,`.-'`'    -.  ;-;;,_		Igor Peshansky, Ph.D. (name changed!)
     |,4-  ) )-,_. ,\ (  `'-'		old name: Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte."
"But no -- you are no fool; you call yourself a fool, there's proof enough in
that!" -- Rostand, "Cyrano de Bergerac"

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]