View previous topic :: View next topic |
Author |
Message |
krotuss Apprentice
Joined: 01 Aug 2008 Posts: 227
|
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 Watchman
Joined: 21 May 2004 Posts: 6059 Location: Removed by Neddy
|
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 _________________
Quote: | Removed by Chiitoo |
|
|
Back to top |
|
|
krotuss Apprentice
Joined: 01 Aug 2008 Posts: 227
|
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 Watchman
Joined: 01 Jul 2004 Posts: 9766 Location: almost Mile High in the 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.) _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6059 Location: Removed by Neddy
|
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 _________________
Quote: | Removed by Chiitoo |
|
|
Back to top |
|
|
|