FRC-1721 / 1721-ChargedUp

2 stars 0 forks source link

Segfault in #26 #27

Closed KenwoodFox closed 1 year ago

KenwoodFox commented 1 year ago

This is really similar to the issue we had last time where the error is our fault but the traceback is too nondescript to figure out what it is.

❯ make sim
python robot.py sim
[phoenix] CANbus Connected: sim
[phoenix] CANbus Network Up: sim
/home/joe/git/concord_robotics/1721-ChargedUp/rio/subsystems/drivesubsystem.py:20: FutureWarning: ctre.Pigeon2 has moved to ctre.sensors
  from ctre import Pigeon2
INFO:wpilib:WPILib version 2023.4.1.0
11:23:57:222 INFO    : wpilib              : WPILib version 2023.4.1.0
INFO:wpilib:HAL version 2023.4.1.0
11:23:57:222 INFO    : wpilib              : HAL version 2023.4.1.0
INFO:wpilib:Running with simulated HAL.
11:23:57:222 INFO    : wpilib              : Running with simulated HAL.
INFO:wpilib:pyntcore version 2023.4.1.1
11:23:57:222 INFO    : wpilib              : pyntcore version 2023.4.1.1
INFO:wpilib:robotpy-commands-v2 version 2023.4.1.0
11:23:57:222 INFO    : wpilib              : robotpy-commands-v2 version 2023.4.1.0
INFO:wpilib:robotpy-ctre version 2023.1.0
11:23:57:222 INFO    : wpilib              : robotpy-ctre version 2023.1.0
INFO:wpilib:robotpy-halsim-gui version 2023.4.1.0
11:23:57:222 INFO    : wpilib              : robotpy-halsim-gui version 2023.4.1.0
INFO:wpilib:robotpy-navx version 2023.0.3
11:23:57:223 INFO    : wpilib              : robotpy-navx version 2023.0.3
INFO:wpilib:robotpy-pathplannerlib version 2023.3.4.1
11:23:57:223 INFO    : wpilib              : robotpy-pathplannerlib version 2023.3.4.1
INFO:wpilib:robotpy-rev version 2023.1.3.2
11:23:57:223 INFO    : wpilib              : robotpy-rev version 2023.1.3.2
INFO:wpilib:robotpy-wpimath version 2023.4.1.0
11:23:57:223 INFO    : wpilib              : robotpy-wpimath version 2023.4.1.0
INFO:wpilib:robotpy-wpinet version 2023.4.1.0
11:23:57:223 INFO    : wpilib              : robotpy-wpinet version 2023.4.1.0
INFO:wpilib:robotpy-wpiutil version 2023.4.1.0
11:23:57:223 INFO    : wpilib              : robotpy-wpiutil version 2023.4.1.0
INFO:faulthandler:registered SIGUSR2 for PID 470660
11:23:57:223 INFO    : faulthandler        : registered SIGUSR2 for PID 470660
INFO:halsim_gui:WPILib HAL Simulation 2023.4.1.0
11:23:57:224 INFO    : halsim_gui          : WPILib HAL Simulation 2023.4.1.0
HAL Extensions: Attempting to load: libhalsim_gui
Simulator GUI Initializing.
Simulator GUI Initialized!
HAL Extensions: Successfully loaded extension
INFO:pyfrc.physics:Physics support successfully enabled
11:23:58:595 INFO    : pyfrc.physics       : Physics support successfully enabled
INFO:nt:Listening on NT3 port 1735, NT4 port 5810
11:23:58:599 INFO    : nt                  : Listening on NT3 port 1735, NT4 port 5810
Not loading CameraServerShared
Instantiating navX-Sensor on SPI Port 4.
navX-Sensor C++ library for FRC
navX-Sensor SimDevice created.
Warning: Joystick Button 1 missing (max 0), check if all controllers are plugged in
  File "/home/joe/.local/share/virtualenvs/rio-pTRoqLhR/lib/python3.10/site-packages/wpilib/_impl/start.py", line 163, in _start
    self.robot.startCompetition()

  File "/home/joe/git/concord_robotics/1721-ChargedUp/rio/robot.py", line 41, in robotInit
    self.container = robotcontainer.RobotContainer()

  File "/home/joe/git/concord_robotics/1721-ChargedUp/rio/robotcontainer.py", line 74, in __init__
    self.configureButtonBindings()

  File "/home/joe/git/concord_robotics/1721-ChargedUp/rio/robotcontainer.py", line 114, in configureButtonBindings
    ).onTrue(

Fatal Python error: Segmentation fault

Thread 0x00007fe3bdffb6c0 (most recent call first):
  <no Python frame>

Thread 0x00007fe3be7fc6c0 (most recent call first):
  <no Python frame>

Thread 0x00007fe3c5ffd6c0 (most recent call first):
  <no Python frame>

Thread 0x00007fe3c67fe6c0 (most recent call first):
  File "/home/joe/.local/share/virtualenvs/rio-pTRoqLhR/lib/python3.10/site-packages/ntcore/_logutil.py", line 94 in _logging_thread
  File "/usr/lib/python3.10/threading.py", line 953 in run
  File "/usr/lib/python3.10/threading.py", line 1016 in _bootstrap_inner
  File "/usr/lib/python3.10/threading.py", line 973 in _bootstrap

Current thread 0x00007fe3c6fff6c0 (most recent call first):
  File "/home/joe/git/concord_robotics/1721-ChargedUp/rio/autonomous/curvyAuto.py", line 23 in __init__
  File "/home/joe/git/concord_robotics/1721-ChargedUp/rio/robotcontainer.py", line 172 in configureAutonomous
  File "/home/joe/git/concord_robotics/1721-ChargedUp/rio/robotcontainer.py", line 77 in __init__
  File "/home/joe/git/concord_robotics/1721-ChargedUp/rio/robot.py", line 41 in robotInit
  File "/home/joe/.local/share/virtualenvs/rio-pTRoqLhR/lib/python3.10/site-packages/wpilib/_impl/start.py", line 163 in _start
  File "/home/joe/.local/share/virtualenvs/rio-pTRoqLhR/lib/python3.10/site-packages/wpilib/_impl/start.py", line 75 in start
  File "/home/joe/.local/share/virtualenvs/rio-pTRoqLhR/lib/python3.10/site-packages/wpilib/_impl/start.py", line 35 in _start
  File "/usr/lib/python3.10/threading.py", line 953 in run
  File "/usr/lib/python3.10/threading.py", line 1016 in _bootstrap_inner
  File "/usr/lib/python3.10/threading.py", line 973 in _bootstrap

Thread 0x00007fe420a84740 (most recent call first):
  File "/home/joe/.local/share/virtualenvs/rio-pTRoqLhR/lib/python3.10/site-packages/wpilib/_impl/start.py", line 42 in run
  File "/home/joe/.local/share/virtualenvs/rio-pTRoqLhR/lib/python3.10/site-packages/pyfrc/mains/cli_sim.py", line 85 in run
  File "/home/joe/.local/share/virtualenvs/rio-pTRoqLhR/lib/python3.10/site-packages/wpilib/_impl/main.py", line 210 in run
  File "/home/joe/git/concord_robotics/1721-ChargedUp/rio/robot.py", line 83 in <module>

Extension modules: yaml._yaml, _cffi_backend (total: 2)
make: *** [Makefile:28: sim] Segmentation fault (core dumped)

I did a git bisect and obvio its between 30ff3ef2bb26232b802406fa24b342e137fc86d5 and 1d3d55eb7db793f9fbe09c81884c8dbdefc3776e

KenwoodFox commented 1 year ago

It errors right here: https://github.com/FRC-1721/1721-ChargedUp/blob/1d3d55eb7db793f9fbe09c81884c8dbdefc3776e/rio/robotcontainer.py#L114

but it will error on any instance of .onTrue, .whileHeld that it finds first.

KenwoodFox commented 1 year ago

Gitter conversation here: https://matrix.to/#/!ICEKWCwDAlQaySZjLv:gitter.im/$kukNsXJ23B9KyQJmXTdOjhclS2MgVbLXW5I52BDRHpo?via=gitter.im&via=matrix.org&via=vovo.id.au

virtuald commented 1 year ago

I looked at this a bit tonight. There's definitely a bug on the RobotPy side, but it doesn't seem to be explicitly about the buttons. There's something more complex going wrong here, it actually seems to be related to the addRequirements method of various commands. I'll have to dig into it tomorrow evening.

virtuald commented 1 year ago

Oh, I figured it out.

The problem is actually in CurvyAuto. You called addRequirements before calling super().__init__(...), which is not ever allowed. Unfortunately, there's not a ton we can do to stop you from encountering this error, but I'll think about it.

KenwoodFox commented 1 year ago

Yep! This is it thank you! Also replied on gitter as well. Makes perfect sense now, a way for the error to be a little more descript would be nice but i know its tough.

Fixed in https://github.com/FRC-1721/1721-ChargedUp/commit/45053d49c94d1a6009a80e754a5b313daba06bd5