Bug 220294 - net/echoping: SIG11 with -m dns only on amd64
Summary: net/echoping: SIG11 with -m dns only on amd64
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Alexey Dokuchaev
URL:
Keywords: needs-patch
Depends on:
Blocks:
 
Reported: 2017-06-26 20:01 UTC by Phillip R. Jaenke
Modified: 2021-07-13 09:57 UTC (History)
3 users (show)

See Also:


Attachments
truss output of echoping sig11 on 11.0-RELEASE amd64 (12.76 KB, text/plain)
2017-06-26 20:01 UTC, Phillip R. Jaenke
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Phillip R. Jaenke 2017-06-26 20:01:00 UTC
Created attachment 183821 [details]
truss output of echoping sig11 on 11.0-RELEASE amd64

Problem appears to possibly be program bug in echoping but may be clang. SIG11 occurs after munmap() call and only occurs on amd64. No problems were observed on i386 or aarch64. No other symptoms have been observed yet but http and https work without problems.
Comment 1 Tilman Keskinoz freebsd_committer 2019-09-25 20:32:54 UTC
I can't reproduce

% echoping -m dns ns1.isc-sns.net www.freebsd.org
Elapsed time: 0.035630 seconds
% uname -a                                       
FreeBSD nihayet.local.arved.priv.at 12.0-RELEASE-p10 FreeBSD 12.0-RELEASE-p10 GENERIC  amd64


The command output from your truss output doesn't even work: 

/usr/local/bin/echoping -t 5 -m /usr/local/lib/echoping/dns.so -n 20 10.53.0.1 -t A nsd0.rootlair.pvt
Error: Unknown type
Usage: [-?] [-t|--type=type] [--tcp] [--no-recurse] [-?|--help] [--usage]
  request
Comment 2 Li-Wen Hsu freebsd_committer 2020-06-17 07:49:30 UTC
Phillip, is this still happening on newer FreeBSD versions?
Comment 3 Alexey Dokuchaev freebsd_committer 2021-07-13 09:03:50 UTC
(In reply to Li-Wen Hsu from comment #2)
> Phillip, is this still happening on newer FreeBSD versions?
It certainly does, albeit this has nothing to with FreeBSD or Clang.  It crashes at dns.c:111 when trying to access upper_type_name = (char *) to_upper(type_name); which ends up being bogus because of the missing prototype for to_upper() so compiler assumes it returns an int which does not match the pointer size on amd64, leading to the crash (but not on i386).  Not sure why it does not happen on aarch64.

Let me see what I can do.
Comment 4 commit-hook freebsd_committer 2021-07-13 09:49:10 UTC
A commit in branch main references this bug:

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

commit 7f1fbb2020e286621e3107c2bf369f9973e99112
Author:     Alexey Dokuchaev <danfe@FreeBSD.org>
AuthorDate: 2021-07-13 09:47:48 +0000
Commit:     Alexey Dokuchaev <danfe@FreeBSD.org>
CommitDate: 2021-07-13 09:48:01 +0000

    net/echoping: fix the segmentation fault at dns.c:111

    Add missing prototype for to_upper() which returns char *.  Without it,
    compiler assumed that it returns an int, which results in segmentation
    fault in init() at dns.c when trying process its result which had been
    cast to char *, albeit needlessly (this code does lots of bogus casts).

    PR:     220294

 net/echoping/Makefile               | 2 +-
 net/echoping/files/patch-echoping.h | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
Comment 5 Alexey Dokuchaev freebsd_committer 2021-07-13 09:57:39 UTC
The program should no longer crash now.  Please reopen if you observe any other segfaults.