Skip to content

Constructing an A301 on a Motioncore bus segfaults in sim #387

Description

@auscompgeek

The first::a301::A301 constructor segfaults in simulation when passed a Motioncore CAN bus ID.

I encountered this when updating robotpy-rev to the latest REVLib today. I haven't attempted to reproduce this on real hardware (as I don't have an A301 or Motioncore).

In C++ this might look like:

#include "first/A301.h"
#include "wpi/framework/TimedRobot.hpp"
#include "wpi/hardware/bus/CANPort.hpp"

class Robot : public wpi::TimedRobot {
  first::a301::A301 motor1{wpi::CANPort::CAN_D0};
  first::a301::A301 motor2{wpi::CANPort::CAN_D19, 1};
}

With the builds from robotpy/robotpy-rev#94 calling it from a REPL is also enough to reproduce:

import rev
import wpilib

rev.A301(wpilib.CANPort.CAN_D0)
rev.A301(wpilib.CANPort.CAN_D1, 1)

This segfault doesn't occur with a SparkMax, nor does it occur when instantiating an A301 on a Systemcore CAN bus (as exercised by robotpy-rev tests); it's specific to specifying a Motioncore bus.

Here's a backtrace from gdb:

#0  0x00007fffe4a1dca4 in (anonymous namespace)::A301_AutoDetectDeviceId(int) ()
   from /home/davo/git/robotpy/robotpy-rev/rev/_rev.cpython-312-x86_64-linux-gnu.so
#1  0x00007fffe4a1e8b5 in c_A301_RegisterId () from /home/davo/git/robotpy/robotpy-rev/rev/_rev.cpython-312-x86_64-linux-gnu.so
#2  0x00007fffe4a04de2 in first::a301::internal::A301::A301(int, int) ()
   from /home/davo/git/robotpy/robotpy-rev/rev/_rev.cpython-312-x86_64-linux-gnu.so
#3  0x00007fffe4a0498c in first::a301::A301::A301(wpi::CANPort, int) ()
   from /home/davo/git/robotpy/robotpy-rev/rev/_rev.cpython-312-x86_64-linux-gnu.so
  • REVLib 2027.0.0-alpha-7
  • Linux (Fedora 44, also reproducible in a Debian 13 container)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions