FaceDescriptor class bug?

It seems that there is a bug in the class Facedescriptor. The following C++ code throws an access violation exception on the last instruction.

Mesh mesh;
FaceDescriptor fd;
mesh.AddFaceDescriptor(fd);

I think that it can be re related to a missing implementation of the operator=.
Do you have any ideas?

More details here.

Thanks,
Stenio

I cannot reproduce the problem, can you try the attached mini-example?
I compile using the ngsolve compiler wrapper ngscxx / linker wrapper ngsld.
The output is:

moveable = 0
copyable = 0
have fd

Since it is not trivially moveable, I wonder why memmove shall be called.

Joachim

testfd.cpp (424 Bytes)

Hi,

I tried the example in Visual Studio and it gave me the reported exception.
I have some problem compiling the example with the wrapper:

$ ./ngscxx.bat -c testfd.cpp

C:\Users\Ste\Desktop\Temp\TEMPVM\netgen-src\install\bin>set NGSCXX_DIR=C:\Users\Ste\Desktop\Temp\TEMPVM\netgen-src\install\bin\

C:\Users\Ste\Desktop\Temp\TEMPVM\netgen-src\install\bin>call "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Auxiliary/Build/vcvarsall.bat" amd64
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.8.7
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
Microsoft (R) C/C++ Optimizing Compiler versione 19.38.33135 per x64
Copyright (C) Microsoft Corporation. Tutti i diritti  sono riservati.

testfd.cpp

The ouput of the command is a file named testfd.obj, so I changed the linker command accordingly:

$ ./ngsld.bat testfd.obj -lnglib -o testfd

C:\Users\Ste\Desktop\Temp\TEMPVM\netgen-src\install\bin>set NGSCXX_DIR=C:\Users\Ste\Desktop\Temp\TEMPVM\netgen-src\install\bin\

C:\Users\Ste\Desktop\Temp\TEMPVM\netgen-src\install\bin>call "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Auxiliary/Build/vcvarsall.bat" amd64
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.8.7
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
Microsoft (R) Incremental Linker Version 14.38.33135.0
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : warning LNK4044: opzione '/lnglib' non riconosciuta; verr… ignorata
LINK : warning LNK4044: opzione '/o' non riconosciuta; verr… ignorata
testfd.obj : warning LNK4042: oggetto specificato pi— di una volta; occorrenze supplementari ignorate

Unfortunatelly it produces a dll file instead of an exe.
I am trying to figure out what are the options syntax for this linker.

Thanks,
Stenio

I tried changing the parameters with no luck:

$ ./ngsld.bat testfd.obj nglib.dll -OUT:testfd.exe

C:\Users\Ste\Desktop\Temp\TEMPVM\netgen-src\install\bin>set NGSCXX_DIR=C:\Users\Ste\Desktop\Temp\TEMPVM\netgen-src\install\bin\

C:\Users\Ste\Desktop\Temp\TEMPVM\netgen-src\install\bin>call "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Auxiliary/Build/vcvarsall.bat" amd64
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.8.7
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
Microsoft (R) Incremental Linker Version 14.38.33135.0
Copyright (C) Microsoft Corporation.  All rights reserved.

nglib.dll : fatal error LNK1107: file danneggiato o non valido: impossibile leggere in 0x380

With this command line I was able to link:

$ ./ngsld.bat testfd.obj -OUT:testfd.exe

C:\Users\Ste\Desktop\Temp\TEMPVM\netgen-src\install\bin>set NGSCXX_DIR=C:\Users\Ste\Desktop\Temp\TEMPVM\netgen-src\install\bin\

C:\Users\Ste\Desktop\Temp\TEMPVM\netgen-src\install\bin>call "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Auxiliary/Build/vcvarsall.bat" amd64
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.8.7
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
Microsoft (R) Incremental Linker Version 14.38.33135.0
Copyright (C) Microsoft Corporation.  All rights reserved.

But if I try to execute the program I get this error:

$ ./testfd.exe
bash: ./testfd.exe: cannot execute binary file: Exec format error

