Mir

Merge lp://qastaging/~afrantzis/mir/fix-1358191-connect-segv-spike into lp://qastaging/mir

Proposed by Alexandros Frantzis
Status: Rejected
Rejected by: Alexandros Frantzis
Proposed branch: lp://qastaging/~afrantzis/mir/fix-1358191-connect-segv-spike
Merge into: lp://qastaging/mir
Diff against target: 301 lines (+126/-28)
8 files modified
src/client/CMakeLists.txt (+1/-0)
src/client/connection_configuration.h (+2/-0)
src/client/default_connection_configuration.cpp (+14/-6)
src/client/default_connection_configuration.h (+4/-0)
src/client/mir_connection.cpp (+2/-22)
src/client/mir_connection.h (+5/-0)
src/client/shared_library_cache.cpp (+48/-0)
src/client/shared_library_cache.h (+50/-0)
To merge this branch: bzr merge lp://qastaging/~afrantzis/mir/fix-1358191-connect-segv-spike
Reviewer Review Type Date Requested Status
Alan Griffiths Needs Fixing
Chris Halse Rogers Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+232108@code.qastaging.launchpad.net

Commit message

client: Ensure our platform library stays loaded for as long as it is needed by other objects

Description of the change

client: Ensure our platform library stays loaded for as long as it is needed by other objects

Both the DefaultClientConfiguration and the MirConnection need it independently for their own reasons (see the bug addressed by this MP), so they both need to keep a strong pointer to the (newly introduced) shared library cache.

Note that this is a spike (it doesn't contain proper targeted tests etc).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

I've been pondering writing a Module class to properly reference-count all the things we load from libraries. That'd be significantly more invasive, though.

Of course, we could also just remove the dlclose() from ~SharedLibrary, and remove the SharedLibraryCache thing entirely. There's no reason to avoid dlopen()ing a library twice, and we never load an unnecessary one so the only thing dlclose() buys us is these bugs.

This seems like a reasonable approach, though.

Revision history for this message
Chris Halse Rogers (raof) :
review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> Of course, we could also just remove the dlclose() from ~SharedLibrary, and remove the
> SharedLibraryCache thing entirely. There's no reason to avoid dlopen()ing a library twice,
> and we never load an unnecessary one so the only thing dlclose() buys us is these bugs.

That's a fair point. If the only reason we want the cache is teardown cleanliness (i.e. explicitly unloading libraries that we loaded explicitly), then just keeping the libraries always loaded is also viable option (in that case a class name like PermanentSharedLibrary would be more descriptive).

Revision history for this message
Chris Halse Rogers (raof) wrote :

Well, I do actually use the unloadability in https://code.launchpad.net/~raof/mir/privatise-all-the-things/+merge/228796 - we load everything to probe it, and then want to unload the platforms that didn't probe.

Hm. Having said that, just making the unload explicit would be fine - the only time we need to unload things is in the location that we open them, so reference-counted SharedLibraries aren't a big win.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> we load everything to probe it, and then want to unload the platforms that didn't probe.

Then perhaps we can keep SharedLibrary as it is and add a SharedLibrary::make_permanent() member that ensures that the library is not unloaded on object destruction (or we could have SharedLibrary and PermanentSharedLibrary, or ... many options here :))

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I don't think we should be coupling SharedLibrary to a cache interface.

Indeed wouldn't placing a cache implementation directly in the configuration object be sufficient?

review: Needs Information
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Indeed wouldn't placing a cache implementation directly in the configuration
> object be sufficient?

After a bit of discussion on IRC I see this wouldn't work.

But that also leads to the conclusion that the condition in...

    // When the last valid connection goes we can clear the libraries cache
    if (!valid_connections)
    {
        delete libraries_cache_ptr;
        libraries_cache_ptr = nullptr;
    }

...is wrong - as the lack of valid connections isn't a sufficient criteria for releasing the cache. Maybe we can just fix that condition to also consider the configuration.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> I don't think we should be coupling SharedLibrary to a cache interfac

Oops meant to update the vote

review: Needs Fixing
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Unmerged revisions

1861. By Alexandros Frantzis

client: Ensure our platform library stays loaded for as long as it is needed by other objects

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches