Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
When are .so's reloaded?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
krotuss
Tux's lil' helper
Tux's lil' helper


Joined: 01 Aug 2008
Posts: 92

PostPosted: Sun Aug 29, 2010 10:47 pm    Post subject: When are .so's reloaded? Reply with quote

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
View user's profile Send private message
Naib
Advocate
Advocate


Joined: 21 May 2004
Posts: 4103
Location: Removed by Neddy

PostPosted: Mon Aug 30, 2010 12:15 am    Post subject: Reply with quote

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
View user's profile Send private message
krotuss
Tux's lil' helper
Tux's lil' helper


Joined: 01 Aug 2008
Posts: 92

PostPosted: Mon Aug 30, 2010 8:37 am    Post subject: Reply with quote

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
View user's profile Send private message
eccerr0r
Advocate
Advocate


Joined: 01 Jul 2004
Posts: 3825
Location: USA

PostPosted: Mon Aug 30, 2010 3:05 pm    Post subject: Reply with quote

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@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed to be advocating?
Back to top
View user's profile Send private message
Naib
Advocate
Advocate


Joined: 21 May 2004
Posts: 4103
Location: Removed by Neddy

PostPosted: Mon Aug 30, 2010 4:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum