Skip to content

Loader always extracts to /tmp when USE_LOADER=ON: libdd_profiling-embedded.so not installed #535

Description

@xroche

Description

When USE_LOADER=ON (the default), the loader (libdd_profiling.so) tries to dlopen("libdd_profiling-embedded.so") at construction time (loader.c:312). This always fails because libdd_profiling-embedded.so is not included in the install targets or the release tarball — it only exists as binary data embedded inside the loader.

Since the dlopen fails, the loader extracts both libdd_profiling-embedded.so and ddprof to /tmp. The /tmp copy of ddprof lacks file capabilities (CAP_PERFMON, CAP_SYS_PTRACE, CAP_IPC_LOCK), so perf_event_open fails with EPERM.

This makes the "skip /tmp extraction when libraries are installed" fix from #529 / commit 90b41db ineffective in practice.

Reproduction

Install ddprof 0.25.0 from the release tarball on any system:

$ ls /usr/lib/libdd_profiling*
/usr/lib/libdd_profiling.so        # the loader — installed
                                   # libdd_profiling-embedded.so — NOT installed

$ ls /tmp/ddprof-* /tmp/libdd_profiling-embedded*
/tmp/ddprof-<hash>                 # extracted, no file caps
/tmp/libdd_profiling-embedded.so-<hash>  # extracted

Proposed fix

Add dd_profiling-embedded to the CMake install targets when USE_LOADER=ON:

set(_install_targets ddprof dd_profiling-static dd_profiling-shared)
if(USE_LOADER)
  list(APPEND _install_targets dd_profiling-embedded)
endif()

install(
  TARGETS ${_install_targets}
  RUNTIME DESTINATION bin
  LIBRARY DESTINATION lib
  ARCHIVE DESTINATION lib
  PUBLIC_HEADER DESTINATION include)

With this change, the loader finds libdd_profiling-embedded.so via standard dlopen search, skips /tmp extraction entirely, and execvp("ddprof") finds /usr/bin/ddprof with its file capabilities intact.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions