Wesley Smith
2011-May-30 02:07 UTC
[LLVMdev] Type::removeAbstractTypeUser crash when freeing module from ExecutionEngine
hi list, I've got a situation where I'm constantly adding and removing Modules from an ExecutionEngine. When removing a module and the jitstate is freed, clean up of the StructLayoutMap ends up trying to access a Type instance was was already freed by the removal of another Module. In trying to debug this, it basically comes down to a Type instance serving as key in StructLayoutMap::LayoutInfo that shouldn't be there (or the Type key shouldn't have been freed although its refcount is 0). I've been scouring the code to find the point where types are added to StructLayoutMap::LayoutInfo but can't find it. Looking in TargetData.cpp shows no code that actually adds entries to the map AFAICT and since StructLayoutMap is declared in the .cpp I don't see how it could be done anywhere else. anyone know which line of code adds types/info pairs to StructLayoutMap::LayoutInfo? thanks in advance, wes
Wesley Smith
2011-Jun-01 02:21 UTC
[LLVMdev] Type::removeAbstractTypeUser crash when freeing module from ExecutionEngine
ok, let me try again. When a type is added to StructLayoutMap::LayoutInfo as a key, where is its refcount incremented? There seems to be an edge case where the Type is left in the LayoutInfo map, but is freed due to a 0 refcount. I have this problem in both 2.8 and 2.9. thanks wes On Sun, May 29, 2011 at 7:07 PM, Wesley Smith <wesley.hoke at gmail.com> wrote:> hi list, > I've got a situation where I'm constantly adding and removing Modules > from an ExecutionEngine. When removing a module and the jitstate is > freed, clean up of the StructLayoutMap ends up trying to access a Type > instance was was already freed by the removal of another Module. In > trying to debug this, it basically comes down to a Type instance > serving as key in StructLayoutMap::LayoutInfo that shouldn't be there > (or the Type key shouldn't have been freed although its refcount is > 0). > > I've been scouring the code to find the point where types are added to > StructLayoutMap::LayoutInfo but can't find it. Looking in > TargetData.cpp shows no code that actually adds entries to the map > AFAICT and since StructLayoutMap is declared in the .cpp I don't see > how it could be done anywhere else. anyone know which line of code > adds types/info pairs to StructLayoutMap::LayoutInfo? > > thanks in advance, > wes >