This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: lftp 4.9.0-1 segmentation fault (core dumped)


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.

*** 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");
-- 
       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@inf.ed.ac.uk
                       URL: http://www.ltg.ed.ac.uk/~ht/
 [mail from me _always_ has a .sig like this -- mail without it is forged spam]

--
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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]