#976102 a2ps 32-bit segfaults on startup

Package:
a2ps
Source:
a2ps
Description:
GNU a2ps - 'Anything to PostScript' converter and pretty-printer
Submitter:
Mack Stanley
Date:
2020-12-17 05:00:03 UTC
Severity:
important
#976102#5
Date:
2020-11-29 18:52:44 UTC
From:
To:
Dear Maintainer,

    * What led up to the situation?

Installation of a2ps on a new installation of 32-bit buster.

    * What exactly did you do (or not do) that was effective (or
      ineffective)?

Try running a2ps with various inputs  and configuration files

    * What was the outcome of this action?

a2ps immediately segfaults with no core dump, even when run with no
arguments.  The only exception that I found is
that "a2ps --version" returns the expected information:

#976102#10
Date:
2020-12-14 22:14:57 UTC
From:
To:
Hello Mack Stanley,
I am not involved in packaging a2ps, but I guess there are some more
information needed to even start investigating.

I tried several files in a VM to send to a2ps and I could
not observe a crash.

Therefore could you supply to this bug which command line is used
to trigger the crash?

If possible a link to or if small enough attaching the input you
give to a2ps?

A crash should at least have a trace in dmesg output,
could you add this?

And possibly you could install the package "systemd-cordump".
That way some more information should be written
to the journal - e.g. visible in 'journalctl -e'.

Kind regards,
Bernhard

#976102#15
Date:
2020-12-15 22:00:15 UTC
From:
To:
Thanks so much for your interest and your message.  I very recently
realized that my bug report is in error and hoped that I would be able
to correct or withdraw it before troubling anyone.

Here is how to reproduce the segfault I observed (in wither 32 or 64 bit
debian a2ps):

Near the top of /etc/a2ps-site.cfg comment out one or both of the lines
_____

Options: --encoding=latin1
Options: --medium=libpaper
_____

Then just execute

a2ps

The result will be a crash with simply

Segmentation Fault
-------

I am very sorry to have filed a false bug report.  I had tried two 32
bit installations and one 64 bit.  Evidently I made the same mistake in
both 32 bit installations: I must have installed with an old Fedora
a2ps-site.cfg already in /etc/ , which the Debian installation politely
refused to overwrite.  The default Fedora a2ps-site.cfg  has those two
lines as

#Options: --encoding=latin1
Options: --medium=_glibc

After removing "#" from the first line, the debian build a2ps complains
helpfully about the second line.  But with the "#" it just segfaults.

I am sorry it took me so long to find this mistake.  It wasn't till I
built 32 bit a2ps from the GNU source that I saw the problem
(http://ftp.gnu.org/gnu/a2ps/a2ps-4.14.tar.gz./configure --prefix=/usr
--with-gnu-gettext --with-medium=letter ).

It would be nice if a2ps itself had been more forthcoming about my
mistake rather than segfaulting.  But it was just that---my mistake.

Again, my apologies for wasting your time and my thanks for your interest.

Best regards, Mack

#976102#20
Date:
2020-12-16 14:24:47 UTC
From:
To:
Am 15.12.20 um 23:00 schrieb Mack Stanley:



Hello Mack,
no problem, with these great details I could collect these backtraces:


     # With: #Options: --encoding=latin1

     (gdb) bt
     #0  __strlen_sse2_bsf () at ../sysdeps/i386/i686/multiarch/strlen-sse2-bsf.S:50
     #1  0x0050bfcc in strlower (string=0x0) at routines.c:95
     #2  0x005096cd in get_encoding_by_alias (job=0x57bc50, alias=0x0) at encoding.c:1207
     #3  0x0050aa50 in a2ps_job_finalize (job=0x57bc50) at jobs.c:305
     #4  0x004ef980 in main (argc=<optimized out>, argv=<optimized out>) at main.c:1025
     (gdb)


     # With: #Options: --medium=libpaper

     (gdb) bt
     #0  __strcasecmp_l_sse4_2 () at ../sysdeps/i386/i686/multiarch/strcmp-sse4.S:229
     #1  0x0050e22a in a2ps_get_medium (job=0xb1ec50, name=0x0) at media.c:164
     #2  0x0050ea6c in a2ps_job_finalize (job=0xb1ec50) at jobs.c:312
     #3  0x004f3980 in main (argc=<optimized out>, argv=<optimized out>) at main.c:1025
     (gdb)


As you mentioned some relation to fedora I made a short
search and it looks like there are some patches used,
which are not yet upstreamed.

https://src.fedoraproject.org/rpms/a2ps/tree/
https://git.savannah.gnu.org/cgit/a2ps.git/log/

Especially the a2ps-4.13b-encoding.patch and
a2ps-4.13-glibcpaper.patch seem related.

Kind regards,
Bernhard



apt install systemd-coredump gdb a2ps a2ps-dbgsym
zcat /usr/share/doc/a2ps/README.gz | a2ps
coredumpctl list
coredumpctl gdb 2478

https://sources.debian.org/src/a2ps/1:4.14-5/lib/jobs.c/#L305

#976102#25
Date:
2020-12-17 04:56:02 UTC
From:
To:

Dear Bernhard,


That's great news!


I do know that the build from the GNU a2ps tarball behaves like the
Debian builds.  (I tried the Debian testing build too.) That's not
surprising since it was the GNU stable source that I used.


The only other thing I know is that  Fedora 33's current build doesn't
care whether "Options: --encoding=latin1" is commented out or not, but
it does segfault if "Options: --medium=_glibc" is commented out in
a2ps-site.cfg.  It doesn't segfault as long as it is passed "Options:
--medium=..." where ... can be anything.  It will object that it doesn't 
know what "..". is, that is, if it is not "_glibc" or "letter" or "A4"
or whatever, but it won't segfault.  Incidentally, it doesn't know what
"libpaper" is.  And I don't know what "_glibc" is!


Thanks again for the positive news.

Best wishes, Mack