Bug 43786 - peverify is broken again
Summary: peverify is broken again
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Ludovic Henry
Depends on:
Reported: 2016-08-26 12:35 UTC by Marek Safar
Modified: 2016-08-30 08:33 UTC (History)
5 users (show)

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

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 Marek Safar 2016-08-26 12:35:13 UTC
peverify any .exe

peverify x.exe
mono_os_mutex_lock: pthread_mutex_lock failed with "Invalid argument" (22)
Abort trap: 6
Comment 1 Andi McClure 2016-08-29 15:45:48 UTC
I can't repro this.

Marek, what OS, mono version etc was this?
Comment 2 Marek Safar 2016-08-29 16:22:21 UTC
Mac OS, mono master


class X
	static void Main ()

mcs x.cs
peverify x.exe

mono_os_mutex_lock: pthread_mutex_lock failed with "Invalid argument" (22)
Abort trap: 6
Comment 3 Rodrigo Kumpera 2016-08-29 18:59:11 UTC
4.4 is broken and won't be fixed.

4.6 works.

Master with the following commit works:

commit dcd650d6fc59817b1efd6fc088ac41ce304a41c2
Author: Zoltan Varga <vargaz@gmail.com>
Date:   Thu Aug 25 22:18:45 2016 +0200
Comment 4 Andi McClure 2016-08-29 19:02:20 UTC
As mentioned, I was not reproducing this. This was with mono master

I *do* reproduce this with the newest mono master
Comment 5 Andi McClure 2016-08-29 19:07:57 UTC
Reopening. Rodrigo, if you are still not reproducing this after upgrading to 6a5599d, let me know.
Comment 6 Andi McClure 2016-08-29 19:23:24 UTC
The crash occurs because scan_mutex is not valid when pedump calls mono_init_version and wapi_init is called.

In between d185b75dd and 6a5599d71e is e5a4d23fc7d431ddb61ad271a5b1e6ad28612104:

"[w32handle] Initialize them earlier...", a commit by ludovic

This moves mono_w32handle_init from mono_init_internal where wapi_init is called to mono_main.

However pedump does not call mono_main, it calls mono_init_version, so now mono_w32handle_init is never called. This could potentially impact anyone who uses the embedding API.

dcd650d6fc59 which Rodrigo tested is newer than e5a4d23fc so I'm not sure why Rodrigo was not reproducing the problem.
Comment 7 Andi McClure 2016-08-29 19:26:42 UTC
Ludovic, can you take a look at this?
Comment 8 Zoltan Varga 2016-08-29 20:39:17 UTC

It would be nice to to all of this stuff in a managed tool instead of C. Since we don't so sandboxing anymore, we don't need a verifier in the runtime.
Comment 9 Rodrigo Kumpera 2016-08-29 21:51:49 UTC
Merged Zoltan's PR.
Comment 10 Rodrigo Kumpera 2016-08-29 22:12:48 UTC
it was reverted, sorry guys :(
Comment 11 Ludovic Henry 2016-08-30 08:33:10 UTC
It is now fixed with https://github.com/mono/mono/commit/e8a221683d31cc392c46ccea67dc1ae8c6d108e7