From 46a943fb0de2573369931eab2e60a06a9f8094f8 Mon Sep 17 00:00:00 2001 From: jakrivan Date: Mon, 12 Feb 2018 18:37:49 +0100 Subject: [PATCH 1/2] Added inline comment about dangers of multidomain usage As requested here: https://github.com/pythonnet/pythonnet/pull/538#issuecomment-364630052 --- src/runtime/assemblymanager.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/runtime/assemblymanager.cs b/src/runtime/assemblymanager.cs index fdd31b004..9b6f152e0 100644 --- a/src/runtime/assemblymanager.cs +++ b/src/runtime/assemblymanager.cs @@ -17,6 +17,13 @@ internal class AssemblyManager { // modified from event handlers below, potentially triggered from different .NET threads // therefore this should be a ConcurrentDictionary + // + // WARNING: Dangerous if cross-app domain usage is ever supported + // Reusing the dictionary with assemblies accross multiple initializations is problematic. + // Loading happens from CurrentDomain (see line 53). And if the first call is from AppDomain that is later unloaded, + // than it can end up referring to assemblies that are already unloaded (default behavior after unload appDomain - + // unless LoaderOptimization.MultiDomain is used); + // So for multidomain support it is better to have the dict. recreated for each app-domain initialization private static ConcurrentDictionary> namespaces = new ConcurrentDictionary>(); //private static Dictionary> generics; From 9255b6b99cd350ce975412769d6a97cb70bb1a7b Mon Sep 17 00:00:00 2001 From: jakrivan Date: Tue, 12 Jun 2018 09:35:18 +0200 Subject: [PATCH 2/2] Comment about dangers of multidomain usage #625 --- AUTHORS.md | 1 + CHANGELOG.md | 1 + 2 files changed, 2 insertions(+) diff --git a/AUTHORS.md b/AUTHORS.md index 78bb25f9e..bbb4ec346 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -23,6 +23,7 @@ - David Lechner ([@dlech](https://github.com/dlech)) - Dmitriy Se ([@dmitriyse](https://github.com/dmitriyse)) - He-chien Tsai ([@t3476](https://github.com/t3476)) +- Jan Krivanek ([@jakrivan](https://github.com/jakrivan)) - Jeff Reback ([@jreback](https://github.com/jreback)) - Joe Frayne ([@jfrayne](https://github.com/jfrayne)) - John Burnett ([@johnburnett](https://github.com/johnburnett)) diff --git a/CHANGELOG.md b/CHANGELOG.md index d03b41ec5..2b1ebd57d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][]. - Added `clr.GetClrType` (#432, #433) - Allowed passing `None` for nullable args (#460) - Added keyword arguments based on C# syntax for calling CPython methods (#461) +- Added detailed comments about aproaches and dangers to handle multi-app-domains (#538) ### Changed