delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/01/17/07:57:11

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:subject:references:from:date:in-reply-to
:message-id:mime-version:content-type; q=dns; s=default; b=eEGWS
ghSJ6MIHb6CvaIY2lBgVVhikSBuiD0jqkl1FpY+h1TLWRBhEraejPt0MF7Z+aSw/
S6sVmmkQznsoaIAISnTPDY5fIpab+gUR3eWGtffNCtP1hcSHL9yrxkVvavIVXzvx
vL4ptDtvzOT03SgAL76VJjKS7PAdxTObwU+IO4=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:subject:references:from:date:in-reply-to
:message-id:mime-version:content-type; s=default; bh=gNEb6PxBgMv
N8yXmVp0pr5a9YiU=; b=PntvwdcOxMicWXw8TTY1dS44HdVR7nDZU7SpofcdWNZ
273BKJuqzrEf6H0TyAtGIa7NC7n9X8SGF9wYFRfg++Eu/rU+D2l1bIChgzl7h30S
65ZlRRuKFlVw4M30AJTRjkxjDg+Ava8jbwOTtxi3+DwCxmlVR11QA4AHkgvZ5t6M
=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,SPF_PASS autolearn=ham version=3.3.1 spammy=****, all, all!, School
X-HELO: loire.is.ed.ac.uk
To: cygwin AT cygwin DOT com
Subject: Re: lftp 4.9.0-1 segmentation fault (core dumped)
References: <DB8PR08MB4025E0AB6085301C45FF5EFCC13E0 AT DB8PR08MB4025 DOT eurprd08 DOT prod DOT outlook DOT com> <f5br2039o7e DOT fsf AT ecclerig DOT inf DOT ed DOT ac DOT uk>
From: "Henry S. Thompson" <ht AT inf DOT ed DOT ac DOT uk>
Date: Fri, 17 Jan 2020 12:56:01 +0000
In-Reply-To: <f5br2039o7e.fsf@ecclerig.inf.ed.ac.uk> (Henry S. Thompson's message of "Mon\, 13 Jan 2020 19\:00\:05 +0000")
Message-ID: <f5by2u62qe6.fsf@ecclerig.inf.ed.ac.uk>
User-Agent: Gnus/5.1012 (Gnus v5.10.12) XEmacs/21.5-b34 (linux)
MIME-Version: 1.0
X-Edinburgh-Scanned: at loire.is.ed.ac.uk with MIMEDefang 2.84, Sophie, Sophos Anti-Virus, Clam AntiVirus
X-IsSubscribed: yes

--=-=-=
Content-Type: text/plain

Henry S. Thompson writes:

> thierry blind writes:
>
>> I updated lftp 4.8.4-1 to lftp 4.9.0-1 but now calling following
>> command will always core dump (I anonymized some confidential data):
>
> Likewise, with just lftp, no arguments at all!

OK, installed src, built it using cygport, and found the problem.

It only happens under the call to Set in the following, i.e. if the IPV6
test fails (see src/network.cc:482)

#if INET6
   // check if ipv6 is really supported
   if(!Networker::FindGlobalIPv6Address() || !CanCreateIpv6Socket())
      ResMgr::Set("dns:order",0,"inet");
#endif

This code is called during dll/module initialisation, at which point the
call to 'ResMgr::Set' segfaults because another static var
initialisation (resource.cc:426) hasn't happened.

It's seems likely that the upstream people, and the package maintainer,
were running on systems with IPV6 enabled, so they didn't hit the
problem.

So, the fix is for the upstream people to fix the ordering problem.

One way, perhaps not the best, to do this is in the attached patch.

Not sure if this is a cygwin problem or an upstream problem...

[The attached file contains a definite upstream fix as well, only
 triggered if you try to build with --disable-ipv6]

ht


-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=lftp-ipv6-fail-fix.patch
Content-Description: fix segfault in lftp

*** lftp-4.9.0/src/network.cc~	2019-08-26 21:42:01.000000000 +0100
--- lftp-4.9.0/src/network.cc	2020-01-17 10:52:00.846861300 +0000
***************
*** 453,487 ****
  #endif
     return 0;
  }
