Cpp garbage collector deleting live objects --- extern code most likely to blame?

I’m working on a project in haxe, using the cpp backend. The program’s talking to an sqlite database via a hand-rolled extern interface, and I’ve just discovered a really unpleasant issue where sometimes the contents of some of the program’s data structures will vanish, being replaced with nulls. These seems to correlate with garbage collections, and adding calls to cpp.vm.Gc.compact() will provoke it earlier.

I’m guessing there aren’t any known bugs in the cpp garbage collector on Haxe 4.1.3, amd64 Debian Linux?

If that’s the case, then the only possible culprit is my sqlite extern interface. As the cpp extern stuff is almost entirely undocumented I’ve had to guess at a lot of it, so I suspect that I’m doing something wrong and confusing the garbage collector, causing it to think that same objects are garbage when they’re actually live.

Could someone have a quick look and sanity check it, please, and tell me if there’s anything obviously wrong with it? I’m out of ideas, here. It’s 200 lines of pretty simple code: each native object is referenced by a Pointer<SomeExternClass>, and owned by a Haxe class which extends Finalizable.

(Or I could paste it here if people think it’s small enough.)

I have a feeling it is the StringMap in executeSimpleQuery() that is returned from executeQuery() and iterated on. Iteration over StringMap uses Dynamic (and is Slow). I have run into many situations where StringMap contents get nulled in gc sweep. If u can use another data structure there, give that a try. Or avoid the Iterator and use a key lookup.
Personally, I use my own custom wrapper for StringMap for the reason I describe above. Do let me know if that was the issue. I may only be projecting my own issue experience with StringMap.

I’d be surprised is StringMap was the problem — it’s a core part of the language; if it were broken, I wouldn’t expect anything to work! But yes, I could replace that with a simple object. That would be faster and easier so it’s worth doing. I’ll try it and see if anything changes.

Any new leads?

No, I haven’t come up with a decent way to use structures for this. Structures don’t allow array access, which I need in order to dynamically place values in the structure. So it’s either hideous reflection or use a map.

There’s always 2 arrays… One for keys and another for values, so that the index of keys array will be the same for a given key as for the matching value.