Bug 244204 - ports-mgmt/dialog4ports - Segmentation fault after upgrade to 13.x-currrent
Summary: ports-mgmt/dialog4ports - Segmentation fault after upgrade to 13.x-currrent
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Some People
Assignee: freebsd-ports-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-17 22:30 UTC by Garance A Drosehn
Modified: 2020-03-09 22:50 UTC (History)
1 user (show)

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


Attachments
12.x executable and core file (56.27 KB, application/octet-stream)
2020-02-18 19:19 UTC, Garance A Drosehn
no flags Details
12.x executable (-gO2) and core file (70.70 KB, application/octet-stream)
2020-02-19 04:05 UTC, Garance A Drosehn
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Garance A Drosehn freebsd_committer 2020-02-17 22:30:08 UTC
I have one virtual machine running 12.x:

FreeBSD <my.host12.edu> 12.1-STABLE FreeBSD 12.1-STABLE r357988 VM-Gilead-12x  amd64

I removed all ports, and reinstalled them.  Most of them are compiled via portupgrade, with just a few brought in via 'pkg install'.

I shutdown the VM, duplicated to a new VM, and then upgraded that VM to be running 13.x:

FreeBSD <my.host13.edu> 13.0-CURRENT FreeBSD 13.0-CURRENT #0 r357988: Sun Feb 16 02:16:34 EST 2020     root@<my.host13.edu>:/usr/obj/usr/src/amd64.amd64/sys/VM-Gilead-13x  amd64

I use portsnap to update all of its data, and it recommends that I do a 'pkg bootstrap -f' before doing anything else.  So I do that.

Later on I use 'pkg version -vL =' and discover there are several ports which need to be upgraded.  I start upgrading them, and (to make a long story short) I notice that if an 'config' dialog box comes up, that I sometimes see it followed by:

`Segmentation fault (core dumped)
 ===> Options unchanged'

I think the core dump happens only if I did not change any options when that dialog box came up.  I determined it was the program 'dialog4ports' which was core-dumping with the segmentation fault.  I could 'cd' into the directory for some port, do a 'make config', hit the enter key (thus approving the current options without changing any), and it would core-dump.

To solve this, I did:

`cd /usr/ports/ports-mgmt/dialog4ports
 make config && make
 make deinstall && make install
 make clean'

After doing this, I see no more problems with segmentation faults when running dialog4ports.  And if I copy the dialog4ports program from my 12.x system to my 13.x system, those segmentation faults will reappear.

So far I have not noticed any problems with any other ports after moving from 12.x to 13.x, but then there are many port-executables which I have not run since that upgrade.  I considered removing all ports and rebuilding all of them on 13.x, but I haven't had the time to just yet.

Perhaps when the system notices that a major OS-level upgrade has occurred, the 'pkg bootstrap -f' step should update 'dialog4ports' in addition to 'pkg' itself?
Comment 1 m1cro 2020-02-17 23:04:27 UTC
Hi Garance,

Do you have core file?
Actually d4p was not changed between 12-13, and it can be related with changes in libdialog.
Maybe you can give me you dialog4ports from your 12bsd? (for future investigating)
Comment 2 Garance A Drosehn freebsd_committer 2020-02-18 19:19:16 UTC
Created attachment 211747 [details]
12.x executable and core file
Comment 3 Garance A Drosehn freebsd_committer 2020-02-18 19:24:25 UTC
I can generate core files at will by using the version of dialog4ports from my 12.x system on my 13.x system.  Here is a ssh-session on my 13.x system, with a few blank lines removed.  I didn't notice it before, but it is perhaps interesting that the run which sees the segmentation fault *does* print out '===> Options unchanged', while the one without a seg-fault does not print anything.

