scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

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

Closed rtar closed 1 year ago

rtar commented 1 year ago

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 commented 1 year ago

Another ticket discussing reproducible builds: https://github.com/scala/scala-dev/issues/405

SethTisue commented 1 year ago

Thank you!