ornladios / ADIOS2

Next generation of ADIOS developed in the Exascale Computing Program
https://adios2.readthedocs.io/en/latest/index.html
Apache License 2.0
267 stars 125 forks source link

BP5 Address sanitizer and undefined behavior sanitizer issues #3580

Open caitlinross opened 1 year ago

caitlinross commented 1 year ago

I'm updating the Fides CI to use ADIOS 2.9 and found a couple of memory leaks as well as an error found by undefined behavior sanitizer.

Memory leaks:

For the UB error, the only information I get is

/usr/include/c++/9/bits/stl_vector.h:1061:34: runtime error: reference binding to null pointer of type 'const struct value_type'

I did a git bisect and found it started with this commit: 5e03434c2d5d940f51183d07fc607aa8b85801a1

@eisenhauer

eisenhauer commented 1 year ago

Hey Caitlin. Hmm. This code got uglier when we had to support ReadRandomAccess mode and this problem maybe related to that, but offhand I don't see how these things fail to get deleted if the BP5Deserializer destructor is called. This bit of code in the destructor should handle all cases:

    if (m_FreeableMBA)
        delete m_FreeableMBA;
    for (auto &step : MetadataBaseArray)
    {
        delete step;
    }

We're not seeing leaks in our own CI in this, so maybe there's something special about how Fides is using ADIOS? I took a quick peek at the code, but I can't spend time on it at the moment as I'm on vacation. I'd suggest trying to make sure that Close() gets called on all the sources... I don't have any thoughts beyond that without doing some more digging.

caitlinross commented 1 year ago

That could be the case. I'll check on it.

Have fun on vacation!