Fix issue where loaded global modules aren't freed
authorCry-Miron <31213913+Cry-Miron@users.noreply.github.com>
Tue, 12 Sep 2017 09:45:03 +0000 (11:45 +0200)
committerGitHub <noreply@github.com>
Tue, 12 Sep 2017 09:45:03 +0000 (11:45 +0200)
commit5a26d60113e4d9eb08f143faf737163e305ee1aa
tree9385a47890bcd098f2e358579e20a19afab91671
parent4a20e930afc89aba911f43fb14cce2feeeab65cc
Fix issue where loaded global modules aren't freed

Globally loaded modules would previously call LoadLibrary on Windows, but never FreeLibrary. This would result in said library keeping an internal reference counter of 1 until the application exited its entry-point, resulting in possible shutdown issues.

This commit makes sure that we correctly free modules (and unload them in the platform-specific APIs) whenever Mono itself is shutting down, ensuring the expected result of Mono-loaded libraries being correctly freed.
mono/metadata/loader.c