Bug 41466 - mono_class_is_subclass_of return incorrect value by assuming mono_class_init has been called on parameters
Summary: mono_class_is_subclass_of return incorrect value by assuming mono_class_init ...
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-06-02 17:45 UTC by Jonathan Chambers
Modified: 2016-06-07 08:14 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Test project (1.25 KB, application/zip)
2016-06-02 17:45 UTC, Jonathan Chambers

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jonathan Chambers 2016-06-02 17:45:12 UTC
Created attachment 16176 [details]
Test project

In an embedding scenario, I am calling mono_class_is_subclass_of on a class and an interface. In this case the class does actually implement the interface so I would expect TRUE to be returned. However, if the class has not been initialized the call returns FALSE since the interface check fails.

My assumption is that mono_class_is_subclass_of (and all embedding APIs) would call mono_class_init as needed. If this is not the case, I can work around it but it probably needs documented.

To reproduce:
unzip the attachment on OSX.
Edit build.sh to a local mono install
./a.out Main.exe

The final line of the output will read: mono_class_if_subclass_of: 0
Edit main.c to call mono_class_init on the klass
The final line of the output will read: mono_class_if_subclass_of: 1
Comment 1 Zoltan Varga 2016-06-07 08:14:56 UTC
Fixed in mono master 97634ecfae6b2b7ec4b1efd0e1a1fdcd23e69224.