Bug 39955 - [gacutil] System.NullReferenceException in Mono.Security.StrongName.Verify
Summary: [gacutil] System.NullReferenceException in Mono.Security.StrongName.Verify
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: Mono.Security ()
Version: 4.2.0 (C6)
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-03-28 22:00 UTC by delcypher
Modified: 2016-03-28 22:00 UTC (History)
1 user (show)

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


Attachments
Simple source file to build an assembly (125 bytes, text/x-csharp)
2016-03-28 22:00 UTC, delcypher
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 for Bug 39955 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description delcypher 2016-03-28 22:00:52 UTC
Created attachment 15538 [details]
Simple source file to build an assembly

When installing a signed assembly using the ``gacutil`` utility a ``System.NullReferenceException`` may be thrown in ``Mono.Security.StrongName.Verify`` if the ``-platform`` flag was used to build the assembly.

Platform:
Arch Linux with kernel 4.4.5-1 ... x86_64
Mono 4.2.2.30/996df3c

Reproduction steps:

1. Generate a key

```
sn -k test.snk
```

2. Compile the attached source file into an assembly and sign it.

```
mcs -target:library MyClass.cs -keyfile:test.snk -platform:x64 -out:myclass.dll
```

3. Make a temporary directory for the gac

```
mkdir XXX
```

4. Try to install the built assembly to the GAC rooted in ``XXX``

```
gacutil -i myclass.dll -root XXX/

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at Mono.Security.StrongName.Verify (System.IO.Stream stream) <0x41ad89a0 + 0x00036> in <filename unknown>:0 
  at Mono.Security.StrongName.Verify (System.String fileName) <0x41ad87c0 + 0x00037> in <filename unknown>:0 
  at Mono.Tools.Driver.VerifyStrongName (System.Reflection.AssemblyName an, System.String assemblyFile) <0x41ac04f0 + 0x000c7> in <filename unknown>:0 
  at Mono.Tools.Driver.Install (Boolean check_refs, System.String name, System.String package, System.String gacdir, System.String link_gacdir, System.String libdir, System.String link_libdir) <0x41abeac0 + 0x0022b> in <filename unknown>:0 
  at Mono.Tools.Driver.Main (System.String[] args) <0x41aa3e00 + 0x007bf> in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at Mono.Security.StrongName.Verify (System.IO.Stream stream) <0x41ad89a0 + 0x00036> in <filename unknown>:0 
  at Mono.Security.StrongName.Verify (System.String fileName) <0x41ad87c0 + 0x00037> in <filename unknown>:0 
  at Mono.Tools.Driver.VerifyStrongName (System.Reflection.AssemblyName an, System.String assemblyFile) <0x41ac04f0 + 0x000c7> in <filename unknown>:0 
  at Mono.Tools.Driver.Install (Boolean check_refs, System.String name, System.String package, System.String gacdir, System.String link_gacdir, System.String libdir, System.String link_libdir) <0x41abeac0 + 0x0022b> in <filename unknown>:0 
  at Mono.Tools.Driver.Main (System.String[] args) <0x41aa3e00 + 0x007bf> in <filename unknown>:0 
```

Notice in step 2, if you remove the ``-platform:x64`` flag when building the assembly then when an attempt to install it into the GAC is made the crash does not occur. Using ``-platform:x86`` doesn't seem to cause a crash later on in ``gacutil`` either but using ``-platform:x64``, ``-platform:arm`` and ``-platform:itanium`` does.