Bug 109 - Should throw AccessViolationException if not using [UnmanagedFunctionPointer (CallingConvention.Cdecl)]
Summary: Should throw AccessViolationException if not using [UnmanagedFunctionPointer ...
Status: RESOLVED NOT_ON_ROADMAP
Alias: None
Product: Runtime
Classification: Mono
Component: Interop ()
Version: unspecified
Hardware: PC All
: --- minor
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-07-29 06:59 UTC by Andres G. Aragoneses
Modified: 2011-08-24 20:11 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
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:
Status:
RESOLVED NOT_ON_ROADMAP

Description Andres G. Aragoneses 2011-07-29 06:59:02 UTC
There was some discussion in bug http://bugzilla.novell.com/583901 about if the bug belonged to the runtime or not.

The culprit was really a missing [UnmanagedFunctionPointer] attribute, but the fact that MS.NET and mono runtime differ when dealing with this problem is a bug in itself which obscures things: Mono should raise an AccessViolationException like MS.NET does, instead of a plain unmanaged exception.
Comment 1 Zoltan Varga 2011-07-30 13:52:13 UTC
If I understand correctly, this is about converting unmanaged crashes into AccessViolationExceptions ? We don't do that, and probably never will, crashes in unmanaged code are not exceptions, and shouldn't be converted to it.
Comment 2 Andres G. Aragoneses 2011-08-02 08:50:23 UTC
(In reply to comment #1)
> If I understand correctly, this is about converting unmanaged crashes into
> AccessViolationExceptions ?

I didn't intend to create such a broad bug. The scenario here is just about a missing attribute in a P/Invoke delegate, not sure if MS.NET throws AccessViolationException for every single unmanaged crash.

> We don't do that, and probably never will, crashes
> in unmanaged code are not exceptions, and shouldn't be converted to it.

Why does MS.NET do it then (at least in this specific case)? And why wouldn't you want to mimic their behaviour? In this specific case it is a good thing because it gives clues that the problem is indeed in the managed code (because it's the one you need to modify to prevent the unmanaged call to crash).
Comment 3 Zoltan Varga 2011-08-02 12:44:02 UTC
AccessViolationException is a generic exception which is thrown when something SIGSEGV like happens on windows. If they do indeed check for a calling conv mismatch, then they would throw a precise exception, so this is probably by accident.
Comment 4 Zoltan Varga 2011-08-24 20:11:09 UTC
-> WONTFIX.