Second attempt to perform debug registration

I am compiling on-line generated source code in a loop:

std::unique_ptrcling::Interpreter gCling;
for ( … ) {
gCling.reset(new cling::Interpreter(argc, argv, “…”));
…generate source code, compile and run it…
}

Seemingly at some random iteration i end up with:
GDBRegistrationListener.cpp:177: virtual void {anonymous}::GDBJITRegistrationListener::NotifyObjectEmitted(const llvm::object::ObjectFile&, const llvm::RuntimeDyld::LoadedObjectInfo&): Assertion `ObjectBufferMap.find(Key) == ObjectBufferMap.end() && “Second attempt to perform debug registration.”’ failed.

Can this be some kind of data race?

Could you use another variable name (just in case). gCling is reserved for other purposes.

Changed the name (although i don’t see how can that have any effect).

Is there some way to restart the interpreter (so i do not have to destruct and re-create it)?
I have tried unlink(), but i have no way to tell how many transactions need to be rolled back.

I think this is a bug sft.its.cern.ch/jira/browse/ROOT-7741
In the meanwhile you could try something like:

[cling$] #include "cling/Interpreter/Interpreter.h"
[cling$] gCling->process("...autogenerated_code..."); // this will create 1 transaction
[cling$] gCling->unload(1);

The generated code is complete source with includes, multiple functions etc so i think process() which would attempt to wrap it into a function is not going to work. I am using declare() but as far as i can tell the end result is not a single transaction, and i have not found a way to figure out the number of transactions generated (and unload() does not return any status so i cannot run it in a loop).

Currently the preamble (includes, typedefs etc) does not change between compilations, so i can try to compile the static part once, then at each iteration add functions then unload(# of functions added) – assuming function definitions add one transaction each. Would that work?