Skip to content

DM-51000: Prepare for eups less installations - #12

Open
mwittgen wants to merge 2 commits into
mainfrom
tickets/DM-51000
Open

mwittgen wants to merge 2 commits into
mainfrom
tickets/DM-51000

Conversation

@mwittgen

@mwittgen mwittgen commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

DM-51000: Prepare for eups less installations

@iagaponenko iagaponenko left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good to me. I left a couple of suggestions whivh are optional.

Comment thread src/packaging.cc
return dir;
}

std::string getPackageDirFromAddress(void const* addressInLibrary) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In principle, one could reinforce the code and check that the pointer is not null:

if (addressInLibrary == nullptr) {
    throw std::invalid_argument("Null pointer passed the parameter");
}

I'm sure the null pointer will be noticed by dladdr. However, the function doesn't seem to have any specific code for this scenario:

Comment thread tests/test_packaging.cc Outdated
// The address of a symbol defined in libcpputils resolves, via dladdr, to
// the cpputils package directory -- independent of any environment variable.
auto anchor = reinterpret_cast<void const *>(&getPackageDirFromAddress);
std::filesystem::path cpputilsPath{getPackageDirFromAddress(anchor)};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would break this line into:

// Test for a valid address
std::filesystem::path cpputilsPath;
BOOST_REQUIRE_NO_THROW({
    cpputilsPath = getPackageDirFromAddress(anchor);
});

And if you reinforce the implementation of getPackageDirFromAddress to detect the null pointer, then you may also add this test:

// Now test for the null pointer
BOOST_CHECK_THROW(getPackageDirFromAddress((void*)0), std::invalid_argument);

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The new code introduces brittle build/test behavior (missing direct standard includes in packaging.cc and an env-var-dependent assertion in the new test) that should be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

This PR adds an environment-variable-independent way to locate a package root directory by resolving a symbol address to its containing shared library via dladdr, supporting “eups less” installation scenarios.

Changes:

  • Add getPackageDirFromAddress(void const*) API and implementation using dladdr + std::filesystem.
  • Add a Boost unit test covering the new lookup behavior.
  • Document the new API in the public header.
File Description
include/​lsst/​cpputils/​packaging.h Declares and documents the new address-based package-root lookup API.
src/​packaging.cc Implements getPackageDirFromAddress using dladdr and filesystem canonicalization.
tests/​test_packaging.cc Adds a unit test validating the new lookup and its relationship to the env-var-based lookup.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/packaging.cc
Comment on lines +25 to 29
#include <dlfcn.h>

#include <filesystem>
#include <iostream>
#include <sstream>
Comment thread tests/test_packaging.cc
Comment on lines +51 to +53
// It must agree with the environment-variable-based lookup for the same package.
BOOST_CHECK_EQUAL(std::filesystem::canonical(cpputilsPath),
std::filesystem::canonical(getPackageDir("cpputils")));
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.

3 participants