From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by sourceware.org (Postfix) with ESMTPS id 5A02D382EAC0 for ; Fri, 20 Nov 2020 07:18:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5A02D382EAC0 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=hi-angel@yandex.ru Received: from mxback2o.mail.yandex.net (mxback2o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1c]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 18E471C84153; Fri, 20 Nov 2020 10:17:32 +0300 (MSK) Received: from iva7-f62245f79210.qloud-c.yandex.net (iva7-f62245f79210.qloud-c.yandex.net [2a02:6b8:c0c:2e83:0:640:f622:45f7]) by mxback2o.mail.yandex.net (mxback/Yandex) with ESMTP id sU5IjY5FEe-HVeeXgZt; Fri, 20 Nov 2020 10:17:32 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1605856652; bh=mluGPlcE38OuZQnec85qIyFsWI9zKB5tCeFuSFnEy7c=; h=In-Reply-To:To:From:Subject:References:Date:Message-ID; b=u/+4+gwCrVPWhH1JPZhW7Cil00mKdKCbPyba694hA+4+PvVCBg2VKMtHNMGU6Oa5E sV2NDxm0+AFA4WPlYzpgs2p2yTfrKrnh1EpUEDMtt3OPfHKHome9vRj1EVfXB8ca7E a+QzIwC2NGsNeavtlogt/l/m1XlVhSvfQtx5IXRo= Authentication-Results: mxback2o.mail.yandex.net; dkim=pass header.i=@yandex.ru Received: by iva7-f62245f79210.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id ixibVTy4iZ-HVIW4sg6; Fri, 20 Nov 2020 10:17:31 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Message-ID: Subject: Re: dlopen: Segfault due to overwriting .so file after it was loaded and loading it again From: Konstantin Kharlamov To: "Wendeborn, Jonathan" , "libc-help@sourceware.org" Date: Fri, 20 Nov 2020 10:17:30 +0300 In-Reply-To: <11e3703d900d48149d0f81ae7682480f@bruexc101.brumgt.local> References: <11e3703d900d48149d0f81ae7682480f@bruexc101.brumgt.local> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP 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: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 07:18:20 -0000 On Fri, 2020-11-20 at 06:52 +0000, Wendeborn, Jonathan via Libc-help wrote: > Hi, > > I am a C++ developer but usually programming and debugging on Windows (so > please excuse any wrong terms). Now I'm compiling my program on Linux (gcc > 9.3.0 on Debian Bullseye with Boost 1.70) for the first time and get a > Segfault in my unit tests. > Luckily I was able to write a reproducer and boil it down to my code > overwriting the .so file after having it loaded (and unloaded): I can't seem to reproduce it. I modified paths in your testcase as fololows: #include #include #include void doit() { boost::filesystem::copy_file("/tmp/libSomething.so", "/tmp/libSomething2.so", boost::filesystem::copy_option::overwrite_if_exists); boost::dll::shared_library l; std::cout << "pre load" << std::endl; l.load("/tmp/libSomething2.so"); std::cout << "loaded" << std::endl; } int main() { doit(); doit(); return 0; } And I build it with g++ test.cpp -o a -g3 -O0 -Wall -Wextra -Wsign-conversion -std=c++17 -fsanitize=address -ldl -lboost_filesystem -lboost_system Running it I get no segfault, just output: λ ./a pre load loaded pre load loaded Please try placing the lib into `/tmp/libSomething` and running the app, do you still see crash?