Crash with "abort signal" when loading device

I’m building a plugin to integrate libmediasoupclient into Unreal Engine.

When I load mediasoup device, it crashes with this report:

Abort signal received

ucrtbase
ucrtbase
UnrealEditor_ShibuChat_Win64_DebugGame!rtc::webrtc_checks_impl::UnreachableCodeReached()
UnrealEditor_ShibuChat_Win64_DebugGame!rtc::webrtc_checks_impl::FatalLog()
UnrealEditor_ShibuChat_Win64_DebugGame!cricket::WebRtcVoiceEngine::Init()
UnrealEditor_ShibuChat_Win64_DebugGame!cricket::CompositeMediaEngine::Init()
UnrealEditor_ShibuChat_Win64_DebugGame!cricket::ChannelManager::Create()
UnrealEditor_ShibuChat_Win64_DebugGame!std::vector<std::unique_ptr<cricket::VoiceChannel,std::default_delete<cricket::VoiceChannel> >,std::allocator<std::unique_ptr<cricket::VoiceChannel,std::default_delete<cricket::VoiceChannel> > > >::erase()
UnrealEditor_ShibuChat_Win64_DebugGame!rtc::Thread::Restart()
UnrealEditor_ShibuChat_Win64_DebugGame!rtc::Thread::QueuedTaskHandler::OnMessage()
UnrealEditor_ShibuChat_Win64_DebugGame!rtc::Thread::Dispatch()
UnrealEditor_ShibuChat_Win64_DebugGame!rtc::Thread::ProcessMessages()
UnrealEditor_ShibuChat_Win64_DebugGame!rtc::Thread::PreRun()
kernel32
ntdll

From the report, I think it fails at cricket::WebRtcVoiceEngine::Init(). I think this might be similar to this issue: After removing the sound card and adding it again, Device::Load crashes.

This is the function I use to load device:

static decltype(auto) CreateAndLoadDevice(const FString& InRtpCapabilityJsonString) noexcept
{
	mediasoupclient::Device device;
	device.Load(nlohmann::json::parse(StringCast<ANSICHAR>(*InRtpCapabilityJsonString).Get()));
	return device;
}

I use the RTP capabilities below for the input. I get them with socket.io, similar to this thread: Problem with mediasoup-client load.

{
    "codecs":
    [
        {
            "channels": 2,
            "clockRate": 48000,
            "kind": "audio",
            "mimeType": "audio/opus",
            "parameters": {},
            "preferredPayloadType": 100,
            "rtcpFeedback":
            [
                {
                    "parameter": "",
                    "type": "transport-cc"
                }
            ]
        },
        {
            "clockRate": 90000,
            "kind": "video",
            "mimeType": "video/VP8",
            "parameters":
            {
                "x-google-start-bitrate": 1000
            },
            "preferredPayloadType": 101,
            "rtcpFeedback":
            [
                {
                    "parameter": "",
                    "type": "nack"
                },
                {
                    "parameter": "pli",
                    "type": "nack"
                },
                {
                    "parameter": "fir",
                    "type": "ccm"
                },
                {
                    "parameter": "",
                    "type": "goog-remb"
                },
                {
                    "parameter": "",
                    "type": "transport-cc"
                }
            ]
        },
        {
            "clockRate": 90000,
            "kind": "video",
            "mimeType": "video/rtx",
            "parameters":
            {
                "apt": 101
            },
            "preferredPayloadType": 102,
            "rtcpFeedback": []
        }
    ],
    "headerExtensions":
    [
        {
            "direction": "sendrecv",
            "kind": "audio",
            "preferredEncrypt": false,
            "preferredId": 1,
            "uri": "urn:ietf:params:rtp-hdrext:sdes:mid"
        },
        {
            "direction": "sendrecv",
            "kind": "video",
            "preferredEncrypt": false,
            "preferredId": 1,
            "uri": "urn:ietf:params:rtp-hdrext:sdes:mid"
        },
        {
            "direction": "recvonly",
            "kind": "video",
            "preferredEncrypt": false,
            "preferredId": 2,
            "uri": "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"
        },
        {
            "direction": "recvonly",
            "kind": "video",
            "preferredEncrypt": false,
            "preferredId": 3,
            "uri": "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"
        },
        {
            "direction": "sendrecv",
            "kind": "audio",
            "preferredEncrypt": false,
            "preferredId": 4,
            "uri": "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"
        },
        {
            "direction": "sendrecv",
            "kind": "video",
            "preferredEncrypt": false,
            "preferredId": 4,
            "uri": "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"
        },
        {
            "direction": "recvonly",
            "kind": "audio",
            "preferredEncrypt": false,
            "preferredId": 5,
            "uri": "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"
        },
        {
            "direction": "sendrecv",
            "kind": "video",
            "preferredEncrypt": false,
            "preferredId": 5,
            "uri": "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"
        },
        {
            "direction": "sendrecv",
            "kind": "video",
            "preferredEncrypt": false,
            "preferredId": 6,
            "uri": "http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07"
        },
        {
            "direction": "sendrecv",
            "kind": "video",
            "preferredEncrypt": false,
            "preferredId": 7,
            "uri": "urn:ietf:params:rtp-hdrext:framemarking"
        },
        {
            "direction": "sendrecv",
            "kind": "audio",
            "preferredEncrypt": false,
            "preferredId": 10,
            "uri": "urn:ietf:params:rtp-hdrext:ssrc-audio-level"
        },
        {
            "direction": "sendrecv",
            "kind": "video",
            "preferredEncrypt": false,
            "preferredId": 11,
            "uri": "urn:3gpp:video-orientation"
        },
        {
            "direction": "sendrecv",
            "kind": "video",
            "preferredEncrypt": false,
            "preferredId": 12,
            "uri": "urn:ietf:params:rtp-hdrext:toffset"
        },
        {
            "direction": "sendrecv",
            "kind": "audio",
            "preferredEncrypt": false,
            "preferredId": 13,
            "uri": "http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time"
        },
        {
            "direction": "sendrecv",
            "kind": "video",
            "preferredEncrypt": false,
            "preferredId": 13,
            "uri": "http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time"
        }
    ]
}

I found that the crash happens at line 93 of libmediasoupclient’s PeerConnection.cpp https://github.com/versatica/libmediasoupclient/blob/48768ba90dee235e045e8dfbf364365504e2c4ce/src/PeerConnection.cpp#L93