From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by sourceware.org (Postfix) with ESMTPS id BD83E3857C4A for ; Thu, 16 Jul 2020 16:46:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BD83E3857C4A Received: by mail-io1-xd2d.google.com with SMTP id l17so6696467iok.7 for ; Thu, 16 Jul 2020 09:46:22 -0700 (PDT) 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 From: "E. Madison Bray" Date: Thu, 16 Jul 2020 18:46:11 +0200 Message-ID: Subject: Cygwin's sqlite3 modifies DLL search order To: cygwin@cygwin.com Content-Type: text/plain; charset="UTF-8" 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@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jul 2020 16:46:24 -0000 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