Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- Expose and implement append_decorations method to build the library… #23

Merged
merged 3 commits into from
Jan 3, 2019

Conversation

Firefly35
Copy link

@Firefly35 Firefly35 commented Oct 31, 2018

… path without loading the library.

It allows to get the concrete path that will be loaded and allows the user to use the concrete path prior to effectively load the library.

… path without loading the library.

It allows to get the concrete path that will be loaded and allows the user to use the concrete path prior to effectively load the library.
- Add error handling for posix platforms (gnu compiler compilation) when a library with missing symbols is asked for loading : check the library path exists and we do not try to load the current executable.
In this case : return the current dlerror (useless to try the exactly specified path as the decorated path points to a valid shared library file).

if (handle_) {
return;
}
if (boost::filesystem::exists(load_path)) {
// decorated path exists : current error is not a bad file descriptor
ec = boost::dll::detail::last_error_code();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the wrong way to use last_error_code. The last_error_code function must be called immediately after the system function in wich error code we are interested in. Putting filesystem::exists between the LoadLibrary and last_error_code breaks the error reporting.

So just move the ec = boost::dll::detail::last_error_code(); line before the if statement. That will do the job.

@@ -511,6 +511,26 @@ class shared_library
return base_t::suffix();
}

/*!
* Returns the decorated path to a shared module name, i.e. with needed prefix/suffix added.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need more scary notes:
Returns the decorated path to a shared module name for the current runtime environment, i.e. ...
Calling this function with different current directories may produce different results.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what you mean with "different current directories" ?

Copy link
Member

@apolukhin apolukhin Nov 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ther result of shared_library::decorate("foo") may not be the same, if user changes the current directory via https://en.cppreference.com/w/cpp/filesystem/current_path
For example it may return libfoo.so and foo.so, depending on the working directory.

Oh, one more thing: please add a test, that if we create an empty file with name test_broken.so and try to load it, then the the loading fails. You may also write some other tests.

@apolukhin
Copy link
Member

Almost ready for merge :)

@apolukhin apolukhin merged commit c0a5b8d into boostorg:develop Jan 3, 2019
@apolukhin
Copy link
Member

Many thanks for the PR!

I've changed a few things in 7981565

We need a better name for the decorate(). It must be scary so that people would not use it without huge need.

@Firefly35
Copy link
Author

Thanks Antony, feel sorry that I didn't have time to finalize the PR with your comments.
I wish you an happy new year for 2019.

@apolukhin
Copy link
Member

Thanks to you! You made the most part of the job.

Happy new Year :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants