Fatal error

I was programming as usual but after I deployed the code I got this error message:

  • A fatal error has been detected by the Java Runtime Environment:

  • SIGSEGV (0xb) at pc=0xaaee7478, pid=15488, tid=15527

  • JRE version: OpenJDK Runtime Environment (17.0.3.7) (build 17.0.3.7-frc+0-2023-17.0.5u7-1)

  • Java VM: OpenJDK Client VM (17.0.3.7-frc+0-2023-17.0.5u7-1, mixed mode, emulated-client, g1 gc, linux-arm)

  • Problematic frame:

  • C [libREVLibDriver.so+0x11478] (anonymous namespace)::HeartbeatDaemon::Main()+0x158

  • No core dump will be written. Core dumps have been disabled. To enable core dumping, try “ulimit -c unlimited” before starting Java again

  • An error report file with more information is saved as:

  • /tmp/hs_err_pid15488.log

  • If you would like to submit a bug report, please visit:

  • Crash Report

anyone has any tips on how to fix this?

  1. Please use code formatting any code or error messages you send online by surrounding it with three backticks (`) on either side.
  2. Please provide more details about your code. A link to a github repository or similar would be preferable.
1 Like

Look at the RIOlog in driverstation or VScode (or whatever IDE you’re using), it will tell you where the crash happened. This is called the ‘stacktrace’ and it will tell you what caused the code failure. If your code doesn’t build, it’ll tell you any uncaught exceptions (such as nullPointerExcpetion at [file and line#] or something like that. It’s a lot to look at, but in general if you look for any red text in the output section of driverstation or your IDE, just above or below that is where you can find the error

Why is your RobotContainer instance static? That might be causing issues.

I agree that the RobotContainer should not be static, but the reason they did that, I believe, was so that they could write code like this:

import static frc.robot.Robot.m_robotContainer;

public class shootingCommand extends CommandBase{
    @Override
    public void initialize() {
        addRequirements(m_robotContainer.getShootingSubsys());
        super.initialize();
    }

The correct way to do this is to pass the subsystem to the constructor of the class and then store it in a member variable. I note in passing that, by convention, Java class names should always start with an upper case letter. Also, this isn’t well-documented, but the requirements of a command are determined when it is scheduled, not after initialization, so the call to addRequirements also belongs in the constructor.

2 Likes

Yeah. Dependency injection, and all that.

The problem here is that making RobotContainer static in this case is more than just bad style, it’s literally the cause of this crash: static members are created on class load, which (in this case) is before the HAL is initialized. Hence, crash.

1 Like