EasternEdgeRobotics / Software_2017

The control software for 2017
MIT License
3 stars 0 forks source link

Shutdown hook causes Rov program to hang. (deadlock in spinlock) #283

Closed cal-pratt closed 7 years ago

cal-pratt commented 7 years ago

If the software doesn't launch correctly (such that the Rov::init method is not called), the program will enter deadlock and hang indefinitely. This is caused by the shutdown hook method Rov::shutdown waiting for the dead flag to be set

void shutdown() {
    Logger.info("Shutting down");
    killSwitch.onCompleted();
    while (true) {
        if (dead.get()) {
        break;
    }
    ...

If init fails to complete, there is no guarantee that the observable which listens to killswitch will be called. ie) the call takeUntil(killSwitch). Possible Solutions: We need to make sure that this subscription has been established in our spinlock, add a timeout, or be more clever in how we set the dead variable. (or a mixture of a these ideas)

ConnorWhalen commented 7 years ago

This is what I was getting at in #279 but didn't investigate because I had fish to fry

cal-pratt commented 7 years ago

ahhh I see. I'm gonna close-dup this issue against #279 then