Bug 271837 - x11/x3270 net/c3270 segfault when using -port 3270 switch
Summary: x11/x3270 net/c3270 segfault when using -port 3270 switch
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Kevin Bowling
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-05 12:13 UTC by Vladimir Mišev
Modified: 2023-06-09 23:46 UTC (History)
0 users

See Also:
kbowling: maintainer-feedback+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Mišev 2023-06-05 12:13:53 UTC
pkg c3270 segfaults when using '-port 3270' switch, or any other port.

c3270 starts OK without switches, but segfault on interactive command:
Connect localhost:3270

Source from http://x3270.bgp.nu/download/04.02/suite3270-4.2ga10-src.tgz builds (out of ports tree) and works OK, and doesn't crash with segfault.
Comment 1 Kevin Bowling freebsd_committer freebsd_triage 2023-06-05 14:07:18 UTC
can you run it from gdb and provide some more details on the segfault
Comment 2 Vladimir Mišev 2023-06-05 14:45:23 UTC
gdb -ex=r --args c3270 -port 3270 localhost
...
Reading symbols from c3270...
(No debugging symbols found in c3270)
Starting program: /usr/local/bin/c3270 -port 3270 localhost
warning: Could not load shared library symbols for [vdso].
Do you need "set solib-search-path" or "set sysroot"?

Program received signal SIGSEGV, Segmentation fault.
Address not mapped to object.
__je_free_default (ptr=<optimized out>) at jemalloc_jemalloc.c:2775
2775                            ifree(tsd, ptr, tcache, false);
(gdb)
Comment 3 Vladimir Mišev 2023-06-05 15:10:02 UTC
gdb c3270 c3270.core
...

Core was generated by `c3270 -port 3270 localhost'.
Program terminated with signal SIGSEGV, Segmentation fault.
Address not mapped to object.
#0  atomic_load_p (a=0x1108, mo=atomic_memory_order_relaxed) at /usr/src/contrib/jemalloc/include/jemalloc/internal/atomic.h:62
62      JEMALLOC_GENERATE_ATOMICS(void *, p, LG_SIZEOF_PTR)
(gdb) bt
#0  atomic_load_p (a=0x1108, mo=atomic_memory_order_relaxed) at /usr/src/contrib/jemalloc/include/jemalloc/internal/atomic.h:62
#1  rtree_leaf_elm_bits_read (elm=0x1108, dependent=true, tsdn=<optimized out>, rtree=<optimized out>)
    at /usr/src/contrib/jemalloc/include/jemalloc/internal/rtree.h:175
#2  rtree_szind_slab_read (rtree_ctx=<optimized out>, dependent=true, tsdn=<optimized out>, rtree=<optimized out>, key=<optimized out>, 
    r_szind=<optimized out>, r_slab=<optimized out>) at /usr/src/contrib/jemalloc/include/jemalloc/internal/rtree.h:500
#3  ifree (tcache=0x820fa1280, slow_path=false, tsd=<optimized out>, ptr=<optimized out>) at jemalloc_jemalloc.c:2574
#4  __je_free_default (ptr=<optimized out>) at jemalloc_jemalloc.c:2775
#5  0x00000000002b2ce2 in ?? ()
#6  0x00000000002b254e in ?? ()
#7  0x0000000000295bae in ?? ()
#8  0x00000000002957f0 in ?? ()
#9  0x00000000002956f0 in ?? ()
#10 0x0000000000000000 in ?? ()
(gdb)
Comment 4 Vladimir Mišev 2023-06-05 15:38:24 UTC
(In reply to Kevin Bowling from comment #1)
Also, net/c3270 port build fails for me:

root@:/usr/ports # git pull
Already up to date.

root@:/usr/ports # cd net/c3270

root@:/usr/ports/net/c3270 # make -s distclean clean stage
[...]
./../../Common/pr3287/pr3287.c:1167:59: error: use of undeclared identifier 'PX_SUCCESS'; did you mean 'SI_SUCCESS'?
            if (proxy_negotiate(s, proxy_user, host, p, true) != PX_SUCCESS) {
                                                                 ^~~~~~~~~~
                                                                 SI_SUCCESS
[...]
gmake[3]: *** [Makefile:39: all] Error 2
gmake[2]: *** [Makefile:158: pr3287] Error 2
[...]

This happens on fully updated  
FreeBSD 13.2-STABLE stable/13-89bd147db GENERIC amd64 1302505
FreeBSD clang version 15.0.7

and 

FreeBSD 13.2-RELEASE releng/13.2-n254617-525ecfdad597 GENERIC amd64 1302001
FreeBSD clang version 14.0.5
Comment 5 Kevin Bowling freebsd_committer freebsd_triage 2023-06-05 16:57:24 UTC
(In reply to Vladimir Mišev from comment #3)
(In reply to Vladimir Mišev from comment #4)

not sure what could even be going on there, PX_SUCCESS is defined in x3270 codebase itself and the port is built on FreeBSD 12+ on multiple archs by the project.  You might have something wrong with your installation.
Comment 6 Vladimir Mišev 2023-06-05 17:42:57 UTC
(In reply to Kevin Bowling from comment #5)
I have two 13.2-RELEASE and one 13.2-STABLE installs; 
all fully updated, everything else that I tried builds fine. 

On all three building net/c3270 fails with same error. 

When I just 

"root@H:/usr/ports/net/c3270 # make extract; cd /work/suite3270-4.2/; 
CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ./configure; gmake"

everything builds OK, but ./c3270 from 
/usr/ports/net/c3270/work/suite3270-4.2/obj/x86_64-unknown-freebsd13.2/c3270
is segfaulting when -port switch is used.

extracted into my ~/work dir, 
http://x3270.bgp.nu/download/04.02/suite3270-4.2ga10-src.tgz 
builds with no problems with:

CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ./configure; gmake

and ./c3270 from 
suite3270-4.2/obj/x86_64-unknown-freebsd13.2/c3270/ 
works ok with '-port' switch - it's not segfaulting
Comment 7 Kevin Bowling freebsd_committer freebsd_triage 2023-06-05 18:48:16 UTC
Fixed in 4.2ga5 https://x3270.miraheze.org/wiki/Release_Notes/suite3270/4.2ga10
Comment 8 commit-hook freebsd_committer freebsd_triage 2023-06-05 18:53:03 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=dc246a44cc105759a733f6d7914fbf2d7009f5c6

commit dc246a44cc105759a733f6d7914fbf2d7009f5c6
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2023-06-05 18:50:16 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2023-06-05 18:51:55 +0000

    x11/x3270, net/c3270: Update to 4.2ga10

    Changes https://x3270.miraheze.org/wiki/Release_Notes/suite3270/4.2ga10

    PR:             271837

 x11/x3270/Makefile | 3 ++-
 x11/x3270/distinfo | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)
Comment 9 Vladimir Mišev 2023-06-05 19:51:07 UTC
Thanks!
Comment 10 Vladimir Mišev 2023-06-09 11:09:08 UTC
(In reply to Kevin Bowling from comment #5)
Just FYI, x3270 fails w "use of undeclared identifier 'PX_SUCCESS'" only when built on existing system where net/libproxy is already installed. 

In that case 'Common/pr3287/pr3287.c' is using  '/usr/local/include/proxy.h' and not '${WRKSRC}/include/proxy.h'
Comment 11 Kevin Bowling freebsd_committer freebsd_triage 2023-06-09 23:46:49 UTC
Hi sorry this is not relevant to the port.  Consider using a clean builder environment like poudriere or fix the upstream build procedure to prefer the local include.