# only depending on vtk, no code to call vtk，crash when close

**URL:** https://discourse.vtk.org/t/only-depending-on-vtk-no-code-to-call-vtk-crash-when-close/16064
**Category:** Development
**Tags:** code
**Created:** [September 26, 2025, 3:24am UTC](https://discourse.vtk.org/t/only-depending-on-vtk-no-code-to-call-vtk-crash-when-close/16064 "2025-09-26T03:24:04Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![sophia](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/b2d939/32.png) [@sophia](https://discourse.vtk.org/u/sophia)
#### Post date: [September 26, 2025, 3:24am UTC](https://discourse.vtk.org/t/only-depending-on-vtk-no-code-to-call-vtk-crash-when-close/16064/1 "2025-09-26T03:24:04Z")

</div>

A mfc application use one dll, the dll depend vtk。Free library when close the app, crash in the vtk code “ delete key;“

void vtkCommonInformationKeyManager::ClassFinalize()  
{  
…  
delete key;

…  
}

how to reslove the issue, thanks for reply

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [September 29, 2025, 6:15pm UTC](https://discourse.vtk.org/t/only-depending-on-vtk-no-code-to-call-vtk-crash-when-close/16064/2 "2025-09-29T18:15:20Z")

</div>

Hello,

It can indeed be some unchecked `delete` that went unnoticed until someone just tried to load the library without actually using it like you. Perhaps you could report the bug here: [https://gitlab.kitware.com/vtk/vtk/-/issues](https://gitlab.kitware.com/vtk/vtk/-/issues) . Other than that, only taking a look at your code.

best,

PC

---

<div class="post-metadata">

### Author: ![sophia](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/b2d939/32.png) [@sophia](https://discourse.vtk.org/u/sophia)
#### Post date: [October 11, 2025, 6:12am UTC](https://discourse.vtk.org/t/only-depending-on-vtk-no-code-to-call-vtk-crash-when-close/16064/3 "2025-10-11T06:12:58Z")

</div>

thanks for your reply。 i have reported the bug，expected to be handled。

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [October 12, 2025, 5:23pm UTC](https://discourse.vtk.org/t/only-depending-on-vtk-no-code-to-call-vtk-crash-when-close/16064/4 "2025-10-12T17:23:48Z")

</div>

The `vtkCommonInformationKeyManager` is meant to do cleanup of all VTK information keys when the program exits (that is, every class derived from `vtkInformationKey`).

In order for the cleanup to work correctly, every header file that defines a `vtkInformationKey` subclass must include `vtkCommonInformationKeyManager.h`. For example,

`vtkInformationIntegerKey.h`:

```c++
#include "vtkInformationKey.h"

#include "vtkCommonInformationKeyManager.h" // Manage instances of this type.

VTK_ABI_NAMESPACE_BEGIN
class VTKCOMMONCORE_EXPORT vtkInformationIntegerKey : public vtkInformationKey
{
  ...

```

The most likely cause of a crash in `vtkCommonInformationKeyManager::ClassFinalize()` is that someone created a custom information key _without_ including `vtkCommonInformationKeyManager.h`. This header ensures proper cleanup via the [nifti counter idiom](https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Nifty_Counter), but if it isn’t included wherever a key is defined, it doesn’t work.

Sophia, do you know if your code defines any `vtkInformationKey` subclasses? Also, can you provide a full stack trace for the crash, so that we can better understand what the error was?

---

<div class="post-metadata">

### Author: ![sophia](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/b2d939/32.png) [@sophia](https://discourse.vtk.org/u/sophia)
#### Post date: [January 29, 2026, 3:44am UTC](https://discourse.vtk.org/t/only-depending-on-vtk-no-code-to-call-vtk-crash-when-close/16064/5 "2026-01-29T03:44:53Z")

</div>

the stack is below:

 ![image](https://discourse.vtk.org/uploads/default/original/2X/b/b900f427928d21609730423dece25b16da1602e5.png)

output window is“引发了未经处理的异常:读取访问权限冲突。  
e-\>Item-\>\*\*\*\* 是 0x7FFAC6728EC0。”

---

<div class="post-metadata">

### Author: ![sophia](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/b2d939/32.png) [@sophia](https://discourse.vtk.org/u/sophia)
#### Post date: [January 29, 2026, 7:02am UTC](https://discourse.vtk.org/t/only-depending-on-vtk-no-code-to-call-vtk-crash-when-close/16064/6 "2026-01-29T07:02:49Z")

</div>

![image](https://discourse.vtk.org/uploads/default/original/2X/b/b9ce09e7a98d5eefd9664f1c394346ec8db138de.png)
