bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug while calling dlcose


From: marco
Subject: Re: Bug while calling dlcose
Date: Sun, 18 May 2003 23:01:18 +0200 (CEST)

> Such a scenario can never work.  The dlclose call will unmap the plugin
> library the code from the process's memory image.  Then, dlclose returns
> to its caller, which returns to its caller, which is a PC in memory
> that's no longer there.

No, this is not true because the caller of dlclose() is not the plugin.
The program calls dlclose on the request of the plugin. It does not return
to the plugin.

Here is a detailed description of a failure and succes scenarioL

Lets assume the program is called A and the loaded module/library/plugin
is called B.

A has the funtion stop().
A calls makethread() in B.
makethread() (in B) creates a new thread and returns to A.
A starts and endless loop (for (;;);)
The thread in B calls stop() in A.
--At this point no thread uses the memory of B--
stop() unloads B using dlclose()... bad stuff happens.

The funny thing is that the patch I've sent works ;). I'll describe how it
works:

A makes an additional thread to run the endless loop.
A waits for a signal using condition_wait.
B calls stop() in A.
A (in stop()) send a signal to A(in the main, where it is still waiting
for this signal)
A (in main) receives the sigal, is happy because it received the signal
and calls dlclose(). No bad stuff happens now.

So when called from the main thread it works! :)

The problem is related to threads, without threads (and without GDB) there
is not a problem.

Thanks,
Marco






reply via email to

[Prev in Thread] Current Thread [Next in Thread]