XbimGeometry icon indicating copy to clipboard operation
XbimGeometry copied to clipboard

SEHException on XBimWire has appeared since v5.1.328 (works in 5.1.317 / 5.1.325)

Open OlivierC-A3d opened this issue 4 years ago • 23 comments

I'm facing a fatal SEHException in Xbim3DModelContext#createContext in version 5.1.328 with the following stack

at ShapeFix_Wire.Perform(ShapeFix_Wire* ) at Xbim.Geometry.XbimWire.Init(IIfcArbitraryClosedProfileDef profile, ILogger logger, XbimConstraints constraints) at Xbim.Geometry.XbimWire.Init(IIfcProfileDef profile, ILogger logger, XbimConstraints constraints) at Xbim.Geometry.XbimWire..ctor(IIfcProfileDef profile, ILogger logger, XbimConstraints constraints) at Xbim.Geometry.XbimFace.Init(IIfcProfileDef profile, ILogger logger) at Xbim.Geometry.XbimFace..ctor(IIfcProfileDef profile, ILogger logger) at Xbim.Geometry.XbimSolid.Init(IIfcExtrudedAreaSolid solid, IIfcProfileDef overrideProfileDef, ILogger logger) at Xbim.Geometry.XbimSolid..ctor(IIfcExtrudedAreaSolid solid, ILogger logger) at Xbim.Geometry.XbimGeometryCreator.CreateSolid(IIfcExtrudedAreaSolid ifcSolid, ILogger logger) at Xbim.Geometry.XbimGeometryCreator.Create(IIfcGeometricRepresentationItem geomRep, IIfcAxis2Placement3D objectLocation, ILogger logger) at Xbim.Geometry.Engine.Interop.XbimGeometryEngine.Create(IIfcGeometricRepresentationItem ifcRepresentation, ILogger logger)

I've tested with 5.1.317 / 5.1.325 and the crash did not appeared

Assemblies and versions affected:

Xbim.Geometry.Engine.Interop version="5.1.328"

Steps (or code) to reproduce the issue:

Crash appears with an IFCEXTRUDEDAREASOLID with a SweptArea IFCARBITRARYCLOSEDPROFILEDEF(.AREA....) composed of an OuterCurve IFCCOMPOSITECURVE

OlivierC-A3d avatar Sep 23 '20 09:09 OlivierC-A3d

Can you retest with the latest Geometry Engine (5.1.376)?

andyward avatar Oct 17 '20 16:10 andyward

Hello. I'm going to update and test right away ! Thanks ... if working :)

OlivierC-A3d avatar Oct 19 '20 06:10 OlivierC-A3d

Ok I've upgraded my projects to net472 to match the upgrade and after I successfully compiled my projects I've a new issue

System.AggregateException: Une ou plusieurs erreurs se sont produites. ---> System.TypeLoadException: La méthode 'CreateShapeGeometry' du type 'Xbim.Geometry.Engine.Interop.XbimGeometryEngine' de l'assembly 'Xbim.Geometry.Engine.Interop, Version=5.1.0.0, Culture=neutral, PublicKeyToken=11e3655e576ec5a9' n'a pas d'implémentation.

The method is not implemented and I checked the library is : ".nuget\packages\xbim.geometry.engine.interop\5.1.390\lib\net472\Xbim.Geometry.Engine.Interop.dll"

OlivierC-A3d avatar Oct 19 '20 07:10 OlivierC-A3d

Sorry I think 5.1.390 of Geometry from our master myget feed is a bit broken. (We are sorting out some build server issues).

Can you try 5.1.387-develop from the develop myget? That's the latest code

andyward avatar Oct 20 '20 13:10 andyward

No problem I'll try this version tomorrow

OlivierC-A3d avatar Oct 20 '20 14:10 OlivierC-A3d

Ok so I put XBim.Geometry and XBim.Interop to 5.1.387-develop but as soon as I want to init a new XBimGeometryEngine I've the same not implemented exception

---> (Exception interne #0) System.IO.FileLoadException: Failed to load Xbim.Geometry.Engine64.dll ---> System.TypeLoadException: La méthode 'CreateShapeGeometry' du type 'Xbim.Geometry.XbimGeometryCreator' de l'assembly 'Xbim.Geometry.Engine64, Version=0.0.0.0, Culture=neutral, PublicKeyToken=11e3655e576ec5a9' n'a pas d'implémentation. à System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type) à System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) à Xbim.Geometry.Engine.Interop.XbimGeometryEngine..ctor(ILogger1 logger) à Xbim.Geometry.Engine.Interop.XbimGeometryEngine..ctor(ILogger1 logger)

OlivierC-A3d avatar Oct 21 '20 07:10 OlivierC-A3d

Weird. I'll take a look...

andyward avatar Oct 21 '20 14:10 andyward

OK. It's fine in Develop -as long as you use the latest Myget develop dependencies. But don't mix and match develop and master (or nuget) dependencies

There's been a breaking change to an interface in Essentials develop code that has made it to master in Essential 5.1.314, but Geometry has not yet been merged from develop. So the latest of master dependencies will fail.

See https://github.com/xBimTeam/XbimEssentials/commit/ed243e9229399619ef4ef9c42069fcbe855f9dbc

For now: When picking up Myget dependencies:

On master: Install Essentials < 3.1.14 On develop: install the latest versions of develop dependencies

To do:

  • [x] Fix up Geometry master build (WIP)
  • [ ] Bump versions to 5.2 as we have a breaking interface
  • [ ] Merge Geometry master to develop ASAP

andyward avatar Oct 23 '20 12:10 andyward

Ok I see ! That was a nasty issue ! I'll try with versions of your comment for the original bug 👍

OlivierC-A3d avatar Oct 23 '20 12:10 OlivierC-A3d

For the very latest I would use:

Essentials : 5.1.312-develop Geometry: 5.1.387-develop

If you still have the SEHException with that we'll have to investigate

andyward avatar Oct 23 '20 12:10 andyward

Ok I've put all XBim dependencies to 5.1.312-develop and Geometry to 5.1.387-develop.

First I've noticed after a clean solution directory that the Engine32 and Engine64 dll were not copied to my output folder but that should be relative to new "net472" folder. If you look closely Dll's are sitting in the old folder "packages\Xbim.Geometry.Engine.Interop.5.1.387-develop\build\net47"

I'vent checked if it's my side to adapt this change or not.

After manually copying them I can confirm the original Bug SEHException is gone. I'll be waiting a clean "release" version of all dependencies.

OlivierC-A3d avatar Oct 23 '20 13:10 OlivierC-A3d

Hmm maybe it's the "net47" references in Xbim.Geometry.Engine.Interop.csproj should match the same framework output folder "net472" ?

OlivierC-A3d avatar Oct 23 '20 13:10 OlivierC-A3d

The move to net472 in geometry is also very recent - Our CI build server started failing on the Geometry builds (we surmise because of an update to the VC SDKs).

This may have had a knock on with deployment - will investigate that separately

andyward avatar Oct 23 '20 15:10 andyward

Hello, I think I am experiencing the same problem. The stacktrace is not always the same and sometimes the Xbim3DModelContext::CreateContext() call completes fine (for the same IFC file it failed before). My rough guess would be some thread-safety issue. The error is always the same System.AccessViolationException: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt.".

I have upgraded to version 5.1.403 to see whether this would be already resolved, but unfortunately the behavior is still the same.

Best regards, Joe

StackTrace 1:

   at TopLoc_SListOfItemLocation.Assign(TopLoc_SListOfItemLocation* , TopLoc_SListOfItemLocation* )
   at TopoDS_Shape.=(TopoDS_Shape* , TopoDS_Shape* A_0)
   at Xbim.Geometry.XbimWire.Init(IIfcCompositeCurveSegment compCurveSeg, ILogger logger, XbimConstraints constraints)
   at Xbim.Geometry.XbimWire..ctor(IIfcCompositeCurveSegment compCurveSeg, ILogger logger, XbimConstraints constraints)
   at Xbim.Geometry.XbimWire.Init(IIfcCompositeCurve compCurve, ILogger logger, XbimConstraints constraints)
   at Xbim.Geometry.XbimWire.Init(IIfcCurve loop, ILogger logger, XbimConstraints constraints)
   at Xbim.Geometry.XbimWire..ctor(IIfcCurve loop, ILogger logger, XbimConstraints constraints)
   at Xbim.Geometry.XbimWire.Init(IIfcArbitraryClosedProfileDef profile, ILogger logger, XbimConstraints constraints)
   at Xbim.Geometry.XbimWire.Init(IIfcProfileDef profile, ILogger logger, XbimConstraints constraints)
   at Xbim.Geometry.XbimWire..ctor(IIfcProfileDef profile, ILogger logger, XbimConstraints constraints)
   at Xbim.Geometry.XbimFace.Init(IIfcProfileDef profile, ILogger logger)
   at Xbim.Geometry.XbimFace..ctor(IIfcProfileDef profile, ILogger logger)
   at Xbim.Geometry.XbimSolid.Init(IIfcExtrudedAreaSolid solid, IIfcProfileDef overrideProfileDef, ILogger logger)
   at Xbim.Geometry.XbimSolid..ctor(IIfcExtrudedAreaSolid solid, ILogger logger)
   at Xbim.Geometry.XbimGeometryCreator.CreateSolid(IIfcExtrudedAreaSolid ifcSolid, ILogger logger)
   at Xbim.Geometry.XbimGeometryCreator.CreateSolid(IIfcSweptAreaSolid ifcSolid, ILogger logger)
   at Xbim.Geometry.XbimGeometryCreator.Create(IIfcGeometricRepresentationItem geomRep, IIfcAxis2Placement3D objectLocation, ILogger logger)
   at Xbim.Geometry.Engine.Interop.XbimGeometryEngine.Create(IIfcGeometricRepresentationItem ifcRepresentation, ILogger logger) in C:\buildagent_os\_work\1\s\Xbim.Geometry.Engine.Interop\XbimGeometryEngine.cs:line 74
   at Xbim.ModelGeometry.Scene.Xbim3DModelContext.<>c__DisplayClass39_0.<WriteShapeGeometries>b__0(Int32 shapeId) in C:\buildagent_os\_work\1\s\Xbim.ModelGeometry.Scene\Xbim3DModelContext.cs:line 1373
   at System.Threading.Tasks.Parallel.<>c__DisplayClass42_0`2.<PartitionerForEachWorker>b__1()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
   at System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object <p0>)
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   at System.Threading.Tasks.Task.ExecutionContextCallback(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
   at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

StackTrace 2:

   at BRepBuilderAPI_MakeFace.{ctor}(BRepBuilderAPI_MakeFace* , TopoDS_Wire* , Boolean )
   at Xbim.Geometry.XbimSolid.Init(IIfcPolygonalBoundedHalfSpace solid, ILogger logger)
   at Xbim.Geometry.XbimSolid.Init(IIfcHalfSpaceSolid solid, ILogger logger)
   at Xbim.Geometry.XbimSolid..ctor(IIfcHalfSpaceSolid solid, ILogger logger)
   at Xbim.Geometry.XbimSolidSet.Init(IIfcBooleanOperand boolOp, ILogger logger)
   at Xbim.Geometry.XbimSolidSet.Init(IIfcBooleanClippingResult solid, ILogger logger)
   at Xbim.Geometry.XbimSolidSet.Init(IIfcBooleanResult boolOp, ILogger logger)
   at Xbim.Geometry.XbimSolidSet..ctor(IIfcBooleanResult boolOp, ILogger logger)
   at Xbim.Geometry.XbimGeometryCreator.Create(IIfcGeometricRepresentationItem geomRep, IIfcAxis2Placement3D objectLocation, ILogger logger)
   at Xbim.Geometry.Engine.Interop.XbimGeometryEngine.Create(IIfcGeometricRepresentationItem ifcRepresentation, ILogger logger) in C:\buildagent_os\_work\1\s\Xbim.Geometry.Engine.Interop\XbimGeometryEngine.cs:line 74
   at Xbim.ModelGeometry.Scene.Xbim3DModelContext.<>c__DisplayClass39_0.<WriteShapeGeometries>b__0(Int32 shapeId) in C:\buildagent_os\_work\1\s\Xbim.ModelGeometry.Scene\Xbim3DModelContext.cs:line 1373
   at System.Threading.Tasks.Parallel.<>c__DisplayClass42_0`2.<PartitionerForEachWorker>b__1()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
   at System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object <p0>)
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   at System.Threading.Tasks.Task.ExecutionContextCallback(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
   at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

StackTrace 3:

   at BRepPrimAPI_MakeHalfSpace.{ctor}(BRepPrimAPI_MakeHalfSpace* , TopoDS_Face* , gp_Pnt* )
   at Xbim.Geometry.XbimSolid.Init(IIfcHalfSpaceSolid solid, ILogger logger)
   at Xbim.Geometry.XbimSolid..ctor(IIfcHalfSpaceSolid solid, ILogger logger)
   at Xbim.Geometry.XbimSolidSet.Init(IIfcBooleanOperand boolOp, ILogger logger)
   at Xbim.Geometry.XbimSolidSet.Init(IIfcBooleanClippingResult solid, ILogger logger)
   at Xbim.Geometry.XbimSolidSet.Init(IIfcBooleanResult boolOp, ILogger logger)
   at Xbim.Geometry.XbimSolidSet..ctor(IIfcBooleanResult boolOp, ILogger logger)
   at Xbim.Geometry.XbimGeometryCreator.Create(IIfcGeometricRepresentationItem geomRep, IIfcAxis2Placement3D objectLocation, ILogger logger)
   at Xbim.Geometry.Engine.Interop.XbimGeometryEngine.Create(IIfcGeometricRepresentationItem ifcRepresentation, ILogger logger) in C:\buildagent_os\_work\1\s\Xbim.Geometry.Engine.Interop\XbimGeometryEngine.cs:line 74
   at Xbim.ModelGeometry.Scene.Xbim3DModelContext.<>c__DisplayClass39_0.<WriteShapeGeometries>b__0(Int32 shapeId) in C:\buildagent_os\_work\1\s\Xbim.ModelGeometry.Scene\Xbim3DModelContext.cs:line 1373
   at System.Threading.Tasks.Parallel.<>c__DisplayClass42_0`2.<PartitionerForEachWorker>b__1()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
   at System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object <p0>)
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   at System.Threading.Tasks.Task.ExecutionContextCallback(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
   at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

jokusoftware avatar Jan 05 '21 17:01 jokusoftware

@jokusoftware I experienced the same stack with one of my IFC

at BRepPrimAPI_MakePrism.{ctor}(BRepPrimAPI_MakePrism* , TopoDS_Shape* , gp_Vec* , Boolean , Boolean ) at Xbim.Geometry.XbimSolid.Init(IIfcExtrudedAreaSolid solid, IIfcProfileDef overrideProfileDef, ILogger logger) at Xbim.Geometry.XbimSolid..ctor(IIfcExtrudedAreaSolid solid, ILogger logger) at Xbim.Geometry.XbimGeometryCreator.CreateSolid(IIfcExtrudedAreaSolid ifcSolid, ILogger logger) at Xbim.Geometry.XbimGeometryCreator.Create(IIfcGeometricRepresentationItem geomRep, IIfcAxis2Placement3D objectLocation, ILogger logger) at Xbim.Geometry.Engine.Interop.XbimGeometryEngine.Create(IIfcGeometricRepresentationItem ifcRepresentation, ILogger logger)

With Xbim.Essentials 5.1.314 Xbim.Geometry.Engine.Interop 5.1.401

After checking for update, error is still here with a different message (IFC was working before)

Xbim.Essentials 5.1.323 Xbim.Geometry.Engine.Interop 5.1.403

General Error Creating IfcExtrudedAreaSolid, #22340 at Xbim.Geometry.XbimGeometryCreator.Create(IIfcGeometricRepresentationItem geomRep, IIfcAxis2Placement3D objectLocation, ILogger logger) at Xbim.Geometry.Engine.Interop.XbimGeometryEngine.Create(IIfcGeometricRepresentationItem ifcRepresentation, ILogger logger)

OlivierC-A3d avatar Jan 22 '21 14:01 OlivierC-A3d

Ca you provide a minimal data example @OlivierC-A3d?

martin1cerny avatar Jan 22 '21 14:01 martin1cerny

Ca you provide a minimal data example @OlivierC-A3d?

Hopefully yes ! Here is an IFC I can share that produces the stack exemple_crash.zip

OlivierC-A3d avatar Jan 22 '21 14:01 OlivierC-A3d

Ca you provide a minimal data example @OlivierC-A3d?

Hello, do you have any news regarding the issue with the provided sample ?

Regards,

OlivierC-A3d avatar Feb 26 '21 12:02 OlivierC-A3d

I confirm it is this slab which is failing: image

There seem to be a problem with the composite curve defining the extrusion profile.

Minimal file: exemple_crash.extracted.zip

martin1cerny avatar Feb 26 '21 14:02 martin1cerny

This one is fixed by applying the same changes to XbimFace.cpp as in #288 See attached XbimFace.cpp (downloaded/modfied from master as of 2021-04-28, i.e. today) Search for "DALMAN - skip return and let ShapeFix_Edge do some work below" (without the ", three places). For background, read my comment in #288 . I cannot be 100% sure that this doesn't break anything else, and I'm not entirely sure why it actually works, but I've used this fix for quite some time now and I haven't seen any negative effects. Sorry for no PR, but it should be easy to add for Martin, Steve, or Claudio.

XbimFace.zip

/Mikael

jomijomi avatar Apr 28 '21 23:04 jomijomi

Hi,

Any news regarding this error or patch suggested ? I can't upgrade librairies due to this error. I tested with XBimExplorer (5.1.430 assembly) solution from Git and the test IFC file is still crashing

Regards

OlivierC-A3d avatar Aug 12 '21 09:08 OlivierC-A3d

Hello, as a workaround I am forcing a single thread processing (context.MaxThreads = 1), that way it does not crash. The processing is much slower though.

Joe

jokusoftware avatar Aug 12 '21 10:08 jokusoftware

Ok hope patch will be released soon, single thread is a no go for me considering sizes of IFC

OlivierC-A3d avatar Aug 12 '21 11:08 OlivierC-A3d