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)

See Also:
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

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.

Note You need to log in before you can comment on or make changes to this bug.