Bug 59881 - DllImport calls a wrong function if its function number greater than 65535
Summary: DllImport calls a wrong function if its function number greater than 65535
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: Interop (show other bugs)
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-10-01 22:07 UTC by Ilia Ishkhanov
Modified: 2017-10-03 08:55 UTC (History)
3 users (show)

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


Attachments
native so with 65537 exported functions and dotnet that imports them and try to call latest (705.89 KB, application/gzip)
2017-10-01 22:07 UTC, Ilia Ishkhanov
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 Ilia Ishkhanov 2017-10-01 22:07:58 UTC
Created attachment 25047 [details]
native so with 65537 exported functions and dotnet that imports them and try to call latest

Its impossible to call 65536 imported function and above. Works fine on .Net Framework 4. 

Platform: Ubuntu 16. Can reproduce on master and 5.2.0.224.

I created the minimal example to reproduce the bug. big_dllexport.c gives the native library with 65537 exported functions. Each of the function prints a unique number. dllimport.cs imports them all and calls ExportedFunc65537 function, which suppose to print 65537, but instead you get 1.

The attached archive contains three files. build.sh describes how to compile both native so and mono app. Run ./dllimport after compilation to see the unexpected output.
Comment 1 Zoltan Varga 2017-10-02 21:38:21 UTC
https://github.com/mono/mono/pull/5682
Comment 2 Zoltan Varga 2017-10-03 08:55:33 UTC
Fixed by mono master 9369ed6e23ee9e822a3aa2318ed55f083241fbcb.