Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn if Mono version is <= 6.12 #21

Merged
merged 1 commit into from
Jan 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clr_loader/ffi/mono.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
MONO_DEBUG_FORMAT_DEBUGGER
} MonoDebugFormat;

char* mono_get_runtime_build_info (void);

MonoDomain* mono_jit_init(const char *root_domain_name);
void mono_jit_cleanup(MonoDomain *domain);
void mono_jit_parse_options(int argc, char * argv[]);
Expand Down
17 changes: 17 additions & 0 deletions clr_loader/mono.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import atexit
import re
from typing import Optional, Sequence

from .ffi import load_mono, ffi
Expand Down Expand Up @@ -122,13 +123,29 @@ def initialize(
if jit_options:
options = [ffi.new("char[]", o.encode("utf8")) for o in jit_options]
_MONO.mono_jit_parse_options(len(options), options)
else:
options = []

if debug:
_MONO.mono_debug_init(_MONO.MONO_DEBUG_FORMAT_MONO)

_ROOT_DOMAIN = _MONO.mono_jit_init(b"clr_loader")
_MONO.mono_domain_set_config(_ROOT_DOMAIN, b".", config_encoded)
_check_result(_ROOT_DOMAIN, "Failed to initialize Mono")

build = _MONO.mono_get_runtime_build_info()
_check_result(build, "Failed to get Mono version")
ver_str = ffi.string(build).decode('utf8') # e.g. '6.12.0.122 (tarball)'

ver = re.match(r'^(?P<major>\d+)\.(?P<minor>\d+)\.[\d.]+', ver_str)
if ver is not None:
major = int(ver.group('major'))
minor = int(ver.group('minor'))

if major < 6 or (major == 6 and minor < 12):
import warnings
warnings.warn('Hosting Mono versions before v6.12 is known to be problematic. If the process crashes shortly after you see this message, try updating Mono to at least v6.12.')

atexit.register(_release)


Expand Down