I’ve tried to compile OpenNurbs 7 (this version) as a DLL on Windows. When linking with a simple program that just calls
ON::Begin(); ON::End();, I am hitting a write access exception in the
ON_StackedText destructor (link).
The destructor is being called on
ON_StackedText::Empty (defined here; constructed here).
ON_StackedText::Empty is a
static const, so it is placed in a read-only section of the DLL (
.rdata). As a result, when the program tries to write to the const object’s member
m_top_run, a write access exception is triggered, because a write is being attempted on a read-only memory page.
Here is a git repository that reproduces the issue on my machine: pelletier/opennurbs-write-bug. I’m running MSVC 14.25.28610 (from Visual Studio 2019) on Windows 10.
I have two pretty ugly workarounds at the moment (without patching OpenNurbs):
- make the page where
ON_StackedText::Emptyis stored writable (patch).
- have the linker make the DLL’s
.rdatasection writable (patch).
Can you confirm this is a bug or am I building it wrong?