Fixes asan's detected tbb leak in osrm-partition
Here's all I could get out of a instrumented `osrm-partition`; debug build, with all the bells and whistles I could think of to make it more verbose: ``` ==17928==ERROR: LeakSanitizer: detected memory leaks Direct leak of 1560 byte(s) in 3 object(s) allocated from: #0 0x7f4244185b30 in operator new[](unsigned long) ../../../../libsanitizer/asan/asan_new_delete.cc:62 #1 0x7f4242a788b3 (/usr/lib/libtbb.so.2+0x208b3) SUMMARY: AddressSanitizer: 1560 byte(s) leaked in 3 allocation(s).<Paste> `` Symbolizing the address results in ``` echo "/usr/lib/libtbb.so 0x7f4242a788b3" | llvm-symbolizer _fini ``` Looks like a crt finalizer => static global dtor "leaking" from tbb. Which turned out to be a missing `tbb::task_scheduler_init` on our end: > Using task_scheduler_init is optional in Intel® Threading Building > Blocks (Intel® TBB) 2.2. By default, Intel TBB 2.2 automatically creates > a task scheduler the first time that a thread uses task scheduling > services and destroys it when the last such thread exits. https://www.threadingbuildingblocks.org/docs/help/hh_goto.htm?index.htm#reference/task_scheduler/task_scheduler_init_cls.html Without an explicit instanz the first call to a tbb algorithm seem to initialize a global scheduler singleton which then "leaks" until the program exits. Phew.
This commit is contained in:
parent
075f69acc2
commit
299d071e9d
@ -14,8 +14,6 @@
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <tbb/task_scheduler_init.h>
|
||||
|
||||
#include "util/geojson_debug_logger.hpp"
|
||||
#include "util/geojson_debug_policies.hpp"
|
||||
#include "util/json_container.hpp"
|
||||
|
@ -153,6 +153,8 @@ int main(int argc, char *argv[]) try
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
tbb::task_scheduler_init init(partition_config.requested_num_threads);
|
||||
|
||||
auto exitcode = partition::Partitioner().Run(partition_config);
|
||||
|
||||
util::DumpMemoryStats();
|
||||
|
Loading…
Reference in New Issue
Block a user