Serializing Hatch crashes Rhino when debugged by VS & Tibidabo is loaded

The Tibidabo plugin is shipped with Land Design.

How to replicate:

  1. Make Tibidabo not to load on startup by disabling Land Design.
  2. Start Rhino in the debugger mode, from Visual Studio (as I am debugging my Grasshopper plugin)
  3. Draw a solid hatch
  4. Try to use BinaryFormatter.Serialize to serialize a Hatch geometry, which is retrieved by HatchObject.HatchGeometry
  5. The operation succeeds
  6. Load Tibidabo manually by entering its command, e.g. tbAudit
  7. Redo steps 3-5
  8. Rhino crashses

I can see something weird happened inside openNurbs. I don’t know if it’s because Tibidabo’s anti-debugger code.

Captured stack

0000004f`f5bcdcc8 00007ff8`d980da02 KERNELBASE!DebugBreak+0x2
0000004f`f5bcdcd0 00007ff8`8abe88bf opennurbs!ON_ErrorEx+0x18f
0000004f`f5bcde00 00007ff8`8ad1067d opennurbs!ON_BinaryArchive::Write3dmReferencedComponentIndex+0x18d
0000004f`f5bcde30 00007ff8`8ac462c1 opennurbs!ON_Hatch::Write+0xd1
0000004f`f5bcdeb0 00007ff8`8aacb83f opennurbs!ON_BinaryArchive::Internal_WriteObject+0xef
0000004f`f5bcdf10 00007ff8`8aacb3e7 opennurbs!ON_BinaryArchive::WriteObject+0x757
0000004f`f5bcdff0 00007ff8`899d3198 rhcommon_c!ON_WriteBufferArchive_NewWriter+0xf8
0000004f`f5bce060 00007ff8`50a33842 unknown!noop+0x0
0000004f`f5bce120 00007ff8`50a335c2 unknown!unknown+0x0
0000004f`f5bce1e0 00007ff8`50a334af unknown!unknown+0x0
0000004f`f5bce220 00007ff8`a24c80ba mscorlib_ni+0x5c80ba
0000004f`f5bce2a0 00007ff8`a24c7e4d mscorlib_ni+0x5c7e4d
0000004f`f5bce320 00007ff8`a24c7727 mscorlib_ni+0x5c7727
0000004f`f5bce3c0 00007ff8`a24c71f6 mscorlib_ni+0x5c71f6
0000004f`f5bce440 00007ff8`a24ea056 mscorlib_ni+0x5ea056
0000004f`f5bce470 00007ff8`50a309ae unknown!unknown+0x0
0000004f`f5bce6b0 00007ff8`50a2feb7 unknown!unknown+0x0
0000004f`f5bce7a0 00007ff8`50a2fbd3 unknown!unknown+0x0
0000004f`f5bce7f0 00007ff8`50a27a1a unknown!unknown+0x0
0000004f`f5bce910 00007ff8`50a0542c unknown!unknown+0x0
0000004f`f5bce9c0 00007ff8`50a03dbc unknown!unknown+0x0
0000004f`f5bcead0 00007ff8`50a2e6eb unknown!unknown+0x0
0000004f`f5bceb10 00007ff8`504ac198 unknown!unknown+0x0
0000004f`f5bceb40 00007ff8`504abad0 unknown!unknown+0x0
0000004f`f5bcec40 00007ff8`4d9edbb3 unknown!unknown+0x0
0000004f`f5bced00 00007ff8`abd5c0ab System_Windows_Forms_ni+0xa5c0ab
0000004f`f5bced40 00007ff8`abd607cd System_Windows_Forms_ni+0xa607cd
0000004f`f5bcedc0 00007ff8`ab5b11ec System_Windows_Forms_ni+0x2b11ec
0000004f`f5bcee80 00007ff8`ab5b00a2 System_Windows_Forms_ni+0x2b00a2
0000004f`f5bcef20 00007ff8`abce5382 System_Windows_Forms_ni+0x9e5382
0000004f`f5bcef90 00007ff8`ad0321fe clr+0x21fe
0000004f`f5bcf020 00007ff8`dc4674d6 user32!DispatchMessageW+0x6a6
0000004f`f5bcf1a0 00007ff8`dc466ff2 user32!DispatchMessageW+0x1c2
0000004f`f5bcf220 00007ff8`a571c182 mfc140u+0x27c182
0000004f`f5bcf250 00007ff8`a571ca85 mfc140u+0x27ca85
0000004f`f5bcf290 00007ff8`7ed0e5b4 RhinoCore!RhRunMessageLoop+0x164
0000004f`f5bcfc70 00007ff6`dc4a1072 Rhino+0x1072
0000004f`f5bcfcb0 00007ff6`dc4a129e Rhino+0x129e
0000004f`f5bcfcf0 00007ff8`dc307974 kernel32!BaseThreadInitThunk+0x14
0000004f`f5bcfd20 00007ff8`dc9da261 ntdll!RtlUserThreadStart+0x21

Rhino’s version & system info

Rhino 6 SR26 2020-5-26 (Rhino 6, 6.26.20147.06511, Git hash:master @ 7788f6214ee9335d5793cc6177985a1c745e663b)
License type: 教育版, 版本2020-05-26 (Educational)
License details: Cloud Zoo.  In use by: Keyu ()

Windows 10.0 SR0.0 or greater (Physical RAM: 16Gb)
Machine name: xxxxx

Non-hybrid graphics.
Primary display and OpenGL: NVIDIA GeForce GTX 1050 (NVidia) Memory: 2GB, Driver date: 7-24-2019 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 432.00

OpenGL Settings
  Safe mode: Off
  Use accelerated hardware modes: On
  Redraw scene when viewports are exposed: On
  
  Anti-alias mode: 4x
  Mip Map Filtering: Linear
  Anisotropic Filtering Mode: Height
  
  Vendor Name: NVIDIA Corporation
  Render version: 4.6
  Shading Language: 4.60 NVIDIA
  Driver Date: 5-22-2019
  Driver Version: 26.21.14.3086
  Maximum Texture size: 32768 x 32768
  Z-Buffer depth: 24 bits
  Maximum Viewport size: 32768 x 32768
  Total Video Memory: 2 GB

Rhino plugins
  C:\Program Files\Rhino 6\Plug-ins\Commands.rhp	"Commands"	6.26.20147.6511
  C:\Program Files\Rhino 6\Plug-ins\WebBrowser.rhp	"WebBrowser"	
  C:\Program Files\Rhino 6\Plug-ins\rdk.rhp	"Renderer Development Kit"	
  C:\Program Files\Rhino 6\Plug-ins\RhinoScript.rhp	"RhinoScript"	
  C:\Program Files\Rhino 6\Plug-ins\RhinoBonusTools.rhp	"Rhino Bonus Tools"	
  C:\Program Files\Rhino 6\Plug-ins\IdleProcessor.rhp	"IdleProcessor"	
  C:\Program Files\Rhino 6\Plug-ins\Tibidabo\Tibidabo.rhp	"Tibidabo"	
  C:\Program Files\Rhino 6\Plug-ins\RhinoRender.rhp	"Rhino Render"	
  C:\Program Files\Rhino 6\Plug-ins\rdk_etoui.rhp	"RDK_EtoUI"	6.26.20147.6511
  C:\Program Files\Rhino 6\Plug-ins\rdk_ui.rhp	"Renderer Development Kit UI"	
  C:\Program Files\Rhino 6\Plug-ins\NamedSnapshots.rhp	"Snapshots"	
  C:\Program Files\Rhino 6\Plug-ins\Alerter.rhp	"Alerter"	
  C:\Program Files\Rhino 6\Plug-ins\RhinoCycles.rhp	"RhinoCycles"	6.26.20147.6511
  C:\Program Files\Rhino 6\Plug-ins\Toolbars\Toolbars.rhp	"Toolbars"	6.26.20147.6511
  C:\Program Files\Rhino 6\Plug-ins\3dxrhino.rhp	"3Dconnexion 3D Mouse"	
  C:\Program Files\Rhino 6\Plug-ins\Displacement.rhp	"Displacement"	

@enric - is this something you guys can look into?
-wim

Hi @wim,

Sure, I’ll take a look.

Thanks,

Enric

btw fyi I’m using VS 16.5.0

Microsoft Visual Studio Community 2019
Version 16.5.0
VisualStudio.16.Release/16.5.0+29911.84
Microsoft .NET Framework
Version 4.8.03761

Installed Version: Community

Visual C++ 2019   00435-60000-00000-AA578
Microsoft Visual C++ 2019

ASP.NET and Web Tools 2019   16.5.236.49856
ASP.NET and Web Tools 2019

Azure App Service Tools v3.0.0   16.5.236.49856
Azure App Service Tools v3.0.0

C# Tools   3.5.0-beta4-20153-05+20b9af913f1b8ce0a62f72bea9e75e4aa3cf6b0e
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Cookiecutter   16.5.20041.1
Provides tools for finding, instantiating and customizing templates in cookiecutter format.

GitHub.VisualStudio   2.11.36.32419
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

IntelliCode Extension   1.0
IntelliCode Visual Studio Extension Detailed Info

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30207.1

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

NuGet Package Manager   5.5.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

Python   16.5.20041.1
Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.

Python - Conda support   16.5.20041.1
Conda support for Python projects.

Python - Django support   16.5.20041.1
Provides templates and integration for the Django web framework.

Python - IronPython support   16.5.20041.1
Provides templates and integration for IronPython-based projects.

Python - Profiling support   16.5.20041.1
Profiling support for Python projects.

ResXManager   1.40.3444.0
Manage localization of all ResX-Based resources in one place. Shows all resources of a solution and let's you edit the strings and their localizations in a well-arranged data grid.

TypeScript Tools   16.0.20225.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   3.5.0-beta4-20153-05+20b9af913f1b8ce0a62f72bea9e75e4aa3cf6b0e
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.8.0.0 for F# 4.7   16.5.0-beta.20104.8+7c4de19faf36647c1ef700e655a52350840c6f03
Microsoft Visual F# Tools 10.8.0.0 for F# 4.7

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for CMake   1.0
Visual Studio Tools for CMake

Hi @gankeyu,

I found the problem: Tibidabo is enabling OpenNURBS error checking when a debugger is present. We added this code to detect errors, even when testing VisualARQ and Lands on Release builds of Rhino. The problem is that this code should be disabled on public builds, and it wasn’t.

Then, regarding why an exception is thrown when you are serializing a hatch, this is because an error happens each time hatch is serialized outside a write 3DM operation because the ON_ManifestMap is missing and the pattern index cannot be converted to archive index. This is completely unrelated t Tibidabo. You can also reproduce the crash by enabling error checking: run command TestErrorCheck, set command option BreakOnError to Always, and then try to serialize the hatch again (without Tibidabo being loaded).

Anyway, I’ve fixed the issue in VisualARQ 2.8.3 and Lands 5.1.3.

Regards,

Enric

1 Like