Skip to content

Used in Windows DLL, FreeLibrary() hangs host program on unloading DLL. #251

Open
@PolyVinalDistillate

Description

@PolyVinalDistillate

In a DLL with a single function executing the following test code after being loaded with LoadLibrary():

void DLL_EXPORT IdentifierFunction(char** sBuf)
{
  *sBuf = (char*)sPluginID;  //Simply returns sPluginID

  printf("\n\nHello from TensorFlow C library version %s\n", TF_Version());
  auto a = cppflow::tensor({1.0, 2.0, 3.0});
  auto b = cppflow::fill({3}, 1.0);

  printf("Testing CPPFlow Tensor Addition Example\n");
  auto c = a+b;
  std::cout << c << std::endl;
  printf("\n\n");
}

I find that a subsequent call in the host program to FreeLibrary() hangs the execution.

If I append the following to the end of the above function:
TFE_DeleteContext(cppflow::context::get_context());

Then I can call FreeLibrary() without issue. I'm totally new to all this, so sorry if I'm missing something - but I feel like there's a bug here, as I saw a similar issue was closed last year due to inactivity.

P.S. trying to delete the context in DllMain() DLL_PROCESS_DETACH does not work, and neither does storing the TFE_Context* in a global variable to delete it later in DLL_PROCESS_DETACH.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions