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

Allow runtime malloc replacement using LoadLibary #828

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Karel-Deconinck
Copy link

When a .dll is loaded using the LoadLibary() then the "reserved" parameter is NULL in the DllMain() function. This makes it impossible to dynamicly load the malloc_proxy dynamically at runtime because the "reserved" parameter is checked to be not null. So I removed the (I think needles) condition on that variable so that the doMallocReplacement() will be called on a LoadLibary(). This allows programmers to create applications that can "optionally" use the tbb_malloc replacement without having to re-link the application.

Description

We are creating an application that will allow end-users to choose what malloc acceleration technique the application should use. But in order to accomidate the runtime option we need to be able to instantiate / call the tbb-malloc proxy replacement at runtime using LoadLibary() and not at Link time. As documented by Microsoft ( https://docs.microsoft.com/en-us/windows/win32/dlls/dllmain ) the DllMain function is called when a dll is "linked" to the application a bit different then when the .dll is loaded using the LoadLibary(). the last parameter ( named reserved ) will be NULL when using the LoadLibary() at runtime. The fix is easy , don't check this reserved parameter to be different then NULL.

Fixes # - issue number(s) if exists

Fixes the previously inability to dynamically setup the malloc_proxy using LoadLibary()

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

  • new feature - change that adds functionality

Tests

  • not yet added : but a new test should be to dynamically load the malloc_proxy dll using LoadLibary()

Documentation

  • [ Y] needs to be updated

Breaks backward compatibility

  • Yes
  • [X ] No
  • Unknown

Notify the following users

List users with @ to send notifications

Other information

This is my very first pull request ever

When a .dll is loaded using the LoadLibary() then the "reserved" parameter is NULL in the DllMain() function. This makes it impossible to dynamicly load the malloc_proxy dynamically at runtime because the "reserved" parameter is checked to be not null. So I removed the (I think needles) condition on that variable so that the doMallocReplacement() will be called on a LoadLibary(). This allows programmers to create applications that can "optionally" use the tbb_malloc replacement without having to re-link the application.
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

1 participant