The -..- and -.- line styles are broken

Bug #1317825 reported by madHamish
60
This bug affects 10 people
Affects Status Importance Assigned to Milestone
xfig (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

$ lsb_release -rd
Description: Ubuntu 14.04 LTS
Release: 14.04

$ apt-cache policy xfig
xfig:
  Installed: 1:3.2.5.c-1ubuntu1
  Candidate: 1:3.2.5.c-1ubuntu1
  Version table:
 *** 1:3.2.5.c-1ubuntu1 0
        500 http://za.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
        100 /var/lib/dpkg/status

Changing a line's style to -..- or -.- causes xfig to crash, with a Segmentation fault

Tags: patch
Revision history for this message
madHamish (antoine-dymond) wrote :

compiling xfig from source, and
$ valgrind ./xfig

== Process terminating with default action of signal 11 (SIGSEGV)
== General Protection Fault
== at 0x60CD35B: __fprintf_chk (fprintf_chk.c:30)
== by 0x44F8A5: error_handler (stdio2.h:97)
== by 0x5FF9FEF: ??? (in /lib/x86_64-linux-gnu/libc-2.19.so)
== by 0x47AEAF: set_line_stuff (w_drawprim.c:1408)
== by 0x47C977: pw_arcbox (w_drawprim.c:1150)
== by 0x446FC5: draw_arcbox (u_draw.c:752)
== by 0x44A47A: draw_line (u_draw.c:600)
== by 0x45BA53: redisplay_lineobject (u_redraw.c:261)
== by 0x45BDFA: redisplay_objects (u_redraw.c:170)
== by 0x45C162: redisplay_region.part.0 (u_redraw.c:464)
== by 0x45D21E: redisplay_line (u_redraw.c:661)
== by 0x422A35: done_line (e_edit.c:2183)

== Process terminating with default action of signal 11 (SIGSEGV)
== General Protection Fault
== at 0x60CD35B: __fprintf_chk (fprintf_chk.c:30)
== by 0x451135: ??? (in /usr/bin/xfig)
== by 0x5FF9FEF: ??? (in /lib/x86_64-linux-gnu/libc-2.19.so)
== by 0x47CC3F: ??? (in /usr/bin/xfig)
== by 0x47E6F7: ??? (in /usr/bin/xfig)
== by 0x448855: ??? (in /usr/bin/xfig)
== by 0x44BD0A: ??? (in /usr/bin/xfig)
== by 0x45D403: ??? (in /usr/bin/xfig)
== by 0x45D7AA: ??? (in /usr/bin/xfig)
== by 0x45DB12: ??? (in /usr/bin/xfig)
== by 0x45EBCE: ??? (in /usr/bin/xfig)
== by 0x40A7EC: ??? (in /usr/bin/xfig)

Revision history for this message
madHamish (antoine-dymond) wrote :

work around:

$ sudo apt-get remove xfig
$ apt-get build-dep xfig

get the Trusty packages
$ wget http://archive.ubuntu.com/ubuntu/pool/universe/x/xfig/xfig_3.2.5.c-1ubuntu1.dsc
$ wget http://archive.ubuntu.com/ubuntu/pool/universe/x/xfig/xfig_3.2.5.c.orig.tar.gz
$ wget http://archive.ubuntu.com/ubuntu/pool/universe/x/xfig/xfig_3.2.5.c-1ubuntu1.debian.tar.gz
$ dpkg-source -x xfig_3.2.5.c-1ubuntu1.dsc

now time to patch the dash_dot line code
$ cd xfig-3.2.5.c/
modify w_drawprim.c as follows :
$ diff w_drawprim.c_org w_drawprim.c
1302a1303
> static unsigned char dash_list_8[8] = {255, 255, 255, 255, 255, 255, 255, 255};
1403c1404
< dash_list[op][il] = (char) 255; /* too large for X! */
---
> dash_list_8[il] = (char) 255; /* too large for X! */
1405c1406
< dash_list[op][il] = (char) round(fl[il] * style_val *
---
> dash_list_8[il] = (char) round(fl[il] * style_val *
1408c1409
< dash_list[op][il] = (char)display_zoomscale;
---
> dash_list_8[il] = (char)display_zoomscale;
1410,1411c1411,1412
< if (dash_list[op][il]==0) /* take care for rounding to zero ! */
< dash_list[op][il]=1;
---
> if (dash_list_8[il]==0) /* take care for rounding to zero ! */
> dash_list_8[il]=1;
1413c1414
< XSetDashes(tool_d, gccache[op], 0, (char *) dash_list[op], nd);
---
> XSetDashes(tool_d, gccache[op], 0, (char *) dash_list_8, nd);

build
$ xmkmf
$ make

Test it, .$/xfig and draw shapes with dash_dot styles.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in xfig (Ubuntu):
status: New → Confirmed
Revision history for this message
Romano Giannetti (romano-giannetti) wrote :

I tested this minimal patch:

--- w_drawprim.c.orig 2014-06-11 17:23:29.348481192 -0600
+++ w_drawprim.c 2014-06-11 17:23:34.736481307 -0600
@@ -1292,7 +1292,7 @@
 }

-static unsigned char dash_list[16][2] = {{255, 255}, {255, 255},
+static unsigned char dash_list[16][8] = {{255, 255}, {255, 255},
      {255, 255}, {255, 255},
      {255, 255}, {255, 255},
      {255, 255}, {255, 255},

...which is simply to change the 2 in line 1295 to an 8; it seems to work. How did work before? The following loop accesses data in that array to a index ndash_3dot( which is 8), and it was never dimensioned like that. The initialization seems not so important after the first two data, if ever.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "my_xfig_patch.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Persio (persiobarros) wrote :

I'm having this problem too. Trusty 64bit here. Is there a precompiled patched pachage?

Revision history for this message
Romano Giannetti (romano-giannetti) wrote :

@Persio it's quite simple to compile, anyway I have a binary on my blog: http://rlog.rgtti.com/2014/06/26/quick-fix-xfig-bug/

Revision history for this message
Persio (persiobarros) wrote :

Thanks, Romano.

Revision history for this message
David Kaufmann (astranox) wrote :

this bug is still in ubuntu, at least 14.04.
the proposed patch is incomplete, as it does increase the size of the bitmap, but not the prefilled values.
a while ago i also wrote a patch for fedora, which i've also attached. ( from: redhat bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=1048127 )

I't won't apply cleanly as it also includes a diff from a fedora .spec file, but except that it should fix the problem
feel free to use as you see fit.

Revision history for this message
Roland Rosenfeld (roland) wrote :

This should be fixed since 1:3.2.5.c-4.

Revision history for this message
Romano Giannetti (romano-giannetti) wrote :

Where is available 1:3.2.5.c-4? In 14.04 seems still 1:3.2.5.c-1ubuntu1.
Thanks!

Changed in xfig (Ubuntu):
status: Confirmed → Fix Committed
Revision history for this message
Roland Rosenfeld (roland) wrote :

Fixed in 1:3.2.5.c-4 (avaliable since xenial)

Changed in xfig (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.