ADIOS2 icon indicating copy to clipboard operation
ADIOS2 copied to clipboard

Plugin engine segfaults when writing a variable that was defined after opening the engine

Open lahwaacz opened this issue 3 months ago • 1 comments

ADIOS2 allows to call IO::DefineVariable after IO::Open. However, when the engine type is set to plugin, then calling Engine::Put on this variable causes a segfault.

Reproducer:

#include <adios2.h>

static const int sample_data = 42;

int main(int argc, char *argv[]){
    adios2::ADIOS adios;
    adios2::IO io = adios.DeclareIO("TestIO");

    // Set a specific engine: bpfile works, plugin segfaults
//    io.SetEngine("bpfile");
    io.SetEngine("plugin");
    io.SetParameter("PluginName", "fides");
    io.SetParameter("PluginLibrary", "ParaViewADIOSInSituEngine");
    io.SetParameter("DataModel", "datamodel.json");
    io.SetParameter("Script", "pipeline.py");

    // Arbitrary filename (not used by the plugin engine)
    std::string filename = "output.bp";
    adios2::Engine engine = io.Open(filename, adios2::Mode::Write);

    adios2::Variable<int> var = io.DefineVariable<int>("size");

    engine.BeginStep();
    engine.Put(var, &sample_data);
    engine.EndStep();

    engine.Close();

    return 0;
}

Build and run:

$ g++ test.cpp -ladios2_cxx11 -g
$ ./a.out
	Catalyst Library Version: 2.0
	Catalyst ABI Version: 2
	Implementation: stub

[hostname:2343538:0:2343538] Caught signal 11 (Segmentation fault: address not mapped to object at address 0x44)
==== backtrace (tid:2343538) ====
 0 0x000000000004dd71 ucs_rcache_distribution_get_num_bins()  ???:0
 1 0x000000000004df3d ucs_rcache_distribution_get_num_bins()  ???:0
 2 0x000000000003e4d0 __sigaction()  ???:0
 3 0x000000000029fbab adios2::core::VariableBase::CheckDimensions()  ???:0
 4 0x00000000002251a0 adios2::core::Engine::CommonChecks()  ???:0
 5 0x0000000000227563 adios2::core::Engine::Put<int>()  ???:0
 6 0x0000000000002770 main()  /home/user/test.cpp:24
 7 0x0000000000027635 __libc_init_first()  ???:0
 8 0x00000000000276e9 __libc_start_main()  ???:0
 9 0x0000000000002195 _start()  ???:0
=================================
Segmentation fault         (core dumped) ./a.out

Backtrace:

(gdb) bt full
#0  adios2::core::VariableBase::CheckDimensions (this=0x0, hint="in call to Put") at /usr/src/debug/adios2/ADIOS2-2.10.2/source/adios2/core/VariableBase.cpp:375
No locals.
#1  0x00007f36da8251a0 in adios2::core::Engine::CommonChecks (this=this@entry=0x56400db85a50, variable=..., data=data@entry=0x563fefabf384 <sample_data>, modes=std::set with 2 elements = {...}, hint="in call to Put")
    at /usr/src/debug/adios2/ADIOS2-2.10.2/source/adios2/core/Engine.cpp:306
No locals.
#2  0x00007f36da827563 in adios2::core::Engine::Put<int> (this=0x56400db85a50, variable=..., data=0x563fefabf384 <sample_data>, launch=adios2::Mode::Deferred) at /usr/src/debug/adios2/ADIOS2-2.10.2/source/adios2/core/Engine.tcc:49
No locals.
#3  0x0000563fefabd770 in main (argc=1, argv=0x7ffd84a71ff8) at test.cpp:24
        adios = {m_ADIOS = std::shared_ptr<adios2::core::ADIOS> (use count 1, weak count 0) = {get() = 0x56400db7c200}}
        io = {m_IO = 0x56400db70b70}
        filename = "output.bp"
        engine = {m_Engine = 0x56400db7c690}
        var = {m_Variable = 0x56400db499b0}

Version: adios2 2.10.2

lahwaacz avatar Nov 15 '25 18:11 lahwaacz

It's not the plugin engine infrastructure. The catalyst plugin engine creates its own IO object internally at Open, and creates its variables from the IO object you pass in Open(). After that changing your IO object has no effect on this particular engine. I don't know if there is a need for this shadow-copying of variable definitions here, so I let it's author, @caitlinross answer that.

pnorbert avatar Nov 17 '25 15:11 pnorbert