- Notifications
You must be signed in to change notification settings - Fork749
Commit4e5afdf
committed
Fix access violation exception on shutdown (#1977)
When nulling the GC handles on shutdown the reference count of all objects pointed to by the IntPtr in the `CLRObject.reflectedObjects` are zero.This caused an exception in some scenarios because `Runtime.PyObject_TYPE(reflectedClrObject)` is called while the reference counter is at zero.After `TypeManager.RemoveTypes();` is called in the `Runtime.Shutdown()` method, reference count decrements to zero do not invoke `ClassBase.tp_clear` for managed objects anymore which normally is responsible for removing references from `CLRObject.reflectedObjects`. Collecting objects referenced in `CLRObject.reflectedObjects` only after leads to an unstable state in which the reference count for these object addresses is zero while still maintaining them to be used for further pseudo-cleanup. In that time, the memory could have been reclaimed already which leads to the exception.1 parentb112885 commit4e5afdf
3 files changed
+6
-2
lines changedLines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
38 | 38 |
| |
39 | 39 |
| |
40 | 40 |
| |
| 41 | + | |
41 | 42 |
| |
42 | 43 |
| |
43 | 44 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
| 26 | + | |
26 | 27 |
| |
27 | 28 |
| |
28 | 29 |
| |
| |||
970 | 971 |
| |
971 | 972 |
| |
972 | 973 |
| |
| 974 | + |
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
278 | 278 |
| |
279 | 279 |
| |
280 | 280 |
| |
| 281 | + | |
| 282 | + | |
281 | 283 |
| |
282 | 284 |
| |
283 | 285 |
| |
| |||
295 | 297 |
| |
296 | 298 |
| |
297 | 299 |
| |
298 |
| - | |
299 |
| - | |
| 300 | + | |
300 | 301 |
| |
301 | 302 |
| |
302 | 303 |
| |
|
0 commit comments
Comments
(0)