# ————————————————————————————————————————————————————
# ————————————————————————————————————————————————————
(1326) root # cp -p /usr/local/bin/dialog4ports{-12x,}
(1327) root # cd /usr/ports/security/libgpg-error
(1328) root # make config

  ┌────────────────────────── libgpg-error-1.37 ─────────────────────────────┐
  │ ┌──────────────────────────────────────────────────────────────────────┐ │
  │ │ [ ] DOCS  Build and/or install documentation                         │ │
  │ │ [x] NLS   Native Language Support                                    │ │
  │ │ [ ] TEST  Build and/or run tests                                     │ │
  │ └──────────────────────────────────────────────────────────────────────┘ │
  ├──────────────────────────────────────────────────────────────────────────┤
  │                       <  OK  >            <Cancel>                       │
  └──────────────────────────────────────────────────────────────────────────┘

Segmentation fault (core dumped)
===> Options unchanged
(1329) root # ls -l dialog4ports.core 
-rw-------  1 root  wheel  9744384 Feb 18 14:03 dialog4ports.core
(1330) root # cp -p /usr/local/bin/dialog4ports{-13x,}
(1331) root # make config

  ┌────────────────────────── libgpg-error-1.37 ─────────────────────────────┐
  │ ┌──────────────────────────────────────────────────────────────────────┐ │
  │ │ [ ] DOCS  Build and/or install documentation                         │ │
  │ │ [x] NLS   Native Language Support                                    │ │
  │ │ [ ] TEST  Build and/or run tests                                     │ │
  │ └──────────────────────────────────────────────────────────────────────┘ │
  ├──────────────────────────────────────────────────────────────────────────┤
  │                       <  OK  >            <Cancel>                       │
  └──────────────────────────────────────────────────────────────────────────┘

(1332) root # date
Tue Feb 18 14:04:19 EST 2020
(1333) root # mv dialog4ports.core /usr/local/bin/dialog4ports{-12x,} /tmp
(1334) root # cd /tmp
(1335) root # tar cjf dialog4ports-dbg.tbz2 dialog4ports-12x dialog4ports.core
Comment 4 m1cro 2020-02-18 23:39:03 UTC
Mmm, I can reproduce segfault with your d4p-12 on my 13bsd.
Can you build d4p-12 with debug symbols?
Comment 5 Garance A Drosehn freebsd_committer 2020-02-19 03:56:36 UTC
I can.  It took awhile though.

I built it with:  CFLAGS="-g -fstandalone-debug" make
and also with:    CFLAGS="-g" make
and both of those versions did *not* generate a seg-fault.

I then wondered if maybe there was something odd about the dialog4ports which I had been using on my 12x system (built back on Dec 24th).  I built a new one without debuginfo, and it did generate the seg-fault.

I then noticed that when I specify "-g", some makefile-magic somewhere changes what *other* options are given to clang.  In particular, adding "-g" causes "-O2 -pipe" to be removed, and that results in significantly different code.

So I built it with:  CFLAGS="-g -O2 -pipe" make
and that version does generate the seg-fault, and also does have the debugging info.
Comment 6 Garance A Drosehn freebsd_committer 2020-02-19 04:05:35 UTC
Created attachment 211754 [details]
12.x executable (-gO2) and core file

Created via:

cd /usr/ports/security/libgpg-error
make config
#       hit 'enter' without changing anything
mv dialog4ports.core /tmp
cp -p /usr/local/bin/dialog4ports /tmp/dialog4ports-12x-gO2
file /tmp/dialog4ports-12x-gO2

#   /tmp/dialog4ports-12x-gO2: ELF 64-bit LSB executable,
#   x86-64, version 1 (FreeBSD), dynamically linked,
#   interpreter /libexec/ld-elf.so.1, for FreeBSD 12.1 (1201512),
#   FreeBSD-style, with debug_info, not stripped

tar cjf dialog4ports-dbg-g.tbz2 dialog4ports-12x-gO2 dialog4ports.core
Comment 7 Garance A Drosehn freebsd_committer 2020-03-09 22:50:36 UTC
Note that I'm not sure that it's important to figure out the specific bug in this specific case.  I'm just saying it might be wise if the recommended step of:

pkg bootstrap -f

would also install a version of "dialog4ports" which matches the OS the user is running on.  Even if we can fix the specific issue that I ran into, I suspect there will be plenty of other opportunities for a similar problem to come up in the future.