Skip to content

Signature data embedded in executable contains absolute source file path #5213

Closed

Description

@marklam

The FSharpSignatureData resource embedded in the assembly contains absolute paths to the source files. This could include a user's real name etc.
I know this info is in the pdb, but shipping that with an executable is optional.
Executables produced from C# compiler don't contain file paths

Repro steps

Provide the steps required to reproduce the problem

  1. Create a simple test.fs containing, say, let main argv = 1
  2. fsc test.fs
  3. strings test.exe
  4. observe the full path to test.fs

Expected behavior

No source paths in the exe

Actual behavior

Absolute paths are embedded in the FSharpSignatureData resource

Known workarounds

Provide a description of any known workarounds.

Related information

Provide any related information

  • Windows
  • Microsoft (R) F# Compiler version 10.1.0 for F# 4.1
  • .NET Runtime

Activity

  1. dsyme commented on Jun 19, 2018

    @dsyme
    Contributor

    I believe this is the only place where the file names are stored:

    Before we just set this to "null", I should add that these file names are utilised by the F# IDE Tools to allow goto-definition and other things to work when

    1. in-memory cross-project references are off and
    2. you're referencing DLL components compiled on your machine.

    This means go-to-definition will start failing for these cases if the file name information is just removed.

    Alternatives might be

    1. add a compiler option to suppress the generation of this information
    2. add a compiler option to opt-in to include this information which is set when compiling from visual studio, or only set for Debug code
    3. ??
  2. cartermp commented on Jun 19, 2018

    @cartermp
    Contributor

    or only set for Debug code

    Seems like the right call to me. Though we'll also want to make sure this doesn't negatively affect other editors (@auduchinok / @Krzysztof-Cieslak / @nosami FYI)

  3. dsyme commented on Jun 19, 2018

    @dsyme
    Contributor

    or only set for Debug code

    I think it would be really odd if GTD only worked across compiled assembly boundaries for Debug mode.... No other design-time tooling depends on this like this....

    Though we'll also want to make sure this doesn't negatively affect other editors (@auduchinok / @Krzysztof-Cieslak / @nosami FYI)

    I think it would.

  4. nosami commented on Jun 19, 2018

    @nosami
    Contributor

    VSMac can't turn off in-memory cross-project references. I would like to add this feature soon though.

  5. cartermp commented on Jun 19, 2018

    @cartermp
    Contributor

    Hmmm. Well I think that from a tooling perspective there's no issue in having this info. What I think I'd prefer is a way to specify a default where this info is not present when building, and have things like design-time builds kick with that feature turned on.

  6. added
    Impact-Medium
    on Jun 19, 2018
  7. cartermp commented on Jun 19, 2018

    @cartermp
    Contributor

    Here's what should happen:

    1. Ensure that in release builds with the F# compiler, this is OFF by default.
    2. In a tooling environment, this is ON by default.
    3. Tools can detect when this is off and can offer to turn them on somehow.
    4. Docs, etc. so that people know about the switch and can configure it for their environments.

    I've labeled this as Urgency-Soon for now, but this is arguably Urgency-Now.

  8. 0x53A commented on Jun 20, 2018

    @0x53A
    Contributor

    Are you sure the c# compiler doesn't embed any absolute paths?

    As far as I know the exe contains an absolute path to the pdb, unless you specifically set a few flags.

    Edit: this is built with VS2017, C# dll, all options the default ones:

    image

  9. marklam commented on Jun 20, 2018

    @marklam
    Author

    For a file test.cs, containing
    class test { public static int Main(string[] args) { return 1; } }
    Compile with csc test.cs
    Opening test.exe in the binary editor shows no pathnames.

  10. 0x53A commented on Jun 20, 2018

    @0x53A
    Contributor

    yes, F# is a little bit worse. C# only embeds the absolute path if you generate a pdb, F# does it always.

    You can try it with -pdb, then you should also see a path in C#. (-pdb is the default for a csproj)

    I see value in having a way to suppress this (mostly for deterministic builds), but I don't think it should be enabled by default (even in release) if tooling suffers.

    Edit:

    C# allows you to map paths with -pathmap.

    I edited my csproj and added <PathMap>C:\temp\KoalaTest=/</PathMap>.

    Result:

    image

    So instead of blindly and in a hurry nulling out the value, please consider implementing the proper c# solution

  11. saul commented on Oct 18, 2018

    @saul
    Contributor

    Linking #3812

  12. added this to the 16.0 milestone on Oct 19, 2018
  13. NinoFloris commented on Dec 3, 2018

    @NinoFloris
    Contributor

    @saul I think F# should do deterministic paths by default when compiling with pdb, like C#. Is PathMap implementation the first step towards doing that or, should it be a native compiler feature?

  14. 7sharp9 commented on Dec 3, 2018

    @7sharp9
    Contributor

    I just looked in a release build and found this and others:

    ...
    Map`2�TypeKindTypeResolvergetShortName�fullName	allScopes�seq`1
    discoverTypes	ProtoFile�file
    resolveScalar�option`1�_arg1
    ptypeToString�resolveNonScalar
    targetType�resolveresolvePTypeA/Users/dave.thomas/Documents/GitHub/falanx/Falanx.Proto.Generator
    
  15. NinoFloris commented on Dec 3, 2018

    @NinoFloris
    Contributor

    Yeah it's everywhere in F# ecosystem, taskbuilder, saturn, giraffe all have (fun localized) user paths in there.

  16. modified the milestones: 16.0, 16.1 on Feb 21, 2019
  17. modified the milestones: 16.1, 16.2 on Apr 23, 2019
  18. modified the milestones: 16.2, 16.1 on Apr 24, 2019
  19. cartermp commented on May 29, 2019

    @cartermp
    Contributor

    Re-opening as this is not resolved in VS

  20. modified the milestones: 16.1, 16.2 on Jul 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Impact-Medium

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions