Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
marklam opened this issue Jun 19, 2018 · 14 comments · Fixed by #6609
Closed

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

marklam opened this issue Jun 19, 2018 · 14 comments · Fixed by #6609
Labels
Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone

Comments

@marklam
Copy link

marklam commented Jun 19, 2018

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
@dsyme
Copy link
Contributor

dsyme commented Jun 19, 2018

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. ??

@cartermp
Copy link
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)

@dsyme
Copy link
Contributor

dsyme commented Jun 19, 2018

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.

@nosami
Copy link
Contributor

nosami commented Jun 19, 2018

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

@cartermp
Copy link
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.

@cartermp cartermp added Area-Compiler Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. labels Jun 19, 2018
@cartermp
Copy link
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.

@0x53A
Copy link
Contributor

0x53A commented Jun 20, 2018

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

@marklam
Copy link
Author

marklam commented Jun 20, 2018

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.

@0x53A
Copy link
Contributor

0x53A commented Jun 20, 2018

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

@saul
Copy link
Contributor

saul commented Oct 18, 2018

Linking #3812

@cartermp cartermp added this to the 16.0 milestone Oct 19, 2018
@NinoFloris
Copy link
Contributor

NinoFloris commented Dec 3, 2018

@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?

@7sharp9
Copy link
Contributor

7sharp9 commented Dec 3, 2018

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

@NinoFloris
Copy link
Contributor

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

@cartermp cartermp modified the milestones: 16.0, 16.1 Feb 21, 2019
@cartermp cartermp modified the milestones: 16.1, 16.2 Apr 23, 2019
@cartermp cartermp modified the milestones: 16.2, 16.1 Apr 24, 2019
@cartermp
Copy link
Contributor

Re-opening as this is not resolved in VS

@cartermp cartermp reopened this May 29, 2019
@cartermp cartermp modified the milestones: 16.1, 16.2 Jul 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants