Bug 60550 - Using dllentry configuration causes Mono app to find wrong DLL exports
Summary: Using dllentry configuration causes Mono app to find wrong DLL exports
Status: NEW
Alias: None
Product: Runtime
Classification: Mono
Component: JIT ()
Version: 5.4 (2017-06)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-11-07 13:47 UTC by Damian Wilson
Modified: 2017-11-07 13:47 UTC (History)
2 users (show)

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


Attachments
SimpleInterop - A Visual Studio 2017 solution. Built binaries under Built folder. (257.19 KB, application/x-zip-compressed)
2017-11-07 13:47 UTC, Damian Wilson
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 60550 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 Damian Wilson 2017-11-07 13:47:56 UTC
Created attachment 25583 [details]
SimpleInterop - A Visual Studio 2017 solution. Built binaries under Built folder.

Basic info:

mono --version :
Mono JIT compiler version 5.4.0 (Visual Studio built mono)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com

I'm using the x64 version in a Windows 10 64 bit PC.

Description:

See attached Windows project that demonstrates this issue. In the project there is an app configuration including the following:

  <dllmap dll="i:SimpleDLL.dll">
                <dllentry dll="__Internal" name="UnknownName" target="AnotherUnknownName"/>
  </dllmap>

This should only map any function import called "UnknownName" to the first matching export in the process called "AnotherUnknownName". However it also causes ANY export from SimpleDLL to be resolved using this same algorithm, meaning that if a DLL exists with the same function name it may find this.

The attached project has two DLLs with the same export name, and the above dllmap in the calling app. Without the dllmap configuration it works as expected, but with it enabled Mono will search the process for the first export with the same name - meaning if duplicates exist it is down to whoever gets loaded first. In this sample, the wrong DLL export is picked.

I built the Mono version using "mcs Program -out:SimpleInterop.exe". Then run with "mono SimpleInterop.exe", which should result in:

"This is the correct other message displayed by AnotherDLL
This is the wrong message displayed by AnotherDLL"

The second message has discovered the wrong DLL export and called its method. Comment out or remove the DLL map and it will find the correct export. Working correctly, it should display:

"This is the correct other message displayed by AnotherDLL
This is the correct message displayed by SimpleDLL"