openframeworks / openframeworks/openFrameworks

ofVideoGrabber and ofThread crash on exit (osx)

Open
#5,046 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug macOS
Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

Having an ofThread and ofVideoGrabber, and trying to close the thread nicely waiting for its work getting done when exiting, makes the videograbber to crash on exit with a EXC_BAD_ACCESS in libsystem_kernel.dylib. I can see the crash is related to [QTKitVideoGrabber stop]

#include "ofApp.h"
void ofApp::setup(){
    startThread();
    grabber.setup(600,400);
}

void ofApp::update(){
    grabber.update();
}

void ofApp::draw(){
    grabber.draw(0,0);
}

void ofApp::exit(){
    if(isThreadRunning()){
        waitForThread();
    }
}

void ofApp::threadedFunction(){
    while(isThreadRunning()) {
        sleep(5);
    }
}

If i leave out sleep(5), then there is no problem.

Running on OSX 10.11.2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the provided ofThread and ofVideoGrabber example on OSX 10.11.2, focusing on the exit path and the QTKitVideoGrabber stop call. Compare behavior with and without sleep(5), then trace the thread shutdown and video-grabber cleanup. Done means the example exits without the EXC_BAD_ACCESS crash while waiting for the thread to finish.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.