Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Oct 2021 01:08:39 -0700
From:      Mark Millard via freebsd-current <freebsd-current@freebsd.org>
To:        "bapt@freebsd.org" <bapt@FreeBSD.org>, freebsd-current <freebsd-current@freebsd.org>
Subject:   main changed DIALOG_STATE, DIALOG_VARS, and DIALOG_COLORS but /usr/lib/libdialog.so.? naming was not adjusted? (crashes in releng/13 programs on main [so: 14] can result)
Message-ID:  <5270B5FE-6C3B-4172-A310-AE9A5A1B853A@yahoo.com>
References:  <5270B5FE-6C3B-4172-A310-AE9A5A1B853A.ref@yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
main [soi: 14] commit a96ef450 (2021-02-26 09:16:49 +0000)
changed DIALOG_STATE, DIALOG_VARS, and DIALOG_COLORS .
These are publicly exposed in (ones that I noticed):

/usr/include/dialog.h:extern DIALOG_STATE dialog_state;
/usr/include/dialog.h:extern DIALOG_VARS dialog_vars;
/usr/include/dialog.h:extern DIALOG_COLORS dlg_color_table[];

and ends up with the storage being form the .bss of
the likes of dialog4ports (the example I ran into).

But the .9 in /usr/lib/libdialog.so.9 's .text that references
the storage where not increased compared to releng/13.0 and
stable/13 that predate the changes, there by not matching
old programs built under releng/13.0 or stable/13 .

Turns out that this explains the crashes I get when I attempt
to use a releng/13 based dialog4ports under main [so: 14]. For
a particular example, see:

https://lists.freebsd.org/archives/freebsd-current/2021-October/000860.html

It shows /usr/main-src/contrib/dialog/dlg_keys.c in
/usr/lib/libdialog.so.9 updating a new field:

286		} else {
287		    dialog_state.had_resize = FALSE;
   0x00000008002d298e <+62>:	movb   $0x0,0x84(%rax)

such that the following happens:

Hardware watchpoint 1: -location __stderrp

Old value = (FILE *) 0x8004d4940
New value = (FILE *) 0x4d4940

where:

(gdb) print &__stderrp
$4 = (FILE **) 0x208568 <__stderrp>

which has that storage in the dialog4ports area:

0x0000000000208360 - 0x0000000000208c50 is .bss

with the older set of fields and size for:

extern DIALOG_STATE dialog_state;

That in turn later leads to a SIGSEGV from the point of
view of a releng/13 based dialog4ports build.

Should main [14] instead have:

/usr/lib/libdialog.so.10

in order to avoid some releng/13.0 and stable/13 programs
trashing their memory? I'm guessing there is no reasonble
way to "compat" this. But preventing programs from trashing
there own memory and running in a corrupted state seems
achievable if the /usr/lib/libdialog.so.? name changes.

This might be something for a freebsd-arch discussion for
relevant folks.

===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5270B5FE-6C3B-4172-A310-AE9A5A1B853A>