HipsterSloth / PSVRTracker

A sample app demonstrating position and orientation tracking for the PSVR headset
MIT License
37 stars 12 forks source link

PS3EyeTracker::open crashes (segfault) on empty TrackerCapabilitiesSet::m_supportedTrackers. #17

Closed m-7761 closed 5 years ago

m-7761 commented 5 years ago

FYI: m_capabilities is a pointer initialized to nullptr here. I think maybe a JSON file is missing or something, but the pointer is dereferenced either way.

        // Fetch the camera capabilities
        m_capabilities= usb_tracker_enumerator->getTrackerCapabilities();

        // If no mode is specified, then default to the first mode
        if (m_cfg.current_mode == "")
        {
            m_cfg.current_mode= m_capabilities->supportedModes[0].modeName;
        }

        // Find the camera mode by name
        m_currentMode= m_capabilities->findCameraMode(m_cfg.current_mode);

m_supportedTrackers is empty so getTrackerCapabilities returns nullptr.

class TrackerCapabilitiesSet
{
public:
    void reloadSupportedTrackerCapabilities();
    bool supportsTracker(unsigned short vendor_id, unsigned short product_id) const;
    CommonSensorState::eDeviceType findTrackerType(unsigned short vendor_id, unsigned short product_id) const;
    const TrackerCapabilitiesConfig *getTrackerCapabilities(unsigned short vendor_id, unsigned short product_id) const;

private:
    std::vector<TrackerCapabilitiesConfig> m_supportedTrackers;
};
HipsterSloth commented 5 years ago

I think this is because the working directory is set incorrectly in the debugger (see other issue). Those capabilities are supposed to come from the bin\resources\supported_trackers folder.

m-7761 commented 5 years ago

That's my hunch, but I am going to try again today. Still there needs to be a nullptr check. It's not too much trouble to report, but even if I could code a fix (generally I won't take the time to do a PR because it's too much work to work into my day to day) I think you need to decide on how to handle that case appropriately. Just reporting findings. (Not setting the working directory shouldn't crash, obviously.)