I was trying out unit testing on a robot with CTRE Talons/Victors, and am getting strange crashes as the test winds up, that do not happen with other motor types. Not sure if it’s a CTRE thing or a Mac thing, hoping some people can try this out for me.
> Task :test FAILED
HAL Extensions: No extensions found
frc.robot.subsystems.MotorTest > dosomething PASSED
libc++abi: terminating with uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> Process 'Gradle Test Executor 3' finished with non-zero exit value 134
This problem might be caused by incorrect test process configuration.
Please refer to the test execution section in the User Manual at https://docs.gradle.org/7.3.3/userguide/java_testing.html#sec:test_execution
If I use the REV motor:
> Task :test
HAL Extensions: No extensions found
frc.robot.subsystems.MotorTest > dosomething PASSED
BUILD SUCCESSFUL in 1s
4 actionable tasks: 2 executed, 2 up-to-date
Hoping I can get someone to try it on Windows and Mac, since all I have here is the Mac.
This type of failure is not uncommon on Mac and is unique to Mac. The root cause is typically a thread that uses a global mutex, and on program shutdown, the mutex getting destroyed (since it’s a global) prior to the thread exiting, resulting in the thread attempting to lock or unlock a destroyed mutex. On other operating systems, this is ignored, but Mac’s libc throws an exception.
This exact failure mechanism is why I wrote the SafeThread class in wpiutil, which sets things up to avoid the mutex destruction race (and also avoids shutdown deadlocks).
It’ll also be available in the next full release, but there’s no ETA on when we’ll cut a new release.
Anyone is able to use the dev build in the meantime, however.