Strange abort/exception with nvidia-encode/nvcuvid on wsl

Have a look at the following code
EncoderCppTest.cpp

#include <stdexcept>
#include <iostream>

int main() {
	std::set_terminate([] {
		std::cout << "std::terminate was called" << std::endl;
		std::exit(-1);
	});
	try {
		int count = std::uncaught_exceptions();
		std::cout << "uncaught exceptions: " << count << std::endl;
		throw std::runtime_error("test");

	} catch (const std::runtime_error& e) {
		std::cout << "std::runtime_error: " << e.what() << std::endl;
	}
	return 0;
}

And to build CMakeLists.txt

cmake_minimum_required(VERSION 3.24)
project(encoder)
add_executable(encoder EncoderCppTest.cpp)
set(CMAKE_BUILD_TYPE Debug)

target_link_directories(encoder PRIVATE 
	/usr/lib/wsl/lib
)

target_link_libraries(encoder PRIVATE
	nvcuvid
	nvidia-encode
)

This will give me

uncaught exceptions: 0
std::terminate was called

I am running this on WSL2 on Windows 11, checked not to install any driver inside wsl

nvidia-smi
Sat Dec  7 11:51:15 2024
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 560.35.04              Driver Version: 561.17         CUDA Version: 12.6     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 3060        On  |   00000000:01:00.0  On |                  N/A |
|  0%   45C    P8             22W /  170W |    1469MiB /  12288MiB |      4%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+

Remove the linking to nvcuvid an nvidia-encode and the exception will be properly handled.

So my conclusion is there is something going wrong inside those two libraries. Note how no function even gets called, yet still std::terminate gets called. Happens on WSL, Ubuntu 24.04