delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/07/16/12:47:11

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 15846388E803
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1594917986;
bh=1FXdEJyULqCwsELf9eoMSS//5OFYVVo3rs4MEC67BZs=;
h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=Z6togUmDiboloDYBp5IT6B2XUAEOhnLHtHJZqsb4eAFHwCfAFdFgk0W6/PQs1CoG1
tMZiUVkn78dwssJhyTPIvz465anG4f1K1NysnYLOXifg+beoLUJRcGPTaShN/lwMKA
4LD+GEapIZMXGtERHqmiAETYSftQGtuxagr+I0ZE=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BD83E3857C4A
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
bh=be52skE2J1rCqT5XNAeNb1xwvT9X3wNYDATFa5vWAFY=;
b=ElxVVaC7ZOIKikOf0SyujMMrU+9wgANfbcfgO6RzlzElgaogzzlrjfFmeI/DFWb31J
Y1rHX2tIylDkc00CKDGrrNmVNFvccYa2LFylFnDfbvCwni4tY1AIBkN50PSR5WIh/arD
EBLjrw/A38qWtv7uU90roNrxzL+Jru/UL1v5VPUWm3dJLiufKEzmW5M7s11KgDoJvd/K
bK9+/kHrLMLUsFOi9nta98Osp536Qt0c4zt0LPokHc09S+jj8wM9lLtljs3V7aiJi+gf
wyJUGf9zV6iFE7o1UzCynL7MKhXA4X1l1dYp/8MmGzIDvG8H5C8Ssx3WAzk22A/+t5QQ
Yq3A==
X-Gm-Message-State: AOAM531o9mRtmB+peipSael+uKc8Y3oJeZfUF1+fMyRJPrwawM7pcCk4
W7NJMGp8aqR4/QNn+lc3ntL8Zgd10MClptaXmOJLiP2rncUJ2A==
X-Google-Smtp-Source: ABdhPJyOj/BhJ/ry7pGEpkCAqOZlY8sDmfQmIX6ulg2tHQQyVmK23atk5MUrFqUZn+jTrRhcF/rkaJntDTY7lF8NkAI=
X-Received: by 2002:a02:1a06:: with SMTP id 6mr6300026jai.8.1594917981674;
Thu, 16 Jul 2020 09:46:21 -0700 (PDT)
MIME-Version: 1.0
Date: Thu, 16 Jul 2020 18:46:11 +0200
Message-ID: <CAOTD34bQzhw6Vv+8Aeh9hZ1oNO8L_H7h1Jne0mkTWCH5vLAH1A@mail.gmail.com>
Subject: Cygwin's sqlite3 modifies DLL search order
To: cygwin AT cygwin DOT com
X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,
SPF_HELO_NONE, SPF_PASS, TXREP,
URI_HEX autolearn=ham autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <http://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: "E. Madison Bray via Cygwin" <cygwin AT cygwin DOT com>
Reply-To: "E. Madison Bray" <erik DOT m DOT bray AT gmail DOT com>
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>

Hi all,

After some significant headache I discovered a problem introduced by
the Cygwin patches for sqlite3.  The effect of this patch is that it
modifies the DLL search order for all subsequent DLL loads (by
filename instead of absolute path) in the application.

It contains the following patch in code which is executed in the
library's initialization:

   sqlite3_vfs_register(&winVfs, 1);

+#if !defined(SQLITE_OMIT_LOAD_EXTENSION)
+  if( cygwin_conv_path ){
+    WCHAR buf[MAX_PATH];
+    cygwin_conv_path(CCP_POSIX_TO_WIN_W, "/usr/bin",
+        buf, MAX_PATH*sizeof(WCHAR));
+    osSetDllDirectoryW(buf);
+#ifdef _WIN32
+  }else if( cygwin_conv_to_full_win32_path ){
+    WCHAR buf[MAX_PATH];
+    char *buf1 = (char *)buf;
+    int i = MAX_PATH;
+    cygwin_conv_to_full_win32_path("/usr/bin", buf1);
+    while(--i>=0) buf[i] = buf1[i];
+    osSetDllDirectoryW(buf);
+#endif
+  }
+#endif
+

The call to SetDllDirectoryW modifies the default DLL search path by
always inserting /usr/bin, superseding the normal $PATH search.  Why
it does this I'm not sure.  It seems related to this patch, though
it's taken on a rather different form over the years:

http://sqlite.1065341.n5.nabble.com/Wrong-filename-handling-in-sqlite3-load-extension-for-Cygwin-td74049.html

It is related to how sqlite3 searches for extension libraries.  Though
I'd argue this patch is not even correct, since if the sqlite3 DLL is
installed somewhere other than /usr/bin (say /usr/local/bin) this
patch still won't be correct.

This is a problem since after using sqlite3 in an application,
subsequent DLL searches will always default to looking in /usr/bin
before any overrides I have on $PATH.  Is there any way we can get
this fixed?

Thanks,
Madison
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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