Bug 30590 - HostProtectionAttribute mis-encoded on delegate
Summary: HostProtectionAttribute mis-encoded on delegate
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 4.0.0
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2015-05-29 11:31 UTC by Sebastien Pouliot
Modified: 2015-06-02 14:39 UTC (History)
1 user (show)

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


Attachments
Test case (846 bytes, application/octet-stream)
2015-05-29 11:34 UTC, Sebastien Pouliot
Details


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:
Status:
RESOLVED FIXED

Description Sebastien Pouliot 2015-05-29 11:31:38 UTC
from System.dll

namespace System.ComponentModel
{
	[HostProtection(SharedState = true)]
	public delegate void PropertyChangedEventHandler(object sender, PropertyChangedEventArgs e);
}

mcs compile this attribute as a _normal_ custom attribute on the delegate (the only case I've seen). It should be encoded as a security declaration, like it already is when used elsewhere on classes.

That does not have much effect for Mono (and Xamarin's products) as they don't support CAS, but the binary would not be correct for running on MS.NET.
Comment 1 Sebastien Pouliot 2015-05-29 11:34:22 UTC
Created attachment 11387 [details]
Test case

$ /opt/mono/bin/mono --version
Mono JIT compiler version 4.1.0 (master/93310d9 Fri 20 Mar 2015 15:05:25 EDT)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           normal
	SIGSEGV:       altstack
	Notification:  kqueue
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen

Compiled with mcs

$ /opt/mono/bin/mono dhbug.exe 
Test.PropertyChangedEventHandler custom attribute System.Security.Permissions.HostProtectionAttribute
Test.Program security System.Security.Permissions.HostProtectionAttribute


Compiled with MS csc (vs2013)

$ /opt/mono/bin/mono dhms.exe 
Test.PropertyChangedEventHandler security System.Security.Permissions.HostProtectionAttribute
Test.Program security System.Security.Permissions.HostProtectionAttribute
Comment 2 Marek Safar 2015-06-02 14:39:12 UTC
Fixed in master and 4.2 branch