Skip to content

[C++] compute kernels registry is not reset when dll is unloaded #47608

@alinaliBQ

Description

@alinaliBQ

Describe the bug, including details regarding any error messages, version, and platform.

Hi community, it seems the compute kernels registry is not cleared when the dll library (that is dynamically linked to arrow_compute.dll) is unloaded. Is this expected behavior? If not, then this might be a big impact.

Please let me know if you have any questions. Here is my attempt at explaining the issue that our team is facing:

  • we are working on an Arrow Flight SQL ODBC driver dll (arrow_flight_sql_odbc.dll) library at GH-46734: [C++] Arrow Flight SQL ODBC layer #46099, that uses arrow_compute.dll
  • arrow::compute::Initialize() is called once from arrow_flight_sql_odbc.dll every time the driver dll is loaded in the test executable. And each test case loads the driver dll at the beginning and unloads at the end.
  • this means arrow::compute::Initialize() gets called every test case
  • this causes an issue because when the second test case starts, we receive Already have a function registered with name error and it blocks rest of tests from running.

What the error message looks like:

[Test 1 passes]
[Test 2 starts]
arrow\cpp\src\arrow\compute\kernels\scalar_arithmetic.cc:1448:  Check failed: _s.ok() Operation failed: registry->AddFunction(std::move(absolute_value))
Bad status: Key error: Already have a function registered with name: abs
  • this error message makes sense because abs is the first function that gets registered, and Arrow errors out on this first call to AddFunction.

I think that every dll library that calls arrow::compute::Initialize() could potentially run into this issue. This is because the application that uses the dll isn't guaranteed to know Arrow compute, so the application isn't expected to call arrow::compute::Initialize().

  • I can confirm this error goes away when I remove the arrow::compute::Initialize() call from the driver dll and into the test environment set up, but the initialization needs to happen inside the driver, as the driver needs to initialize the compute functions in order to work properly.

Thanks in advance to people that are looking into this.

Component(s)

C++

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    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