Re: Changing libraries when they are already in process space
- From: Nix <nix-razor-pit@xxxxxxxxxxxxx>
- Date: Thu, 07 Jun 2007 22:46:57 +0100
On 6 Jun 2007, Josef Moellers said:
sandy wrote:
Hi,
I would need some information on unix system libraries. An application
is running in a machine and using some COMMON libraries like, libstdc+
+ and libodbc. This library is already loaded in application's process
space.
If i use RPM installer or any other program which replaces COMMON
libraries, what happens to the process already running.
It keeps the old file in memory. New processes loading the shared
object will get the new one. It is just not feasable to replace code
and data from within a process' address space.
Not without the cooperation of that process, at least, and even then
it's horribly difficult.
Does it
actually allows to replace library?
Why shouldn't it? Besides, if you upgrade to a new version, you'll
usually get a new file name as well: /usr/lib/libstdc++.so.5.0.6 will
still be there if you install /usr/lib/libstdc++.so.5.0.7, only the
symbolic link /usr/lib/libstdc++.so.5 will be set to the new file.
That is, it doesn't allow replacement of a running binary. You can
unlink (`delete') the library and put another file of the same name
there, and this is what normally happens: in that case, because the old
library is still being held open by all those things using it, it does
not actually get freed off the filesystem until all the processes
holding it open have closed it. (These are, of course, standard Unix
semantics.)
*Overwriting* of a running executable *is* blocked, with the write()
failing with -ETXTBSY (at one point this wasn't true for shared
libraries and other executable mmap()s, and overwriting them would be
apt to cause major crahses of lots of processes all at once: you'll
pardon me if I don't test this *just* now).
Init is statically linked, so there's no need to restart
that, which would require a reboot.
Not so!
linux-gate.so.1 => (0xb7f47000)
libc.so.6 => /lib/libc.so.6 (0x4332d000)
/lib/ld-linux.so.2 (0x4330f000)
In fact, telinit even has an option `q' which causes init to re-exec()
itself, specifically so that it can pick up new shared libraries
(generally after a libc upgrade).
However, it is often easier to reboot than to restart various services.
Certainly if you upgrade things like libc and the new copy has security
fixes in it or something, sure.
--
`... in the sense that dragons logically follow evolution so they would
be able to wield metal.' --- Kenneth Eng's colourless green ideas sleep
furiously
.
- Follow-Ups:
- Re: Changing libraries when they are already in process space
- From: Josef Moellers
- Re: Changing libraries when they are already in process space
- References:
- Changing libraries when they are already in process space
- From: sandy
- Re: Changing libraries when they are already in process space
- From: Josef Moellers
- Changing libraries when they are already in process space
- Prev by Date: Re: DSO prelinking
- Next by Date: how to get unstripped libraries from buildroot?
- Previous by thread: Re: Changing libraries when they are already in process space
- Next by thread: Re: Changing libraries when they are already in process space
- Index(es):
Relevant Pages
|