Archicad C++ API
About Archicad add-on development using the C++ API.

Archicad crashing when closed and opens bug report

Anonymous
Not applicable
Hello,

I have developed a plugin for Archicad 21. It has a pallette with buttons. I have made it to be reachable through window->pallette. When I open the pallette and close the whole Archicad it just crashes and opens the bug report.

I get this in the error log:

Exception thrown at 0x00007FFC6DE65F20 in Archicad.exe: 0xC0000005: Access violation executing location 0x00007FFC6DE65F20.

What could be the possible reason for the whole Archicad to crash when I try to close it with my plugin opened?

This is what I got in the initialize and freedata functions:

GSErrCode __ACENV_CALL	RegisterInterface(void)
{
	GSErrCode	err;

	//
	// Register menus
	//
	//err = ACAPI_Register_Menu (32500, 0, MenuCode_UserDef, MenuFlag_SeparatorBefore);
	err = ACAPI_Register_Menu(32500, 0, MenuCode_Palettes, MenuFlag_SeparatorBefore);

	return err;
}		/* RegisterInterface */


		// -----------------------------------------------------------------------------
		// Called when the Add-On has been loaded into memory
		// to perform an operation
		// -----------------------------------------------------------------------------
GSErrCode __ACENV_CALL	Initialize(void)
{

	GSErrCode err = NoError;
	static short result = 0;

	//
	// Install menu handler callbacks
	//
	err = ACAPI_Install_MenuHandler(32500, MenuCommandHandler);

	return err;

	//return err;
}		/* Initialize */


		// -----------------------------------------------------------------------------
		// Called when the Add-On is going to be unloaded
		// -----------------------------------------------------------------------------

GSErrCode __ACENV_CALL	FreeData(void)
{
	return NoError;
}		/* FreeData */
6 REPLIES 6
Ralph Wessel
Mentor
jcimentarov wrote:
I have developed a plugin for Archicad 21. It has a pallette with buttons. I have made it to be reachable through window->pallette. When I open the pallette and close the whole Archicad it just crashes and opens the bug report. What could be the possible reason for the whole archicad to crash when I try to close it with my plugin opened?
Are you calling ACAPI_KeepInMemory? You need to use this if your add-on is doing anything persistent, e.g. keeping a palette open.
Ralph Wessel BArch
Anonymous
Not applicable
I have tried putting ACAPI_KeepInMemory(1) in Initialize() and MenuCommandHandler(), but it stills crashes if I have the palette opened and quit ARCHICAD.

By the way I have developed this plugin for both MAC and Windows and this only happens on the windows version of the plugin.

Am I placing the ACAPI_KeepInMemory() on the right place?
Ralph Wessel
Mentor
jcimentarov wrote:
I have tried putting ACAPI_KeepInMemory(1) in Initialize() and MenuCommandHandler(), but it stills crashes if I have the palette opened and quit ARCHICAD.

By the way I have developed this plugin for both MAC and Windows and this only happens on the windows version of the plugin.

Am I placing the ACAPI_KeepInMemory() on the right place?
The documentation for ACAPI_KeepInMemory states:
You should call this function with true each time your add-on is called to stay in memory. The values of all your global variables stay the same between the calls to your add-on. Also, when in memory, the Initialize and the FreeData functions of your add-on are not called. See more about this topic at the Control the Load/Unload Mechanism part of the Tips and Tricks.
If that's taken care of, then there must be another explanation for the crash. Are there any other clues, e.g. crash report or a stack trace? Are you able to debug into the point where it crashes? It's most likely to be an issue with memory management.
Ralph Wessel BArch
Anonymous
Not applicable
It says that it has unloaded my plugin(Environment_Control.apx)

This is the log of Archicad before crash:

'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Visualisation\OpenGL Engine.gmx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Windows\System32\prl_umdd10.dll'
The thread 0x1058 has exited with code 0 (0x0).
The thread 0x17f8 has exited with code 0 (0x0).
The thread 0x152c has exited with code 0 (0x0).
Exception thrown at 0x00007FF93C123FB8 in ARCHICAD.exe: Microsoft C++ exception: GS::InterruptedException at memory location 0x000000F9E73FF658.
The thread 0x1184 has exited with code 0 (0x0).
The thread 0x1fc0 has exited with code 0 (0x0).
The thread 0xdc4 has exited with code 0 (0x0).
Exception thrown at 0x00007FF93C123FB8 in ARCHICAD.exe: Microsoft C++ exception: GS::InterruptedIOException at memory location 0x000000F9E74FC160.
Exception thrown at 0x00007FF93C123FB8 in ARCHICAD.exe: Microsoft C++ exception: GS::InterruptedIOException at memory location 0x000000F9E74FD868.
Exception thrown at 0x00007FF93C123FB8 in ARCHICAD.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
Exception thrown at 0x00007FF93C123FB8 in ARCHICAD.exe: Microsoft C++ exception: GS::InterruptedIOException at memory location 0x000000F9E74FD868.
The thread 0xae0 has exited with code 0 (0x0).
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Environment_Control.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Standard\Selections.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Standard\RegisterLightworksFileTypes.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Standard\Quick Layers.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Standard\NecessaryLPs.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Standard\Interactive Schedule.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Standard\Element Information.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Standard\Corner Window.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Standard\Active Layer.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Standard\3Dconnexion Enabler.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\MEP.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\MEP Modeler\MEP Modeler.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Local\Grid Tool.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Import-Export\Rhino_Out.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\opennurbs.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Import-Export\Rhino_In.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\EXPRESSManagerUtilities_EDM.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Ifc2x3Classes_EDM.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9317_none_08e0939fa840d57b\msvcr90.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\edm_libxml2.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\edmikit500.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\EDM.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Ifc4Classes_EDM.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\IfcCommonClasses_EDM.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Import-Export\IFC.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Import-Export\CommonBlock.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Import-Export\CorrectTextPos.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Import-Export\LabelIO.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Import-Export\MeshIn.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Import-Export\PointIN.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Import-Export\RoundTrip.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\ZLib-DWG.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\PlotStyleServices-DWG_4.01src_14.tx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\TD_Gs-DWG_4.01src_14.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\DWFToolkit-DWG.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\W3dTk-DWG.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\WhipTk-DWG.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\DWFCore-DWG.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\TD_Dwf7Export-DWG_4.01src_14.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\DXF_DWG_Engine.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\TD_DbRoot-DWG_4.01src_14.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\TD_Gi-DWG_4.01src_14.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\TD_SpatialIndex-DWG_4.01src_14.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\TD_Db-DWG_4.01src_14.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\sisl-DWG.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\TD_Ge-DWG_4.01src_14.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\TD_Alloc-DWG_4.01src_14.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\TD_Root-DWG_4.01src_14.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Import-Export\DXF-DWG In-Out.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Extras\Profile Database.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Extras\MeshImport.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Windows\System32\Wldap32.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Extras\ARCHICAD Online Training.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\EnergyEvaluation.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\LibXL.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\EnergyEvaluation\EnergyEvaluation.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Windows\System32\msvcr120.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\PVRTexLib.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\LibXML.dll'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\BIMx\BIMx.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Import-Export\Collada In-Out.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Import-Export\GoogleEarthConnectivity.apx'
'ARCHICAD.exe' (Win32): Unloaded 'C:\Program Files\GRAPHISOFT\ARCHICAD 21\Add-Ons\Import-Export\PointCloud_In.apx'
The thread 0x154c has exited with code 0 (0x0).
The thread 0xc60 has exited with code 0 (0x0).
The thread 0x550 has exited with code 0 (0x0).
'ARCHICAD.exe' (Win32): Unloaded 'C:\Windows\System32\mfreadwrite.dll'
Exception thrown at 0x00007FF8F8DD5FD0 in ARCHICAD.exe: 0xC0000005: Access violation executing location 0x00007FF8F8DD5FD0.
Anonymous
Not applicable
Another thing I notice is that when the palette is opened and I close Archicad the palette continues to stay opened and after that comes the crash.

It looks like it has to be destroyed somehow?
Anonymous
Not applicable
Thread can be solved! I have fixed with by adding the following function into the FreeData:

GSErrCode __ACENV_CALL	FreeData(void)
{	
	DGDestroyPalette(myDialID);
	return NoError;
}