Bug 241690 - sysutils/screen -4.7.0_4: stack overflow detected on arm
Summary: sysutils/screen -4.7.0_4: stack overflow detected on arm
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm Any
: --- Affects Some People
Assignee: Cy Schubert
Depends on:
Reported: 2019-11-03 16:06 UTC by Ulrich Grey
Modified: 2019-11-06 06:16 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (cy)


Note You need to log in before you can comment on or make changes to this bug.
Description Ulrich Grey 2019-11-03 16:06:56 UTC
I have built sysutils/screen (screen-4.7.0_4) on a wandboard-quad running: 
FreeBSD 13.0-CURRENT r352778 GENERIC  arm
The version of the ports tree is:
Last Changed Rev: 516289
Last Changed Date: 2019-11-02 07:24:29 +0000 (Sat, 02 Nov 2019)
The build (using ports-mgmt/poudriere-3.3.2_1) finished successfully.

If I start sysutils/screen: 

root@wqtest:~ # gdb /usr/local/bin/screen
GNU gdb (GDB) 8.3.1 [GDB v8.3.1 for FreeBSD]
Reading symbols from /usr/local/bin/screen...
(gdb) run
Starting program: /usr/local/bin/screen 
[Detaching after fork from child process 13723]

I get error messages in /var/log/messages:

Nov  3 15:22:04 wqtest SCREEN[13723]: stack overflow detected; terminated
Nov  3 15:22:05 wqtest kernel: pid 13723 (screen), jid 0, uid 0: exited on signal 6 (core dumped)

The screen core file:
Comment 1 Cy Schubert freebsd_committer 2019-11-03 19:48:03 UTC
Is ASLR enabled?

ulimit -a, please.

The core won't do me any good, no arm here, no debug info.

A backtrace won't do us good as screen traps all exceptions and issues an abort() to abend gracefully.
Comment 2 Ulrich Grey 2019-11-03 21:14:34 UTC
ulimit -a for my wandboard-quad running:

root@wqtest:~ # uname -a
FreeBSD wqtest.intranet 13.0-CURRENT FreeBSD 13.0-CURRENT r352778 GENERIC  arm

root@wqtest:~ # ulimit -a
cpu time               (seconds, -t)  unlimited
file size           (512-blocks, -f)  unlimited
data seg size           (kbytes, -d)  524288
stack size              (kbytes, -s)  8192
core file size      (512-blocks, -c)  unlimited
max memory size         (kbytes, -m)  unlimited
locked memory           (kbytes, -l)  unlimited
max user processes              (-u)  5547
open files                      (-n)  58095
virtual mem size        (kbytes, -v)  unlimited
swap limit              (kbytes, -w)  unlimited
socket buffer size       (bytes, -b)  unlimited
pseudo-terminals                (-p)  unlimited
kqueues                         (-k)  unlimited
umtx shared locks               (-o)  unlimited
Comment 3 Cy Schubert freebsd_committer 2019-11-03 22:04:59 UTC
I didn't ask for uname -a. Is ASLR enabled?
Comment 4 Cy Schubert freebsd_committer 2019-11-03 22:12:16 UTC
sysctl -a | grep aslr
Comment 5 Ulrich Grey 2019-11-03 22:18:31 UTC
root@wqtest:~ # sysctl -a | grep aslr
kern.elf32.aslr.stack_gap: 3
kern.elf32.aslr.honor_sbrk: 1
kern.elf32.aslr.pie_enable: 0
kern.elf32.aslr.enable: 0
vm.aslr_restarts: 0
Comment 6 Mikael Urankar freebsd_committer 2019-11-04 09:03:10 UTC
I don't know what the issue is but here is a possible workaround for arm:

Index: Makefile
--- Makefile    (revision 516618)
+++ Makefile    (working copy)
@@ -49,6 +49,10 @@
 .include <bsd.port.options.mk>
+.if ${ARCH} == armv6 || ${ARCH} == armv7
+SSP_CFLAGS?=   -fno-stack-protector
Comment 7 Cy Schubert freebsd_committer 2019-11-04 13:09:59 UTC
I don't have any arm here. Can you test the patch please?
Comment 8 Ulrich Grey 2019-11-04 15:33:06 UTC
The patch does not work.
I get a "stack overflow detected" warning like before.
Comment 9 Mikael Urankar freebsd_committer 2019-11-04 16:53:04 UTC
(In reply to Ulrich Grey from comment #8)
Can you post the build log somewhere (it works for me on 2 different boards)?
Comment 10 Ulrich Grey 2019-11-04 19:02:20 UTC
I noticed that I made a stupid mistake.
I installed the new built package from an older repository.
Mikaëls patch works, sysutils/screen is running now on my wandboard.
I apologize.
Comment 11 Cy Schubert freebsd_committer 2019-11-04 20:30:13 UTC
Thanks all for the patch and for testing this.
Comment 12 commit-hook freebsd_committer 2019-11-04 20:43:32 UTC
A commit references this bug:

Author: cy
Date: Mon Nov  4 20:43:08 UTC 2019
New revision: 516740
URL: https://svnweb.freebsd.org/changeset/ports/516740

  Fix a stack assertion under arm.

  PR:		241690
  Submitted by:	mikael.urankar at gmail.com
  Reported by:	Ulrich Grey <usenet at ulrich-grey.de>

Comment 13 Marcin Cieślak 2019-11-06 02:33:52 UTC
Is this a proper fix or maybe is there a bug in screen somewhere anyway?

Would that be possible to compile screen without this patch

make WITH_DEBUG=yes clean deinstall reinstall

and see where it crashes with gdb ("bt all" after crash)
Comment 14 Marcin Cieślak 2019-11-06 02:35:16 UTC
(In reply to Marcin Cieślak from comment #13)

er, just 'bt'
Comment 15 Cy Schubert freebsd_committer 2019-11-06 06:16:35 UTC
This is the correct fix.