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

Regression in sbt 1.9.5, likely zinc regression #12868

Closed
mdedetrich opened this issue Sep 14, 2023 · 30 comments
Closed

Regression in sbt 1.9.5, likely zinc regression #12868

mdedetrich opened this issue Sep 14, 2023 · 30 comments
Milestone

Comments

@mdedetrich
Copy link

mdedetrich commented Sep 14, 2023

Reproduction steps

Scala version: N/A (see PR)

Updating an existing project to SBT 1.9.5, see apache/pekko#648

Problem

[error] /home/runner/work/incubator-pekko/incubator-pekko/stream/src/main/scala/org/apache/pekko/stream/impl/io/compression/GzipDecompressor.scala:29:52: Generated class org.apache.pekko.stream.impl.io.compression.createLogic$$anon differs only in case from org.apache.pekko.stream.impl.io.compression.createLogic$$anon (defined in DeflateDecompressor.scala).
[error]   Such classes will overwrite one another on case-insensitive filesystems.
[error]   override def createLogic(attr: Attributes) = new DecompressorParsingLogic {
[error]                                                    ^
[error] /home/runner/work/incubator-pekko/incubator-pekko/stream/src/main/scala/org/apache/pekko/stream/impl/io/compression/GzipDecompressor.scala:40:26: Generated class org.apache.pekko.stream.impl.io.compression.createLogic$$anon$inflating$ differs only in case from org.apache.pekko.stream.impl.io.compression.createLogic$$anon$inflating$ (defined in DeflateDecompressor.scala).
[error]   Such classes will overwrite one another on case-insensitive filesystems.
[error]     override case object inflating extends Inflate(false) with Step
[error]                          ^
[error] two errors found

Original notes

Still need to figure out what the root cause is, basically a project (Pekko) was updated to 1.9.5 and then MiMa started complaining about bincompat issues (see https://github.com/apache/incubator-pekko/actions/runs/6182223720/job/16781910666?pr=648). My initial suspicion/hunch is that it may be due to the new compiler bridge that was added in zinc which was brought in by the new sbt version (see scala/scala#10472)

@SethTisue
Copy link
Member

SethTisue commented Sep 14, 2023

I'm testing sbt 1.9.5 in the Scala 2 community build now — perhaps that will generate some insight.

fyi @lrytz

@SethTisue SethTisue added this to the 2.13.13 milestone Sep 14, 2023
@mdedetrich
Copy link
Author

mdedetrich commented Sep 14, 2023

So I doubt that this is due to the new compiler bridge because that was added for Scala 2.13 and MiMa is complaining about Scala 2.12 artifacts.

I am looking through the various changes put into Zinc recently (which is what new sbt 1.9.5 brings in) and the only one that comes to mind is sbt/zinc#1244 (it seems to be dealing with filenames which is what MiMa is complaining about).

The inliner was also enabled in Zinc for Scala 2.13, but I seriously doubt thats the issue (this would be some serious bug in the inliner and furthermore would only be applicable if Zinc on Scala 2.13 is used to compile Scala 2.12 artifacts which I don't think is the case)

@pjfanning
Copy link

The issue occurs with sbt +compile when you compile with latest https://github.com/apache/incubator-pekko (main branch) code but with project/build.properties edited to use sbt 1.9.5. You don't need to do a Mima check to reproduce it.

I checked and it only seems to happen with sbt ++2.12 compile - it does not happen with sbt ++2.13 compile

@SethTisue
Copy link
Member

the only one that comes to mind is sbt/zinc#1244

@dwijnand wdyt, plausible culprit?

@He-Pin
Copy link
Contributor

He-Pin commented Sep 14, 2023

I tested with sbt 1.9.5 and 2.13.11, fails too.

@lrytz
Copy link
Member

lrytz commented Sep 14, 2023

MiMa started complaining

Just to clarify - is it really MiMa complaining? The error message "... differs only in case from ..." is from the compiler (https://github.com/scala/scala/blob/v2.12.18/src/compiler/scala/tools/nsc/backend/jvm/PostProcessor.scala#L104-L105)

@mdedetrich
Copy link
Author

Just to clarify - is it really MiMa complaining? The error message "... differs only in case from ..." is from the compiler (https://github.com/scala/scala/blob/v2.12.18/src/compiler/scala/tools/nsc/backend/jvm/PostProcessor.scala#L104-L105)

Your right, it happened in the MiMa step but it does seem to be the actual Scala compiler

@pjfanning
Copy link

@lrytz see #12868 (comment)

@lrytz
Copy link
Member

lrytz commented Sep 14, 2023

Created scala-steward-org/scala-steward#3167 for now -- I don't know if this would work?

@lrytz
Copy link
Member

lrytz commented Sep 14, 2023

I can confirm it's caused by sbt/zinc#1244. I'll continue digging, but probably won't have anything done during ScalaDays.

@mdedetrich
Copy link
Author

I can confirm it's caused by sbt/zinc#1244. I'll continue digging, but probably won't have anything done during ScalaDays.

Thanks for diagnosing, enjoy the conference!

@SethTisue
Copy link
Member

cc @eed3si9n

@SethTisue SethTisue changed the title Regression in latest SBT 1.9.5. which may be due to new compiler bridge in zinc/scala Regression in latest SBT 1.9.5, likely zinc regression Sep 14, 2023
@SethTisue SethTisue changed the title Regression in latest SBT 1.9.5, likely zinc regression Regression in sbt 1.9.5, likely zinc regression Sep 14, 2023
@eed3si9n
Copy link
Member

eed3si9n commented Sep 14, 2023

So at this point it may result in spurious/false warnings, and it might fail builds with fatal warnings?
Let me know how wide the impact (does it affect most builds etc), and if we need to follow up with new Zinc and sbt soon.

@lrytz
Copy link
Member

lrytz commented Sep 15, 2023

A lot of guessing here from my side as I haven't had time to look in detail, but the interaction is something like this:

We have package p { class C { def m { new anon { def sol } } } }.

The phase travel exitingFlatten added in sbt/zinc#1244 causes the (cached) flatname of ClassSymbol for the anonymous class to be computed after the flatten phase. The owner chain of the symbol is different at this point. So instead of something like p.C$m$anon we end up with only p.m$anon.

The error in pekko is due to two anonymous classes now having the same name accidentally. However, I believe that this has a broad effect, many anonymous classes will get a different name when compiling with the new zinc.

While it's possibly OK in terms of binary compatibiliy (anonymous classes cannot be referenced externally), it's still an unintended wide-reaching change.

It probably should be considered a bug in the compiler, but we cannot change existing compiler releases. The new zinc needs to continue working with existing compiler releases. Therefore I think we need to revert the change in zinc. Since poeple might start using the new sbt and publish libraries with it, we should do that rather quickly and get another sbt release out.

@mdedetrich
Copy link
Author

I agree with @lrytz here in that it seems the best course of action is to revert that PR and re-release zinc+sbt, then there is more breathing room to solve that PR properly without causing regressions.

@SethTisue
Copy link
Member

community build results:

the 2.13 builds are green

on 2.12, the akka-stream build consistently has a test failure

example failure: https://scala-ci.typesafe.com/job/scala-2.12.x-jdk8-integrate-community-build/8240/artifact/logs/akka-stream-build.log: [akka-stream] [ERROR] [SECURITY][09/14/2023 23:51:01.548] [GzipSpec-akka.test.stream-dispatcher-7] [akka.actor.ActorSystemImpl(GzipSpec)] Uncaught error from thread [GzipSpec-akka.test.stream-dispatcher-7]: Receiver class akka/stream/impl/io/compression/createLogic$$anon$inflating$ must be the current class or a subtype of interface akka/stream/impl/io/compression/createLogic$$anon$Step, shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[GzipSpec]

note that while the 2.13 build has current Akka, the 2.12 build is on a much older version

@eed3si9n I'm always happy to run new sbt versions through the community build on request, including milestones and RCs

@mdedetrich
Copy link
Author

mdedetrich commented Sep 15, 2023

note that while the 2.13 build has current Akka, the 2.12 build is on a much older version

FYI Pekko is also failing on 2.12 but with the latest Scala 2.12 scala version (i.e. 2.12.18) so I don't think the specific Scala 2.12 version makes a difference here.

@eed3si9n
Copy link
Member

Since poeple might start using the new sbt and publish libraries with it, we should do that rather quickly and get another sbt release out.

On it.

@eed3si9n
Copy link
Member

sbt 1.9.6 is released - https://eed3si9n.com/sbt-1.9.6

I merged sbt/zinc#1244 with a cursory review (it looked ok to me), so I take responsibility on this regression. IT’S ME HI.

@eed3si9n
Copy link
Member

Closing this as resolved.

@lrytz
Copy link
Member

lrytz commented Sep 15, 2023

Thanks Eugene!

I merged sbt/zinc#1244 with a cursory review (it looked ok to me), so I take responsibility on this regression

I don't think anyone would have spotted that during review...

@SethTisue
Copy link
Member

@eed3si9n i agree, this was unlikely to have been caught in advance by a human reviewer. but the community build did catch it, so ( later, after we catch our breath) maybe we could work out a way for me to help test sbt changes and/or zinc changes there, hopefully without much extra effort from your side being needed

I’m interested both in a test-all-of-sbt option, and perhaps in a test-new-zinc-with-existing-sbt option as well?

@eed3si9n
Copy link
Member

Yea, in general future Zinc changes should probably go through some testing, even when they look somewhat innocuous.

@mkurz
Copy link

mkurz commented Sep 15, 2023

So... if I just published a bunch of libraries including Play to maven central using sbt 1.9.5 it's better to re-publish them again with 1.9.6? 😢

@eed3si9n
Copy link
Member

Yea, I think it's a judgement call since the definition and call site of a lambda is closed within your own library, but it's definitely an odd duck name mangling. Given the wide usage of Play, it might be safe to republish?

@mkurz
Copy link

mkurz commented Sep 15, 2023

Given the wide usage of Play, it might be safe to republish?

I think so. Anyway, thank you for the excellent and continuous work on sbt 👍

@mdedetrich
Copy link
Author

Just wanted to say that SBT 1.9.6 solves the problem with Pekko, so I can confirm that sbt/zinc#1244 was indeed the culprit

@mkurz
Copy link

mkurz commented Sep 15, 2023

sbt/sbt#7382

sbt 1.9.6 still seems to have the Zinc issue

?

@eed3si9n
Copy link
Member

@mkurz That seems to be an unrelated issue from this one.

@mkurz
Copy link

mkurz commented Sep 15, 2023

Told scala-steward to hold back the already published artifacts, like you did with sbt 1.9.5:

cwienberg pushed a commit to cwienberg/spark-sorting-helpers that referenced this issue Sep 16, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [sbt/sbt](https://togithub.com/sbt/sbt) | patch | `1.9.4` -> `1.9.6` |

---

### Release Notes

<details>
<summary>sbt/sbt (sbt/sbt)</summary>

### [`v1.9.6`](https://togithub.com/sbt/sbt/releases/tag/v1.9.6): 1.9.6

[Compare Source](https://togithub.com/sbt/sbt/compare/v1.9.5...v1.9.6)

#### bug fix

- sbt 1.9.6 reverts "internal representation of class symbol names"
change
([sbt/zinc#1244),
which caused Scala compiler to generate wrong anonymous class name by
[@&#8203;eed3si9n](https://togithub.com/eed3si9n) in
[sbt/zinc#1256.
See
[scala/bug#12868
for more details.

**Full Changelog**: sbt/sbt@v1.9.5...v1.9.6

### [`v1.9.5`](https://togithub.com/sbt/sbt/releases/tag/v1.9.5): 1.9.5

[Compare Source](https://togithub.com/sbt/sbt/compare/v1.9.4...v1.9.5)

#### highlights

- Switches to pre-compiled compiler bridge for Scala 2.13.12+
[#&#8203;7374][7374] by [@&#8203;eed3si9n][@&#8203;eed3si9n]
- Fixes NPE when just `-X` is passed to `scalacOptions`
[zinc#1246][zinc1246] by [@&#8203;unkarjedy][@&#8203;unkarjedy]

#### other updates

- Fixes internal representation of class symbol names
[zinc#1244][zinc1244] by [@&#8203;dwijnand][@&#8203;dwijnand]
- Fixes `NumberFormatException` in `CrossVersionUtil.binaryScalaVersion`
[lm#426][lm426] by [@&#8203;HelloKunal][@&#8203;HelloKunal]
- Fixes `scripted` client/server instability on Windows
[#&#8203;7087][7087] by [@&#8203;mdedetrich][@&#8203;mdedetrich]
- Fixes `sbt` launcher script bug on Windows [#&#8203;7365][7365] by
[@&#8203;JD557][@&#8203;JD557]
- Fixes `help` command on oldshell [#&#8203;7358][7358] by
[@&#8203;azdrojowa123][@&#8203;azdrojowa123]
- Adds `allModuleReports` to `UpdateReport` [lm#428][lm428] by
[@&#8203;mdedetrich][@&#8203;mdedetrich]
- Handles javac warning messages [zinc#1228][zinc1228] by
[@&#8203;Arthurm1][@&#8203;Arthurm1]
- Enables inliner for Scala 2.13 compiler bridge [zinc#1247][zinc1247]
by [@&#8203;mdedetrich][@&#8203;mdedetrich]

#### new contributors

- [@&#8203;azdrojowa123](https://togithub.com/azdrojowa123) made their
first contribution in
[sbt/sbt#7358
- [@&#8203;JD557](https://togithub.com/JD557) made their first
contribution in
[sbt/sbt#7367

**Full Changelog**: sbt/sbt@v1.9.4...v1.9.5

[@&#8203;eed3si9n]: https://togithub.com/eed3si9n

[@&#8203;Nirvikalpa108]: https://togithub.com/Nirvikalpa108

[@&#8203;adpi2]: https://togithub.com/adpi2

[@&#8203;er1c]: https://togithub.com/er1c

[@&#8203;eatkins]: https://togithub.com/eatkins

[@&#8203;dwijnand]: https://togithub.com/dwijnand

[@&#8203;mdedetrich]: https://togithub.com/mdedetrich

[@&#8203;JD557]: https://togithub.com/JD557

[@&#8203;azdrojowa123]: https://togithub.com/azdrojowa123

[@&#8203;HelloKunal]: https://togithub.com/HelloKunal

[@&#8203;unkarjedy]: https://togithub.com/unkarjedy

[@&#8203;Arthurm1]: https://togithub.com/Arthurm1

[7374]: https://togithub.com/sbt/sbt/pull/7374

[7087]: https://togithub.com/sbt/sbt/pull/7087

[7365]: https://togithub.com/sbt/sbt/issues/7365

[7358]: https://togithub.com/sbt/sbt/pull/7358

[zinc1246]: https://togithub.com/sbt/zinc/pull/1246

[zinc1244]: https://togithub.com/sbt/zinc/pull/1244

[zinc1228]: https://togithub.com/sbt/zinc/pull/1228

[zinc1247]: https://togithub.com/sbt/zinc/pull/1247

[lm426]: https://togithub.com/sbt/librarymanagement/pull/426

[lm428]: https://togithub.com/sbt/librarymanagement/pull/428

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/cwienberg/spark-sorting-helpers).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi44My4wIiwidXBkYXRlZEluVmVyIjoiMzYuODMuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants