-
Notifications
You must be signed in to change notification settings - Fork 669
Description
Describe the bug
We have tests for code that uses Preferences where we create a new NetworkTableInstance per test. The tests use a JUnit Rule (source code) that creates a unique NetworkTableInstance instance before each test is run.
All interactions with the NetworkTableInstance created by the rule are performed in the same thread.
As we have added more of these tests, we were increasingly getting test failures in GitHub workflows due to the JVM dying with a SIGSEGV.
The tests consistently pass for me when running locally via Gradle.
The relevant lines of the JVM error file appear to be:
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J 1843 edu.wpi.first.networktables.NetworkTablesJNI.setTopicPersistent(IZ)V (0 bytes) @ 0x00007ff978d647ec [0x00007ff978d647a0+0x000000000000004c]
j edu.wpi.first.networktables.Topic.setPersistent(Z)V+5
j edu.wpi.first.wpilibj.Preferences.lambda$setNetworkTableInstance$0(Ledu/wpi/first/networktables/NetworkTableEvent;)V+38
j edu.wpi.first.wpilibj.Preferences$$Lambda$491+0x00007ff9141a5208.accept(Ljava/lang/Object;)V+4
J 1835 c1 edu.wpi.first.networktables.NetworkTableInstance$ListenerStorage.lambda$startThread$0()V (327 bytes) @ 0x00007ff971574684 [0x00007ff971573a80+0x0000000000000c04]
j edu.wpi.first.networktables.NetworkTableInstance$ListenerStorage$$Lambda$492+0x00007ff9141a5660.run()V+4
j java.lang.Thread.run()V+11 [email protected]
v ~StubRoutines::call_stub
Edit: There appears to be two underlying causes:
- NetworkTable Listeners can be called after they have been removed (and after the NetworkTable Instance has been closed)
Preferencesinstalls a listener that reads from and updates topics
If the first issue is fixed, the second one would not necessarily have to be fixed. I'm not sure how hard the first issue would be to fix. I'm also not sure if updating topics in a listener is a supported use case.
In our team's robot code these issues was "solved" this by adding a small delay between calling Preferences.setNetworkTableInstance(NetworkTableInstance.getDefault()) and closing the previously-set NetworkTableInstance (code). Looking at the comments on this issue that might not be safe. A less hacky solution can be found here.
Links
Desktop (please complete the following information):
- OS: MacOS 15.5 (note: issue does not reproduce locally)
- Project Information:
WPILib Information:
Project Version: 2025.3.1
VS Code Version: 1.96.2
WPILib Extension Version: 2025.2.1
C++ Extension Version: 1.23.2
Java Extension Version: 1.43.1
Java Debug Extension Version: 0.58.2
Java Dependencies Extension Version 0.24.1
Java Version: 17
Java Location: /Users/kevincooney/wpilib/2025/jdk
Vendor Libraries:
PathplannerLib (2025.2.1)
CTRE-Phoenix (v5) (5.35.1)
CTRE-Phoenix (v6) (25.2.1)
REVLib (2025.0.1)
WPILib-New-Commands (1.0.0)
photonlib (v2025.3.2)