Bug 47867 - assert at sre.c:1553 in System.Reflection.Emit.TypeBuilder.create_runtime_class
Summary: assert at sre.c:1553 in System.Reflection.Emit.TypeBuilder.create_runtime_class
Alias: None
Product: Runtime
Classification: Mono
Component: Reflection ()
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Aleksey Kliger
Depends on:
Reported: 2016-11-24 17:31 UTC by Robert van der Boon
Modified: 2016-12-01 15:38 UTC (History)
3 users (show)

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

Test file (1.10 KB, text/plain)
2016-11-24 17:31 UTC, Robert van der Boon
Assert Abort Stacktrace (5.52 KB, text/plain)
2016-11-24 17:32 UTC, Robert van der Boon
Standalone reproduction (846 bytes, text/plain)
2016-11-28 18:04 UTC, Aleksey Kliger

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 Robert van der Boon 2016-11-24 17:31:37 UTC
Created attachment 18657 [details]
Test file

When using Rhino mocks to create a DynamicMock for an interface with a generic method an assertion is raised and the process dies.

See attached both a test case and the stacktrace.
compile the testcase with:
  mcs -t:exe -r:Rhino.Mocks test.cs
run with:
  mono --debug test.exe

If you compile with -DLESS_GENERIC the test succeeds (prints: "Done: 00000000-0000-0000-0000-000000000000")
Comment 1 Robert van der Boon 2016-11-24 17:32:04 UTC
Created attachment 18658 [details]
Assert Abort Stacktrace
Comment 2 Aleksey Kliger 2016-11-28 17:36:36 UTC
This is one of our awesome corner cases where a finished typebuilder references a generic instantiation of an unfinished one.  reflection_setup_internal_class minimally initializes the referenced type, but it doesn't have enough info to make the call on whether the type will be a generic or not. But when we go to instantiate in mono_reflection_bind_generic_parameters we expect to see a generic type definition.

Working on a minimal standalone reproduction...
Comment 3 Aleksey Kliger 2016-11-28 18:04:48 UTC
Created attachment 18698 [details]
Standalone reproduction

Standalone reproduction without dependencies.
Comment 4 Aleksey Kliger 2016-12-01 15:38:18 UTC
Fixed in Mono master https://github.com/mono/mono/commit/a713a14521da8ddf992c4a3e64855d56cb7897a3