Skip to content

Conversation

@emilazy
Copy link

@emilazy emilazy commented Sep 13, 2025

Description

This fixes issues that arise when libtbbmalloc cannot be loaded by relative path, makes the behaviour consistent with the Windows code path, and eliminates the duplication of MALLOCLIB_NAME.

Fixes # - issue number(s) if exists

Type of change

Choose one or multiple, leave empty if none of the other choices apply

Add a respective label(s) to PR if you have permissions

  • bug fix - change that fixes an issue
  • new feature - change that adds functionality
  • tests - change in tests
  • infrastructure - change in infrastructure and CI
  • documentation - documentation update

Tests

  • added - required for new features and some bug fixes
  • not needed

Probably too difficult to test. I confirmed that this stops the test suite crashing on program exit on macOS in Nixpkgs, though.

Documentation

  • updated in # - add PR number
  • needs to be updated
  • not needed

Breaks backward compatibility

  • Yes
  • No
  • Unknown

Notify the following users

List users with @ to send notifications

Other information

@emilazy
Copy link
Author

emilazy commented Sep 13, 2025

It seems like RTLD_NODELETE may be a better solution to the general problem here, by the way. But I only went for the most direct local fix for the problem we were seeing.

@emilazy
Copy link
Author

emilazy commented Sep 13, 2025

Looks like this is (nondeterministically?) causing problems on Linux, and I don’t know why :(

My guesses (e.g. needs RTLD_GLOBAL?) seem like they should apply equally to the previous state of the code.

This fixes issues that arise when `libtbbmalloc` cannot be loaded by
relative path, makes the behaviour consistent with the Windows code
path, and eliminates the duplication of `MALLOCLIB_NAME`.
@emilazy
Copy link
Author

emilazy commented Sep 13, 2025

I guess this was the same thing as:

// There is an use case, when we want to find TBB library, not just some shared object
// providing "dynamic_link" symbol (it can be shared object that directly includes
// dynamic_link.cpp). For this case we use a public TBB symbol. Searching for public symbol
// in every case leads to finding main executable instead of TBB library on some version of
// Linux.
#if DYNAMIC_LINK_FIND_LIB_WITH_TBB_RUNTIME_VERSION
static void *func_from_lib = (void*)&TBB_runtime_version;
#else
static void *func_from_lib = (void*)&dynamic_link;
#endif

Switching to a private function fixed it. Let me know if you want to add an #if for this one too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant