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

scalac embeds absolute file path into class files when -Xcheckinit flag is used #12698

Closed
rtar opened this issue Dec 6, 2022 · 2 comments · Fixed by scala/scala#10237
Closed
Assignees
Labels
Milestone

Comments

@rtar
Copy link

rtar commented Dec 6, 2022

Reproduction steps

Scala version: 2.13.10

object CheckInit {
  val SomeField: Int = 1
}

Problem

When compiled with -Xcheckinit flag, the code above will emit the bytecode like following:

ldc 'Uninitialized field: /home/ruslan/xcheckinit/CheckInit.scala: 2'

The problem is that it exposes absolute path of the file. It seems to be a wrong thing to do and could be a mild security risk as it exposes the directory structure from the machine it compiles on. It also makes build less reproducible.

Should not it be changed to relative path instead?

I could try to make PR for that, but I wanted to make sure it is not an intentional behavior before investing too much time into it.

One can find a responsible code here: https://github.com/scala/scala/blob/a360263370c1d9b4d26b943b1c55d8e4d6ed8360/src/compiler/scala/tools/nsc/transform/AccessorSynthesis.scala#L360

@rtar
Copy link
Author

rtar commented Dec 7, 2022

Another ticket discussing reproducible builds: scala/scala-dev#405

@SethTisue
Copy link
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants