mcneel / compute.rhino3d

REST geometry server based on RhinoCommon and headless Rhino
Other
302 stars 189 forks source link

Exception raised on `/rhino/geometry/areamassproperties/compute-brep_bool_bool_bool_bool ` compute server #124

Closed highway900 closed 4 years ago

highway900 commented 4 years ago

Hi,

We ran into this exception when using the compute server which was self hosted. Any ideas what might be causing it?

This is a script that will cause the issue.

import rhino3dm
import compute_rhino3d.Util
import compute_rhino3d.AreaMassProperties

compute_rhino3d.Util.apiKey = "1234"
compute_rhino3d.Util.url = "http://ip.com"
start = rhino3dm.Point3d(250, 250, 0)
end = rhino3dm.Point3d(0, 0, 0)
crv = rhino3dm.Curve.CreateControlPointCurve([start,end],1)
extru = rhino3dm.Extrusion.Create( crv, 500, False)
massProps = compute_rhino3d.AreaMassProperties.Compute6( extru, True, False, False, False )

Running this script causes the compute server to crash with this exception

[2020-10-16T02:54:55.5242837+00:00] "POST /rhino/geometry/areamassproperties/compute-brep_bool_bool_bool_bool HTTP/1.1" 200 -

Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at UnsafeNativeMethods.ON_Brep_SetTolerancesBoxesAndFlags(IntPtr pBrep, Boolean bLazy, Boolean bSetVertexTolerances, Boolean bSetEdgeTolerances, Boolean bSetTrimTolerances, Boolean bSetTrimIsoFlags, Boolean bSetTrimTypeFlags, Boolean bSetLoopTypeFlags, Boolean bSetTrimBoxes)
   at Rhino.Geometry.Brep..ctor(SerializationInfo info, StreamingContext context)
   at Void .ctor(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)(Object[] )
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateISerializable(JsonReader reader, JsonISerializableContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
   at compute.geometry.GeometryEndPoint.HandlePostHelper(JArray ja, Dictionary`2 returnModifiers) in C:\projects\compute-rhino3d\src\compute.geometry\GeometryEndPoint.cs:line 472
   at compute.geometry.GeometryEndPoint.Post(NancyContext context) in C:\projects\compute-rhino3d\src\compute.geometry\GeometryEndPoint.cs:line 385
   at compute.geometry.RhinoPostModule.<>c__DisplayClass0_0.<.ctor>b__0(Object _) in C:\projects\compute-rhino3d\src\compute.geometry\Program.cs:line 163
   at Nancy.Routing.Route.<>c__DisplayClass4.<Wrap>b__3(Object parameters, CancellationToken context)
   at Nancy.Routing.Route.Invoke(DynamicDictionary parameters, CancellationToken cancellationToken)
   at Nancy.Routing.DefaultRouteInvoker.Invoke(Route route, CancellationToken cancellationToken, DynamicDictionary parameters, NancyContext context)
   at Nancy.Routing.DefaultRequestDispatcher.<>c__DisplayClass2.<Dispatch>b__0(Task`1 completedTask)
   at Nancy.Routing.DefaultRequestDispatcher.Dispatch(NancyContext context, CancellationToken cancellationToken)
   at Nancy.NancyEngine.<>c__DisplayClasse.<InvokeRequestLifeCycle>b__c(Task`1 t)
   at Nancy.NancyEngine.InvokeRequestLifeCycle(NancyContext context, CancellationToken cancellationToken, IPipelines pipelines)
   at Nancy.NancyEngine.HandleRequest(Request request, Func`2 preRequest, CancellationToken cancellationToken)
   at Nancy.NancyEngineExtensions.HandleRequest(INancyEngine nancyEngine, Request request, Func`2 preRequest, Action`1 onComplete, Action`1 onError, CancellationToken cancellationToken)
   at Nancy.Owin.NancyMiddleware.<>c__DisplayClass4.<>c__DisplayClass6.<UseNancy>b__1(IDictionary`2 environment)
   at compute.geometry.LoggingMiddleware.<Invoke>d__1.MoveNext() in C:\projects\compute-rhino3d\src\compute.geometry\Startup.cs:line 33
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at compute.geometry.LoggingMiddleware.Invoke(IOwinContext ctx)
   at Microsoft.Owin.Cors.CorsMiddleware.<Invoke>d__4.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Owin.Cors.CorsMiddleware.Invoke(IDictionary`2 environment)
   at Microsoft.Owin.Hosting.Utilities.Encapsulate.Invoke(IDictionary`2 environment)
   at Microsoft.Owin.Host.HttpListener.OwinHttpListener.<ProcessRequestAsync>d__30.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Owin.Host.HttpListener.OwinHttpListener.ProcessRequestAsync(HttpListenerContext context)
   at Microsoft.Owin.Host.HttpListener.OwinHttpListener.<ProcessRequestsAsync>d__29.MoveNext()
   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.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run()
   at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(Action action, Boolean allowInlining, Task& currentTask)
   at System.Threading.Tasks.Task.FinishContinuations()
   at System.Threading.Tasks.Task`1.TrySetResult(TResult result)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
   at System.Threading.Tasks.TaskFactory`1.<>c__DisplayClass35_0.<FromAsyncImpl>b__0(IAsyncResult iar)
   at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
   at System.Net.ListenerAsyncResult.IOCompleted(ListenerAsyncResult asyncResult, UInt32 errorCode, UInt32 numBytes)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
mcneel-build commented 4 years ago

Linked with COMPUTE-136

sbaer commented 4 years ago

That endpoint is expecting a Brep instead of an extrusion. You can change your code to pass a brep like the following

brep = extru.ToBrep(True)
massProps = compute_rhino3d.AreaMassProperties.Compute6( brep, True, False, False, False )

I'm not closing this issue yet as I would still like to fix the memory error occurring on compute