scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.73k stars 1.04k forks source link

Nightly Dotty workflow of 2024-03-05 failed #19879

Open github-actions[bot] opened 4 months ago

github-actions[bot] commented 4 months ago

See https://github.com/lampepfl/dotty/actions/runs/8150374165

nicolasstucki commented 4 months ago
Error:  Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "java.util.HashMap.get(Object)" is null
Error:      at com.vladsch.flexmark.html.renderer.HeaderIdGenerator.generateId(HeaderIdGenerator.java:124)
Error:      at com.vladsch.flexmark.html.renderer.HeaderIdGenerator.getId(HeaderIdGenerator.java:148)
Error:      at dotty.tools.scaladoc.tasty.comments.markdown.SectionRenderingExtension$SectionHandler$.render(SectionRenderingExtension.scala:38)
Error:      at dotty.tools.scaladoc.tasty.comments.markdown.SectionRenderingExtension$SectionHandler$.render(SectionRenderingExtension.scala:32)
Error:      at com.vladsch.flexmark.html.renderer.NodeRenderingHandler.render(NodeRenderingHandler.java:16)
Error:      at com.vladsch.flexmark.html.HtmlRenderer$MainNodeRenderer.renderNode(HtmlRenderer.java:779)
Error:      at 
...
sjrd commented 4 months ago

According to the CI build history for pushes on main, this was broken by https://github.com/lampepfl/dotty/pull/19860

/cc @Linyxus

This needs to be addressed today, as we're moving the repo tomorrow morning and we need the CI to be working at that time. If it's not fixed by 3pm, I will revert the PR.

sjrd commented 4 months ago

Reverting #19860 does not fix the issue. Any idea what else could have caused this?

dwijnand commented 4 months ago

Duplicate of #18344

details in https://github.com/lampepfl/dotty/issues/19524#issuecomment-1910357898

cc @Florian3k

sjrd commented 4 months ago

Huh. It's been quite consistent in the past few builds, though.

dwijnand commented 4 months ago

Yeah, it's a not-too-often flaky failure. But there's a whole bunch of backreferences to the various duplicates

dwijnand commented 4 months ago

I think it's a race-condition:

                if (headerBaseIds.containsKey(baseRefId)) {
                    int index = headerBaseIds.get(baseRefId);

                    index++;
                    headerBaseIds.put(baseRefId, index);
                    baseRefId += "-" + index;
                } else {
                    headerBaseIds.put(baseRefId, 0);
                }

The get is being called concurrently while one of those puts caused the hashmap to rehash its internal table. I'm not sure, though, how we fix that in SectionRenderingExtension.SectionHandler...

Florian3k commented 4 months ago

We may put this as a temporary fix in SectionRenderingExtension.scala:

val id = idGenerator.synchronized:
  idGenerator.getId(headerText + ifSuffixStr)

Not sure how much this will affect performance, but I guess it's better than nothing for now.

sjrd commented 4 months ago

Yes, let's do that. Can you send a PR?