Skip to content

Conversation

@som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Dec 2, 2025

Save and restore stdio in the test rig child process.

Also add a test from the duplicate ticket for 23245.

@hamzaremmal
Copy link
Member

Maybe there's no more skipping...

There is no more skipping.

@som-snytt
Copy link
Contributor Author

Added a bit of output for more stack trace. The test will always fail, to make re-running easier.

My first guess was NPE in clinit. My second guess was a bad "nullable field" getting nulled after lazy val init; perhaps the outer pointer itself, which was used only for the lazy init. But the outer is not a class param in the example; its rhs is just a static module. Maybe the trait init? but that is empty. Maybe a class isn't initialized? Maybe a missing inner class, except the module is top level.

I could not replicate locally (WSL) but interacting with the test rig made me want to contribute improvements, as I intended.

I see that the flaky test is not included in the group with -Ylegacy-lazy-vals, which was my fourth guess.

@som-snytt
Copy link
Contributor Author

Woo-hoo!

Output from 'tests/run/i23245a' did not match check file. Actual output:
java.lang.NullPointerException: Cannot invoke "java.io.PrintStream.println(String)" because "java.lang.System.err" is null
	at logadapter.LogAdapter.info(api.scala:23)
	at Test$.main(test_2.scala:3)
	at Test.main(test_2.scala)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at dotty.tools.vulpix.ChildJVMMain.runMain(ChildJVMMain.java:40)
	at dotty.tools.vulpix.ChildJVMMain.main(ChildJVMMain.java:47)

Oh wait, does that make any sense? I'll look at it later.

@som-snytt som-snytt force-pushed the issue/23245-breakage branch 2 times, most recently from d3fae08 to 7d224c9 Compare December 17, 2025 20:09
@som-snytt
Copy link
Contributor Author

som-snytt commented Dec 17, 2025

The test for #2781 was aware that nulling stdio streams is unfriendly, but did it anyway, in the interests of science.

Any test thereafter in the same runner JVM that used System.err, including the default exception handler in doing e.printStackTrace(), would throw NPE.

This doesn't seem to be a rampant problem, but for safety, the ChildJVMMain that communicates with the test rig now saves and restores stdio.

Equivalent in partest:

https://github.com/scala/scala/blob/v2.13.18/src/partest/scala/tools/partest/nest/Runner.scala#L242

@som-snytt som-snytt changed the title Issue/23245 breakage Restore stdio in test rig Dec 17, 2025
@som-snytt som-snytt marked this pull request as ready for review December 17, 2025 20:30
runMain(stdin.readLine());
}
finally {
if (err != System.err) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why branch here? we can just call System.setErr regardless of if it changed or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be finicky. I needed a block for a println while verifying, and then I decided to avoid any side-effects, however benign, of calling the setter.

Most of my time was spent formatting the Java code.

Worth adding that this class could be written in Scala.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I have an opportunity edit it again anyway. I requested your review because of your proximate interest in the build passing correctly. By proximate, I mean near and dear to your heart.

@som-snytt som-snytt force-pushed the issue/23245-breakage branch from 7d224c9 to 47abcd0 Compare December 18, 2025 04:53
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

Successfully merging this pull request may close these issues.

2 participants