I'm having the weirdest bug in QTCreator and I can not find out why or how it's happening.

Running QTCreator 4.1.0, Based on QT 5.7.0.
Compiler: MSVC 2015 x64.
External libraries: Opencv 3.10 and LibVLC 2.2.4 (both 64 bit. Using 32 bit compiler with 32 bit libraries creates the same error).

The code I'm trying to make work is from an example I found on a forum. It fetches a picture from an IP camera with LibVLC and transfers it to a OpenCV Mat (I'm using QTCreator to do this because I'm later going to show the picture in a QT frontend).

The program compiles fine, but crashes immediately on startup with the debug error "The CDB process terminated."

Here's the code that creates the crash 100% of the time (Runs fine in Visual Studio):

Qt Code:
  1. #include <Windows.h>
  2. #include <opencv\highgui.h>
  3. #include <opencv\cv.h>
  4. #include <opencv2\opencv.hpp>
  5. #include "vlc/vlc.h"
  6.  
  7. using namespace cv;
  8.  
  9. struct ctx
  10. {
  11. Mat* image;
  12. HANDLE mutex;
  13. uchar* pixels;
  14. };
  15. // define output video resolution
  16. #define VIDEO_WIDTH 1920
  17. #define VIDEO_HEIGHT 1080
  18.  
  19. void *lock(void *data, void**p_pixels)
  20. {
  21. struct ctx *ctx = (struct ctx*)data;
  22.  
  23. WaitForSingleObject(ctx->mutex, INFINITE);
  24.  
  25. // pixel will be stored on image pixel space
  26. *p_pixels = ctx->pixels;
  27.  
  28. return NULL;
  29.  
  30. }
  31.  
  32. void display(void *data, void *id) {
  33. (void)data;
  34. assert(id == NULL);
  35. }
  36.  
  37. void unlock(void *data, void *id, void *const *p_pixels) {
  38.  
  39. // get back data structure
  40. struct ctx *ctx = (struct ctx*)data;
  41.  
  42. /* VLC just rendered the video, but we can also render stuff */
  43. // show rendered image
  44. imshow("test", *ctx->image);
  45.  
  46. ReleaseMutex(ctx->mutex);
  47. }
  48.  
  49. int main()
  50. {
  51. // VLC pointers
  52. libvlc_instance_t *vlcInstance;
  53. libvlc_media_player_t *mp;
  54. libvlc_media_t *media;
  55.  
  56. const char * const vlc_args[] = {
  57. "-I", "dummy", // Don't use any interface
  58. "--ignore-config", // Don't use VLC's config
  59. "--extraintf=logger", // Log anything
  60. "--verbose=2", // Be much more verbose then normal for debugging purpose
  61. };
  62.  
  63. vlcInstance = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
  64.  
  65. // Read a distant video stream
  66. media = libvlc_media_new_location(vlcInstance, "rtsp://root:root@10.11.12.13:1234/videoinput_1/h264_1/media.stm");
  67.  
  68. mp = libvlc_media_player_new_from_media(media);
  69.  
  70. libvlc_media_release(media);
  71.  
  72. struct ctx* context = (struct ctx*)malloc(sizeof(*context));
  73. context->mutex = CreateMutex(NULL, FALSE, NULL);
  74.  
  75. context->image = new Mat(VIDEO_HEIGHT, VIDEO_WIDTH, CV_8UC3);
  76. context->pixels = (unsigned char *)context->image->data;
  77. // show blank image
  78. imshow("test", *context->image);
  79.  
  80. libvlc_video_set_callbacks(mp, lock, unlock, display, context);
  81. libvlc_video_set_format(mp, "RV24", VIDEO_WIDTH, VIDEO_HEIGHT, VIDEO_WIDTH * 24 / 8); // pitch = width * BitsPerPixel / 8
  82.  
  83.  
  84. int ii = 0;
  85. int key = 0;
  86. while (key != 27)
  87. {
  88. ii++;
  89. if (ii > 5)
  90. {
  91. libvlc_media_player_play(mp);
  92. }
  93. float fps = libvlc_media_player_get_fps(mp);
  94. printf("fps:%f\r\n", fps);
  95. key = waitKey(30); // wait 100ms for Esc key
  96. }
  97.  
  98. libvlc_media_player_stop(mp);
  99.  
  100.  
  101. return 0;
  102. }
To copy to clipboard, switch view to plain text mode 

Bear in mind, program doesn't actually have to run the code to crash. Even if it just sits in a unused method, it still crashes immediately on startup.

Here's the bizarre part: If I comment out the "broken code" from the program, the error is still there. I remove the code completely (with ctrl+z to a point before I added it), and the error is still there. I remove the includes, still error. The only way I can find to run the program after getting this error is to remove all broken code and associated libraries, create a different type of build error, and that somehow resets the debugger enough to run the program again. Even restarting the program or rebooting the computer doesn't work

From a different forum, I found a tip to add cdb.exe manually in tools-options-Debugger-CDB:
C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\cdb.exe

Having done that, the debugger (without an error this time) locks itself on startup (refuses to be closed), while running the application without it one produces a regular crash.

With that, I am out of ideas. Anyone else?