Skip to content

Rare memory management failures in FM-index in multi-threadding context #3389

@behrj

Description

@behrj

Does this problem persist on the current main?

  • I have verified the issue on the current main

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

In rare cases we find failures that look like this:

libs/seqan3/submodules/sdsl-lite/include/sdsl/int_vector.hpp:1820: 
  sdsl::int_vector<<anonymous> >::reference 
    sdsl::int_vector<<anonymous> >::operator[](const size_type&) 
[with unsigned char t_width = 0; 
 reference = sdsl::int_vector_reference<sdsl::int_vector<0> >; 
 size_type = long unsigned int]: 
Assertion idx < this->size()' failed.

Aborted (core dumped)

We are using the FM-index in a multi-thread context where each thread creates a separate instance of the index.
Our understanding that the global singleton pattern currently does not handle critical parts of the memory management in a thread-safe manner.

Expected Behavior

We would like to use the FM index in a multi-threadded context.

Steps To Reproduce

We do not have a small test to reproduce the issue.
Creating a number of threads constantly creating and destroying FM-indices should trigger the failure.

We have successfully tested the following patch:

-         static memory_manager m;
+         static thread_local memory_manager m;

on seqan3/submodules/sdsl-lite/include/sdsl/memory_management.hpp line 776.

Environment

- Operating system: ubuntu:22.04
- SeqAn version: 3.3.0
- Compiler: gcc-12

Anything else?

As the failure is rare, we cannot be sure if our patch is 100% effective, but we have not seen issues in the test we ran so far. So the tests are successful in the sense that the application is compiling and was run on about 50 cases.
We saw a failure rate of about 1/500, so we will only be able to confirm that this working well after a couple of weeks. Therefore, your assessment of the issue and the solution would be valuable.

Metadata

Metadata

Assignees

Labels

bugfaulty or wrong behaviour of code

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions