Accessing extra_fb's pixels

I am trying to compare two images. When I try to access the pixels from extra_fb, the device crashes / restarts. I can access the pixels from img just fine. Do I need to do anything to arg_msk so I can access the pixels?

sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE) 
sensor.set_framesize(sensor.QQVGA) 
extra_fb = sensor.alloc_extra_fb(sensor.width(), sensor.height(), sensor.GRAYSCALE)

while(True):
    clock.tick()
    img = sensor.snapshot()
    diff2 = img.difference2(extra_fb)
    extra_fb.replace(sensor.snapshot())
    print(clock.fps(), diff2)



static mp_obj_t py_image_difference2(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
{
    image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);

    image_t *arg_msk =
        py_helper_keyword_to_image_mutable_mask(n_args, args, 2, kw_args);

    fb_alloc_mark();

    int pixels = 0;

    for (int y = 0, yy = arg_img->h; y < yy; y++) {
        uint8_t *row_ptr1 = IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(arg_img, y);
        uint8_t *row_ptr2 = IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(arg_msk, y);
        for (int x = 0, xx = arg_img->w; x < xx; x++) {
            int pixel1 = IMAGE_GET_GRAYSCALE_PIXEL_FAST(row_ptr1, x);
            int pixel2 = IMAGE_GET_GRAYSCALE_PIXEL_FAST(row_ptr2, x);
            
            // works
            if (pixel1 >= 32) {
                pixels++;
            }
            
            // crashes when uncommented
            /*if (pixel2 >= 32) {
                pixels++;
            }*/
        };
    }

    fb_alloc_free_till_mark();

    return mp_obj_new_int(pixels);
}
image_t *arg_msk =
        py_helper_keyword_to_image_mutable_mask(n_args, args, 2, kw_args);

Is probably NULL. I think the 2 should be a 1. Or, pass mask=extra_fb in your python code.

Elite, changing it to 1 worked, thanks!