| delorie.com/archives/browse.cgi | search |
| X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
| X-Recipient: | djgpp AT delorie DOT com |
| X-Original-DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; |
| d=gmail.com; s=20120113; | |
| h=mime-version:in-reply-to:references:date:message-id:subject:from:to | |
| :content-type; | |
| bh=0cdkn3lg6fsuW7++mbXJUO2oc5o/nXSxoCYbpSJArQc=; | |
| b=bWnSi2v3lqIJjIaiGJ3ZHINO8o5//lTlSeGBpAxEJ+NX2/yzSfo5/0UAy+rN9SZtt3 | |
| LP+MO3dYkq6adKIGELd3+AWKjmO+wpWpJkYacf7CZN69/4N/v4WL+4k+z8MPihbIcHf3 | |
| vD+vFjqBz5JzxWz0ZWdRs+7PyaRgeT8fn6BBFpP1Ud9ns+WarUj5AKj97Bl7BFUJKByw | |
| of6j048Q1m7lUDuvf7Q29HDLYAd7LiFgZu/V4bVFaoFnTsoSustnBYYkvcSFeD1pi9/J | |
| OTjEXTQ1BdUS8gQa4WVne0nSeHp4ss5UF4tN5UbyK76+OE7JjYVsrMDYWrmBvqbvBn7u | |
| W/lg== | |
| MIME-Version: | 1.0 |
| X-Received: | by 10.50.142.105 with SMTP id rv9mr1728756igb.32.1443684899922; |
| Thu, 01 Oct 2015 00:34:59 -0700 (PDT) | |
| In-Reply-To: | <CAA2C=vDSknbCKHzUA954weavLj16nXuDyP_Ggi+SmLJ_e-U_KA@mail.gmail.com> |
| References: | <CAA2C=vAwcH9pHN63=Mskr9L016yAAJ6KkMPeuO9o_2cV7Pd0Kw AT mail DOT gmail DOT com> |
| <CAA2C=vDDN8UqGpbAzkba19Syq-1mLsBPAuSzSPWue_S2TYf_XQ AT mail DOT gmail DOT com> | |
| <b8759e89-e375-4647-a9eb-64543cc49748 AT googlegroups DOT com> | |
| <CAA2C=vDSknbCKHzUA954weavLj16nXuDyP_Ggi+SmLJ_e-U_KA AT mail DOT gmail DOT com> | |
| Date: | Thu, 1 Oct 2015 10:34:59 +0300 |
| Message-ID: | <CAA2C=vAdzu+ebq1mEsoqwkxJcYR+2EZdKJ3d5XxOZRCytL6z8w@mail.gmail.com> |
| Subject: | Re: dlclose not removing dependency dxes |
| From: | "Ozkan Sezer (sezeroz AT gmail DOT com) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com> |
| To: | djgpp AT delorie DOT com |
| Reply-To: | djgpp AT delorie DOT com |
| Errors-To: | nobody AT delorie DOT com |
| X-Mailing-List: | djgpp AT delorie DOT com |
| X-Unsubscribes-To: | listserv AT delorie DOT com |
On 9/27/15, Ozkan Sezer <sezeroz AT gmail DOT com> wrote:
> On 9/26/15, Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de) [via
> djgpp AT delorie DOT com] <djgpp AT delorie DOT com> wrote:
>> On Friday, September 25, 2015 at 7:21:47 PM UTC+2, Ozkan Sezer
>> (sezeroz AT gmail DOT com) [via djgpp AT delorie DOT com] wrote:
>>> On 9/25/15, Ozkan Sezer <sezeroz AT gmail DOT com> wrote:
>>> > AFAICS, dlclose()ing of a dxe doesn't remove its dependency dxes along
>>> > with it, which will result in unnecessarily occupied memory which may
>>> > prove fatal upon multiple dlopen()/dlclose() of a dxe with deps. This
>>> > needs addressing.
>>> >
>>>
>>> My last argument was inaccurate and misleading. Here's better:
>>>
>>> One has a.dxe and b.dxe; a.dxe depends on b.dxe. Do dlopen a.dxe
>>> and b.dxe is opened implicitly. Do dlcose a.dxe, and b.dxe stays
>>> open still occupying its memory. The memory occupied by the unused
>>> b.dxe might be needed by the app but will be unavailable to it.
>>> Further dlopen calls for a.dxe will increment the refcount for b.dxe
>>> which never gets decremented.
>>
>>
>> Can you provide a minimal sample code to demonstrate the issue?
>>
>> Regards,
>> Juan M. Guerrero
>>
>
> =======================================
>
> $ cat 12.c
> extern int my_func2();
> int my_func1() {
> return my_func2();
> }
> $ gcc -c 12.c
> $ dxe3gen -o a.dxe -P b.dxe -U 12.o
> $ dxe3gen --show-exp a.dxe
> _my_func1
> $ dxe3gen --show-dep a.dxe
> b.dxe
>
> =======================================
>
> $ cat 13.c
> int my_func2() {
> return -1;
> }
> $ gcc -c 13.c
> $ dxe3gen -o b.dxe 13.o
> $ dxe3gen --show-exp b.dxe
> _my_func2
>
> =======================================
>
> $ cat 11.c
> #include <dlfcn.h>
> #include <stdio.h>
>
> void *my_dxe1;
> int (*my_f)();
>
> int main (void) {
> my_dxe1 = dlopen("a.dxe",0);
> if (!my_dxe1) {
> printf("dlopen() failed\n");
> return 1;
> }
> dlclose(my_dxe1);
>
> my_f = dlsym(RTLD_DEFAULT,"_my_func1");
> if(!my_f) {
> printf("a.dxe not loaded\n");
> }
> else {
> printf("a.dxe:my_func1(): %p\n",my_f);
> }
>
> my_f = dlsym(RTLD_DEFAULT,"_my_func2");
> if(!my_f) {
> printf("b.dxe not loaded\n");
> }
> else {
> printf("b.dxe:my_func2(): %p\n",my_f);
> printf("b.dxe:my_func2() returns: %d\n",my_f());
> }
>
> return 0;
> }
>
> $ gcc -Wall -W 11.c
>
> =======================================
>
> $ a.exe > a.log
> $ cat a.log
> a.dxe not loaded
> b.dxe:my_func2(): 95830
> b.dxe:my_func2() returns: -1
>
PING? Any ideas? (Sorry that I brought the issue
but have no patch for it myself.)
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |