| View previous topic :: View next topic |
| Author |
Message |
krotuss Tux's lil' helper

Joined: 01 Aug 2008 Posts: 89
|
Posted: Sun Aug 29, 2010 10:47 pm Post subject: When are .so's reloaded? |
|
|
| Hi, what will happen when I reemerge shared library, which is already loaded in memory, and than launch some program that is linked with this library? Will linker find out so library has changed and load its new version, or program will be linked with old version which is already loaded? Thanks. |
|
| Back to top |
|
 |
Naib Advocate


Joined: 21 May 2004 Posts: 3929 Location: UK - Birmingham
|
Posted: Mon Aug 30, 2010 12:15 am Post subject: |
|
|
Presently running apps will still be referencing the "old" so (be it in RAM or via inode location).
Newer apps will force the newer so to be loaded
| Code: |
deadlib() { lsof | grep 'DEL.*lib' | cut -f 1 -d ' ' | sort -u; }; deadlib |
is a good one-liner to show what apps need to be restarted after an so update _________________ A free press is the unsleeping guardian of every other right that free men prize; it is the most dangerous foe of tyranny. Where men have the habit of liberty, the Press will continue to be the vigilant guardian of the rights of the ordinary citizen. |
|
| Back to top |
|
 |
krotuss Tux's lil' helper

Joined: 01 Aug 2008 Posts: 89
|
Posted: Mon Aug 30, 2010 8:37 am Post subject: |
|
|
| Thanks. How does linker know that library has changed, is there some mechanism similar to inotify used, or it simply compares image of library on disk with the one in RAM every time it links another program? |
|
| Back to top |
|
 |
eccerr0r Advocate

Joined: 01 Jul 2004 Posts: 2998 Location: USA
|
Posted: Mon Aug 30, 2010 3:05 pm Post subject: |
|
|
Linker doesn't know, it just checks the current location. The linker is invoked every time a new program is run.
Existing programs (that are already loaded) have pointers to the old version, as Naib says, in RAM as code or an inode location as a file handle to the deleted version. Once all handles are gone/programs terminated, the file will then truly be "removed" from the disk and space reclaimed. Until then you'll see shared libraries still eating disk space and RAM, despite them being removed.
This is why it's good to reboot the machine after certain upgrades such as libc, so programs like init can pick up a new copy of libc.
(unlike in Windows it simply forces you to reboot... which may not always be a bad thing.) _________________ Core-i7-2700K@4.1GHz/8GB RAM/180GB SSD/Intel HD3000 graphics
What the heck am I advocating? |
|
| Back to top |
|
 |
Naib Advocate


Joined: 21 May 2004 Posts: 3929 Location: UK - Birmingham
|
Posted: Mon Aug 30, 2010 4:15 pm Post subject: |
|
|
| eccerr0r wrote: | Linker doesn't know, it just checks the current location. The linker is invoked every time a new program is run.
Existing programs (that are already loaded) have pointers to the old version, as Naib says, in RAM as code or an inode location as a file handle to the deleted version. Once all handles are gone/programs terminated, the file will then truly be "removed" from the disk and space reclaimed. Until then you'll see shared libraries still eating disk space and RAM, despite them being removed.
This is why it's good to reboot the machine after certain upgrades such as libc, so programs like init can pick up a new copy of libc.
(unlike in Windows it simply forces you to reboot... which may not always be a bad thing.) |
my one-liner helps. Takes a bit of getting use to to know what binary corresponds to what init service. After an upgrade I run that on my headless to see what services need restarting _________________ A free press is the unsleeping guardian of every other right that free men prize; it is the most dangerous foe of tyranny. Where men have the habit of liberty, the Press will continue to be the vigilant guardian of the rights of the ordinary citizen. |
|
| Back to top |
|
 |
|