I have additional infos, it looks to be a strange bug.
I was trying to parse an XML file (which holds a "master" and "detail" records") and write it to a database. First I tried using Datasmap and XMLTransforms, then did it manually because the XML transformations have problems with more than one nested dataset.
I wrote something like this to process XML subnodes (mapping them to detail tables):
SubNode := MailNode.ChildNodes.FindNode('ATTACHMENTS');
if (SubNode <> nil) and SubNode.HasChildNodes then
begin
for j := 0 to SubNode.ChildNodes.Count -1 do
begin
dsAttachments.Insert;
dsAttachmentsCONTENT_TYPE.AsVariant := SubNode.ChildNodes[j]['CONTENT_TYPE'];
dsAttachmentsFILENAME.AsVariant := SubNode.ChildNodes[j]['FILE'];
dsAttachmentsELEMENT_ID.AsVariant := SubNode.ChildNodes[j]['ELEMENT_ID'];
dsAttachments.Post;
end;
end;
I was using TOracleDataset because I used them before with Datasnap, they were set for a M/D relationship therefore I relied on them to generate PKs (using sequences) and FKs (using the M/D relationship).
I discovered that sometimes - not always - when calling Post an "Index list out of bound (-2)" exception was raised, and from now on attempting to close the TOracleSession used by that dataset would result in an AV.
When I got rid of all the dataset and rewrote it to use plain TOracleQuery components, the error disappeared. Yet I wonder why it appeared, because the logic it's the same, the difference is now I don't rely on components to generate and set PKs and FKs but do it myself in code.