Uninitialized variable causes a crash on aarch64.

Pierre Langlois <[email protected]>
Newsgroups gmane.comp.gnu.mailutils.bugs
Message-ID <[email protected]>
Hi there!

Since version 3.10, mailutils isn't available on Guix for aarch64 since
the test-suite doesn't pass because of a segfault in readmsg tests. You
can find the full log here [0] and the bugreport on [1].

Reproducing the crash under GDB, it seems the `weedc' variable isn't
initialized and on this platform is set to `0xffff'. Later on, it causes
a crash.

Here's a reproducer, ran in GDB:

```
$ export MAIL=/tmp/guix-build-mailutils-3.10.drv-0/mailutils-3.10/testsuite/spool/mbox1                                                        
$ export FOLDER=/tmp/guix-build-mailutils-3.10.drv-0/mailutils-3.10/testsuite/spool/mbox1
$ ... edit readmsg script so that `gdb --args' is prepended
$ /tmp/guix-build-mailutils-3.10.drv-0/mailutils-3.10/readmsg/readmsg --no-site --no-user readmsg -h SOMETHING
...
(gdb) start
Temporary breakpoint 2 at 0x4034c8: file readmsg.c, line 463.
Starting program: /tmp/guix-build-mailutils-3.10.drv-0/mailutils-3.10/readmsg/.libs/readmsg --no-site --no-user readmsg -h SOMETHING
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/gnu/store/cb88z63hyg1icd2kkahiink2p291mhr2-glibc-2.31/lib/libthread_db.so.1".

Temporary breakpoint 2, main (argc=6, argv=0xffffffffeb58) at readmsg.c:463
463       int *set = NULL;
(gdb) p weedc
$4 = 65535
(gdb) watch weedc
Hardware watchpoint 3: weedc
(gdb) c
Continuing.
From [email protected]  Fri Dec 28 23:28:09 2001

Program received signal SIGSEGV, Segmentation fault.
0x00000000004030a0 in print_header (message=0x470f90, unix_header=1, weedc=65535, weedv=0x4042c8 <__libc_csu_init>) at readmsg.c:353
353                   if (weedv[j][0] == '!')
(gdb) p j
$5 = 0
(gdb) p weedv[j][0]
Cannot access memory at address 0x910003fda9bc7bfd
(gdb) up
#1  0x0000000000403a2c in main (argc=2, argv=0xffffffffeb78) at readmsg.c:580
580             print_header (msg, unix_header, weedc, weedv);
(gdb) p weedc
$6 = 65535
(gdb) 
```

If we set `weedc' to zero, then the readmsg tests all pass and we're
good to go to update mailutils in Guix!

Thanks,
Pierre

[0]: https://ci.guix.gnu.org/log/i8wpby2wmbn85qn0yv4v0q7ik4cki149-guile2.2-mailutils-3.10
[1]: https://issues.guix.gnu.org/43088
signature.asc (application/pgp-signature, 519 B)
-----BEGIN PGP SIGNATURE-----

iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAl9cvEwYHHBpZXJyZS5s
YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31U6bwIALMeuTbn2Rkun5nSkoCX/gqv
i59gNGVytFCWU2fkLWLxcFQq533BtqXX66UA9boFiIODtO3kJNjDlzVbl+E+yhbG
ytKj25WmKZy8UkTvai2aDCrqOMKETSwQYD6Z7+P+l0vJ4b+Ffvkx2pDe1eBoOwZZ
kG2sGVtv+CynfGpe2s1xwy9208gkoRU48ywT3j8PUCwEpa9LQmv2Lx8bMZ+TcCrR
HQsXodX2M09Jx3RAakiQPjN52FNvtFQuQ+yhNMhAAOFs+sP4BusIKegAdY+s3LHi
gHU0a/PtucqjJkvYafxIcYd5AyRrxfEX5ydMKq6Rzc+lBOHwHf3usHT3FslMgDw=
=m4eb
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.