Hope this helps.

Thanks,
Stenio

Ok, there was the option /DLL specified on the ngsld.bat file. I removed it and linked with this command:

$ ./ngsld.bat -OUT:testfd.exe testfd.obj -SUBSYSTEM:CONSOLE

Now I can run the program and this is the result:

$ ./testfd.exe
moveable = 0
copyable = 0
have fd

So here I am back to square one! The problem seems to be related to the options used by IDE. Don’t know which one thoug!

Hi Joachim,

these are the commands that Visual Studio makes to build the program:

CL.exe /c /I"C:\Users\Ste\Documents\Visual Studio 2022\Soluzioni\TestNetGen\netgen\include" /I"C:\Users\Ste\Documents\Visual Studio 2022\Soluzioni\TestNetGen\netgen\include\include" /ZI /JMC /nologo /W3 /WX- /diagnostics:column /sdl /Od /D _DEBUG /D _CONSOLE /D _MBCS /D WIN32 /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /std:c++17 /permissive- /Fo"x64\Debug\\" /Fd"x64\Debug\vc143.pdb" /external:W3 /Gd /TP /FC /errorReport:prompt main.cpp

link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\Ste\Documents\Visual Studio 2022\Soluzioni\TestNetGen\x64\Debug\TestNetGen.exe" /INCREMENTAL /ILK:"x64\Debug\TestNetGen.ilk" /NOLOGO /LIBPATH:"C:\Users\Ste\Documents\Visual Studio 2022\Soluzioni\TestNetGen\netgen\lib" "C:\Users\Ste\Documents\Visual Studio 2022\Soluzioni\TestNetGen\netgen\lib\nglib.lib" "C:\Users\Ste\Documents\Visual Studio 2022\Soluzioni\TestNetGen\netgen\lib\ngcore.lib" "C:\Users\Ste\Documents\Visual Studio 2022\Soluzioni\TestNetGen\netgen\lib\libngsolve.lib" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:\Users\Ste\Documents\Visual Studio 2022\Soluzioni\TestNetGen\x64\Debug\TestNetGen.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\Ste\Documents\Visual Studio 2022\Soluzioni\TestNetGen\x64\Debug\TestNetGen.lib" /MACHINE:X64 x64\Debug\main.obj

while these are the ones used by ngscxx and ngsld:

cl /c  /O2 /Ob1 /DNDEBUG /DWIN32 /D_WINDOWS /GR /EHsc  /DHAVE_NETGEN_SOURCES /DUSE_TIMEOFDAY /DLAPACK /DUSE_UMFPACK /D_WIN32_WINNT=0x1000 /DWNT /DWNT_WINDOW /DNOMINMAX /DMSVC_EXPRESS /D_CRT_SECURE_NO_WARNINGS /DHAVE_STRUCT_TIMESPEC /DWIN32 /std:c++17 /bigobj /wd4068 -DMAX_SYS_DIM=3 /bigobj  /I"%NGSCXX_DIR%/../include" /I"%NGSCXX_DIR%/../include/include" %*

link %*  /LIBPATH:"%NGSCXX_DIR%/../lib" nglib.lib ngcore.lib libngsolve.lib

Do you see anything that would cause the exception that I am getting?

Thanks,
Stenio

does non debug work?

Very good advice Christopher: it release mode works! I had to add this definition to be able to compile _WIN32_WINNT=0x1000, and now works.

Do you have an idea of what can be the problem in debug mode?

Many thanks,
Stenio

did you compile netgen also with debug? i think if that doesn’t match there can be problems. for example we enable range checks and BareMatrices,… carry their sizes (in ngsolve, which is optimized out in release) there is probably also some abi incompatibiliy in netgen. i think currently we cannot support cross Debug<->release builds

No, I did not. I compiled it following these instructions and using the command

cmake --build . --config Release --target install

I’ll see if I can go on in Release mode or I’ll make a build in Debug mode if necessary.

Thank you for your support,
Stenio