From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by sourceware.org (Postfix) with ESMTPS id BC3173858D32 for ; Mon, 27 Feb 2023 16:57:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BC3173858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=starynkevitch.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=starynkevitch.net Received: (Authenticated sender: basile@starynkevitch.net) by mail.gandi.net (Postfix) with ESMTPSA id 8708CFF802; Mon, 27 Feb 2023 16:57:33 +0000 (UTC) Content-Type: multipart/alternative; boundary="------------zlVvINoxXF6Loe3jKaAtcib2" Message-ID: Date: Mon, 27 Feb 2023 17:57:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: dlmopen and isolation of loaded libraries Content-Language: en-US To: =?UTF-8?B?0JDQu9C10LrRgdCw0L3QtNGAINCS0LDRidC40LvQutC+?= References: Cc: libc-help@sourceware.org From: Basile Starynkevitch In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,BODY_8BITS,HTML_MESSAGE,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This is a multi-part message in MIME format. --------------zlVvINoxXF6Loe3jKaAtcib2 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 27/02/2023 12:48, Александр Ващилко via Libc-help wrote: > Hi, I am developing a project that has the functionality of loading > libraries of some third-party products which shipped with their own > versions of libstdc++ or glibc. > But my project needs to use its own versions of the same libraries. > I found the dlmopen function, but as I understand, it has limited isolation > functionality. Yes. I assume your project runs a single process under Linux. Its virtual address space is not "isolating" shared libraries. For debugging, try adding a routine reading /proc/self/maps (a textual file). Maybe also use pmap(1) command. Better isolation requires a multi-process approach. See also /proc and https://man7.org/linux/man-pages/man5/proc.5.html > > Also, as I understand from this article > https://sourceware.org/glibc/wiki/LinkerNamespaces, every new namespace > created by dlmopen have own copy of glibc of version from which dlmopen > was called. > > I there any way to load third-party libraries with their own versions of > libstdc++, their own versions of glibc, or all their own libraries of their > own versions at the same time? > > Anyway, even if dlmopen doesn't support the required functionality, do > glibc and libstdc++ support the simultaneous existence of different > versions of these libraries at the same time in the same process? This probably won't work well, or is a very brittle approach (conflict for similar global data mmap-ed twice?) For details, read Levine's book: /Linkers & Loaders/, and download and study the source code of GNU libc and of musl-libc (and its documentation). BTW, my pet open source project is the /RefPerSys/ open source artificial intelligence engine on http://refpersys.org/ (some source code on https://github.com/RefPerSys/RefPerSys ...) Regards -- Basile Starynkevitch (only mine opinions / les opinions sont miennes uniquement) 92340 Bourg-la-Reine, France web page: starynkevitch.net/Basile/ --------------zlVvINoxXF6Loe3jKaAtcib2--