- 
- static bool CanCreateIpv6Socket()
- {
- #if INET6
-    bool can=true;
-    int s=socket(AF_INET6,SOCK_STREAM,IPPROTO_TCP);
-    if(s==-1 && (errno==EINVAL
- #ifdef EAFNOSUPPORT
-       || errno==EAFNOSUPPORT
- #endif
-    ))
-       can=false;
-    if(s!=-1)
-       close(s);
-    return can;
- #else
-    return false;
- #endif
- }
- 
- static struct NetworkInit : private Networker {
-    NetworkInit();
- } NETWORK_INIT;
- 
- NetworkInit::NetworkInit()
- {
- #if INET6
-    // check if ipv6 is really supported
-    if(!Networker::FindGlobalIPv6Address() || !CanCreateIpv6Socket())
-       ResMgr::Set("dns:order",0,"inet");
- #endif // INET6
- }
--- 453,455 ----
*** lftp-4.9.0/src/resource.cc~	2019-08-26 21:28:00.000000000 +0100
--- lftp-4.9.0/src/resource.cc	2020-01-17 12:40:36.857655200 +0000
***************
*** 35,40 ****
--- 35,46 ----
  #include "configmake.h"
  #include "misc.h"
  #include "localcharset.h"
+ #include "network.h"
+ 
+ // The following hack moved from network.cc by HST to avoid an static order fail
+ struct NetworkInit : private Networker {
+  NetworkInit();
+ };
  
  static const char *FtpProxyValidate(xstring_c *p)
  {
***************
*** 498,501 ****
--- 504,540 ----
     SetDefault("log:enabled",ctx,"yes");
     SetDefault("log:show-time",ctx,"yes");
     SetDefault("log:file",ctx,dir_file(get_lftp_data_dir(),"transfer_log"));
+ 
+    struct NetworkInit NETWORK_INIT;  // This hack moved from network.cc by HST
+  
+ }
+ 
+ // Moved from network.cc by HST
+ static bool CanCreateIpv6Socket()
+ {
+ #if INET6
+    bool can=true;
+    int s=socket(AF_INET6,SOCK_STREAM,IPPROTO_TCP);
+    if(s==-1 && (errno==EINVAL
+ #ifdef EAFNOSUPPORT
+       || errno==EAFNOSUPPORT
+ #endif
+    ))
+       can=false;
+    if(s!=-1)
+       close(s);
+    return can;
+ #else
+    return false;
+ #endif
  }
+ 
+ // This hack moved from network.cc by HST
+ NetworkInit::NetworkInit() {
+ #if INET6
+   // check if ipv6 is really supported
+   if(!Networker::FindGlobalIPv6Address() || !CanCreateIpv6Socket())
+     ResMgr::Set("dns:order",0,"inet");
+ #endif // INET6
+ }
+ 
*** lftp-4.9.0/src/ftpclass.cc~	2019-08-23 22:08:17.000000000 +0100
--- lftp-4.9.0/src/ftpclass.cc	2020-01-16 16:32:35.108886200 +0000
***************
*** 848,853 ****
--- 848,854 ----
        conn->data_sa.in.sin_port=htons(port);
        conn->data_sa.sa.sa_family=AF_INET;
     }
+ #if INET6
     // V6 / AF_INET6
     else if (proto == 2)
     {
***************
*** 855,860 ****
--- 856,862 ----
        conn->data_sa.in6.sin6_port=htons(port);
        conn->data_sa.sa.sa_family=AF_INET6;
     }
+ #endif
     else
     {
        Disconnect("unsupported address family");

--=-=-=
Content-Type: text/plain

-- 
       Henry S. Thompson, School of Informatics, University of Edinburgh
      10 Crichton Street, Edinburgh EH8 9AB, SCOTLAND -- (44) 131 650-4440
                Fax: (44) 131 650-4587, e-mail: ht AT inf DOT ed DOT ac DOT uk
                       URL: http://www.ltg.ed.ac.uk/~ht/
 [mail from me _always_ has a .sig like this -- mail without it is forged spam]


--=-=-=
Content-Type: text/plain; charset=us-ascii


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
--=-=-=--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019