Hi Rodolphe,

I am the original author of the Mac OS port of libdc1394 but it's been a few years since I did any active hacking on it.

I can say that the platform_camera_t structure is supposed to be initialized to zero here:

macosx/control.c:227:

    camera = calloc (1, sizeof (platform_camera_t));

However, it seems very clear that something is going wrong in your case. It might be a more subtle memory smasher.

However, you are probably in the best position to debug it further. Your test case has narrowed things down to a fairly narrow portion of code. Any further debugging would be much appreciated!

Is there any possibility that other threads are running that may stomp on this memory?

Thanks,
David



On Fri, Feb 22, 2013 at 3:23 PM, Rodolphe Pineau <pineau@rti-zone.org> wrote:
I've been trying for a few hours to get the runloop working on OS X
Here is the code snipset that causes issue :

======== CODE START ========

    // let's only use the first camera for now
    camera = dc1394_camera_new (dc1394_lib, list->ids[0].guid);
    if (!camera) {
        camera = NULL;
        dc1394_log_error("Failed to initialize camera with guid %"PRIx64, list->ids[0].guid);
        dc1394_camera_free_list (list);
        return;
    }
    printf("Using %s %s\n", camera->vendor, camera->model);
    // setup the runloop so that the callback is properly called.
    err = dc1394_capture_schedule_with_runloop (camera, CFRunLoopGetCurrent (), kCFRunLoopDefaultMode);
    DC1394_ERR(err,"Failed to setup the runloop");

======== CODE END ========

This mostly always fails on the dc1394_capture_schedule_with_runloop (from dc1394/macosx/capture.h) and here is the error message I get :

libdc1394 warning: schedule_with_runloop must be called before capture_setup

Except I don't call dc1394_capture_setup before setting the runloop !!
As you can see I do a dc1394_camera_new, display the name of the cam and init the runloop… nothing else.
If I check in dc1394/macosx/capture.c I see that it test for a private variable  :

int
dc1394_capture_schedule_with_runloop (dc1394camera_t * camera,
        CFRunLoopRef run_loop, CFStringRef run_loop_mode)
{
    dc1394camera_priv_t * cpriv = DC1394_CAMERA_PRIV (camera);
    platform_camera_t * craw = cpriv->pcam;
    dc1394capture_t * capture = &(craw->capture);

    if (craw->capture_is_set) {
        dc1394_log_warning("schedule_with_runloop must be called before capture_setup");
        return -1;
    }

    capture->run_loop = run_loop;
    capture->run_loop_mode = run_loop_mode;
    return 0;
}

I wonder if the capture_is_set variable is properly initialized to 0 before being set ?

Any idea on this ? … or am I the only OS X developer around here ;)

Thanks, Rodolphe

--

|        Rodolphe Pineau    RTI-Zone        |
|         http://www.rti-zone.org/          |
|   Robotics / Unix / Mac OS X / Astronomy  |


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Mailing list for libdc1394-devel
libdc1394-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdc1394-devel