Skip to content

Issue with DllImport #5874

Closed
Closed

Description

@manu-st

While exploring how DllImport worked on Linux, I found the following issue at this line: https://github.com/dotnet/coreclr/blob/master/src/vm/dllimport.cpp#L7165

It seems that the code forgot to assign the result of the call to LoadFromNativeDllSearchDirectories to hmod. Is this expected?

Activity

  1. adityamandaleeka commented on May 18, 2016

    @adityamandaleeka
    Member

    @manu-silicon You're right. Thanks for finding this issue!

  2. manu-st commented on May 18, 2016

    @manu-st
    Author

    @adityamandaleeka You are welcome.

  3. whoisj commented on May 18, 2016

    @whoisj

    Wouldn't it be nice if the language / compiler complained loudly when return values were ignored?

    https://twitter.com/xjoeduffyx/status/730991667960893440

    😏

  4. yizhang82 commented on May 18, 2016

    @yizhang82
    Contributor

    @adityamandaleeka I just discovered this as well and I have a fix (dotnet/coreclr#5048) that fixes this as well as a different issue. Our PR probably going to conflict since I'm moving that exact same code.

  5. adityamandaleeka commented on May 18, 2016

    @adityamandaleeka
    Member

    @yizhang82 I've closed my PR, and am reassigning this issue to you.

  6. yizhang82 commented on May 18, 2016

    @yizhang82
    Contributor
  7. yizhang82 commented on May 18, 2016

    @yizhang82
    Contributor
  8. manu-st commented on May 19, 2016

    @manu-st
    Author

    @yizhang82 By the way, how one can set NATIVE_DLL_SEARCH_DIRECTORIES?

  9. manu-st commented on May 19, 2016

    @manu-st
    Author

    I see. Is there a way to have that set of directories searched too for PInvoke? That would help tremendously!

  10. yizhang82 commented on May 19, 2016

    @yizhang82
    Contributor

    Yep. It is being searched already and that's exactly what LoadFromNativeDllSearchDirectories does. My other PR dotnet/coreclr#5048 only changes the order.

  11. 1 remaining item

  12. yizhang82 commented on May 19, 2016

    @yizhang82
    Contributor

    @manu-silicon That's a host specific issue since host owns translating the environment variables into NATIVE_DLL_SEARCH_DIRECTORIES that is understood by the runtime.
    @schellap Can you take a look and create a issue as well?
    /cc @gkhanna79

  13. manu-st commented on May 19, 2016

    @manu-st
    Author

    In the meantime, I'll work on porting the Windows code to unixcoreruncommon to fetch the value of CORE_LIBRARIES as I need this to run some program on Unix. Thanks!

  14. gkhanna79 commented on May 19, 2016

    @gkhanna79
    Member

    Corelibraries is for internal development. We should probably clean it up and remove it. You should use native ski search path envvar only.

  15. manu-st commented on May 19, 2016

    @manu-st
    Author

    Not sure to understand what native ski means. I just made a patch for picking up from CORE_LIBRARIES. See https://github.com/dotnet/coreclr/compare/master...manu-silicon:core_libraries?expand=1 Let me know if this is worth creating a pull request.

  16. gkhanna79 commented on May 19, 2016

    @gkhanna79
    Member

    @manu-silicon Sorry, auto-correct on phone does its own thing.

    CORE_LIBRARIES is just a development/internal-testing environment variable and should not be relied upon. If you wish to add it to unixcorerun for consistentcy, that is fine. But this is not expected to be formally supported in any host used in formal scenarios. The formal way to specify the folders to look for pinvoke targets is NATIVE_DLL_SEARCH_PATHS.

  17. manu-st commented on May 19, 2016

    @manu-st
    Author

    @gkhanna79 I understand that but how do I set this as a user? I only found CORE_LIBRARIES as a solution.

  18. gkhanna79 commented on May 19, 2016

    @gkhanna79
    Member

    You cannot - this is a host property and you will need to write a host that sets it. For .NET Core, this is automatically computed based upon the app manifest and .NET Host passes it to the runtime. If you have a scenario where you wish to have an external user specify such a value, consider authoring a host.

  19. manu-st commented on May 19, 2016

    @manu-st
    Author

    I was thinking about an app manifest too. Is this supported just for Windows?

  20. gkhanna79 commented on May 19, 2016

    @gkhanna79
    Member
  21. manu-st commented on May 19, 2016

    @manu-st
    Author

    Being rusty on the app manifest. Does anyone have an example of a manifest that add to the NATIVE_DLL_SEARCH_PATHS?

  22. manu-st commented on May 19, 2016

    @manu-st
    Author

    @schellap This is confusing. I'm not using dotnet/cli. I'm looking at ways to tell CoreCLR where to look for my native dlls.

  23. schellap commented on May 19, 2016

    @schellap

    @manu-silicon no need to use CLI. You can take a look at how the dotnet host sets it from its app manifest for the .net core app model and implement something similar.

    However, I would suggest porting the CORE_LIBRARIES as it would be a smaller change than go down the app manifest route since your objective is just hooking the native paths.

    Here is relevant code:
    https://github.com/dotnet/cli/blob/rel/1.0.0/src/corehost/cli/hostpolicy.cpp#L62

  24. transferred this issue fromdotnet/coreclron Jan 30, 2020
  25. ghost locked as resolved and limited conversation to collaborators on Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions