I am encountering a ReadOnlyMemoryError() when calling create_mesh on Windows 64-bit. Despite successfully compiling the underlying libtesselate.dll using Visual Studio 2019 Build Tools, the process crashes as soon as the C library is invoked. Please note that your package perfectly works on my Linux Mint machine.
Steps to Reproduce:
using TriangleMesh
poly = polygon_Lshape()
mesh = create_mesh(poly, "pq") # Crashes here
Error output:
ERROR: ReadOnlyMemoryError()
Stacktrace:
[1]
@ TriangleMesh \.julia\packages\TriangleMesh\nRk7h\src\TriangleMesh_create_mesh.jl:14
[2] #create_mesh#7
@ \.julia\packages\TriangleMesh\nRk7h\src\TriangleMesh_create_mesh.jl:227 [inlined]
[3] create_mesh(poly::Polygon_pslg, switches::String)
@ TriangleMesh \.julia\packages\TriangleMesh\nRk7h\src\TriangleMesh_create_mesh.jl:216
[4] top-level scope
@ REPL[3]:1
Some type information was truncated. Use `show(err)` to see complete types.
Troubleshooting Conducted So Far
We have attempted to rule out compilation and architecture mismatches with the following steps:
-
Toolchain Update: Modified compile.bat to use Visual Studio 2019 (v16.11) environment variables (vcvarsall.bat x64) instead of the default 2017 settings.
-
Bitness Alignment: * Removed the /DCPU86 flag from makefile.win, which was forcing 32-bit logic.Added /D_WIN64 and /DANSI_DECLARATORS to CFLAGS. Verified via dumpbin /headers that the resulting libtesselate.dll is indeed a native x64 binary.
-
Pointer Truncation Fixes: Noticed significant C4311 and C4312 warnings (pointer truncation) during compilation of triangle.c.
Attempted to suppress/handle these using compiler flags, but the ReadOnlyMemoryError() persists in Julia.
-
Manual Deployment: Verified that the DLL is correctly placed in deps/usr/lib/ and is being loaded by Julia, but the crash occurs during the memory transfer between Julia and the C-struct triangulateio.
Suspected Cause:
It appears there is a memory alignment or pointer-size mismatch between the Julia mutable struct definitions in TriangleMesh_create_mesh.jl and the C struct triangulateio defined in triangle.h. On Windows 64-bit, the C library may expect 8-byte alignment or different integer sizes for indices than what the Julia wrapper passes via ccall.
Thank you.
I am encountering a ReadOnlyMemoryError() when calling create_mesh on Windows 64-bit. Despite successfully compiling the underlying libtesselate.dll using Visual Studio 2019 Build Tools, the process crashes as soon as the C library is invoked. Please note that your package perfectly works on my Linux Mint machine.
Steps to Reproduce:
Error output:
Troubleshooting Conducted So Far
We have attempted to rule out compilation and architecture mismatches with the following steps:
Toolchain Update: Modified compile.bat to use Visual Studio 2019 (v16.11) environment variables (vcvarsall.bat x64) instead of the default 2017 settings.
Bitness Alignment: * Removed the /DCPU86 flag from makefile.win, which was forcing 32-bit logic.Added /D_WIN64 and /DANSI_DECLARATORS to CFLAGS. Verified via dumpbin /headers that the resulting libtesselate.dll is indeed a native x64 binary.
Pointer Truncation Fixes: Noticed significant C4311 and C4312 warnings (pointer truncation) during compilation of triangle.c.
Attempted to suppress/handle these using compiler flags, but the ReadOnlyMemoryError() persists in Julia.
Manual Deployment: Verified that the DLL is correctly placed in deps/usr/lib/ and is being loaded by Julia, but the crash occurs during the memory transfer between Julia and the C-struct triangulateio.
Suspected Cause:
It appears there is a memory alignment or pointer-size mismatch between the Julia mutable struct definitions in TriangleMesh_create_mesh.jl and the C struct triangulateio defined in triangle.h. On Windows 64-bit, the C library may expect 8-byte alignment or different integer sizes for indices than what the Julia wrapper passes via ccall.
Thank you.