Bug 39347

Summary: Assertion when passing delegate of icall method to p/invoke
Product: [Mono] Runtime Reporter: Alex Corrado [MSFT] <alexc>
Component: InteropAssignee: Bugzilla <bugzilla>
Severity: normal CC: mono-bugs+mono, mono-bugs+runtime, vargaz
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: Test case

Description Alex Corrado [MSFT] 2016-03-04 03:24:16 UTC
Created attachment 15260 [details]
Test case

See attached test case.

When passing a delegate to a p/invoke call, mono crashes with this assertion if the delegate was constructed from an icall:

* Assertion at loader.c:1437, condition `method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL' not met

Look at the call to `mono_lookup_pinvoke_call` here: https://github.com/mono/mono/blob/7452477db341f1c8ec368db491bfe5653a972ce2/mono/metadata/marshal.c#L300 ... note that the guard condition for that is `mono_method_signature (method)->pinvoke`, while the assertion in `mono_lookup_pinvoke_call` checks `method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL'
Comment 1 Zoltan Varga 2016-03-19 12:06:54 UTC
Fixed in mono master c736aba5c94c20e6faad6b736f8e3a834e26d95f.