Hello all,
I’m building an application that uses Unreal Engine 5 running on the Xavier NX in Jetpack 5. The actual UE5 application and GStreamer pipeline works fine when using conventional gstreamer elements eg: x264enc.
But when I include Jetpack 5 specific components, specifically nvv4l2h264enc , a runtime error occur related to memory allocation. (See stack trace below)
The elements are being constructed via a parse launch string command, and I also include the nvidia specific .so files in the Unreal Build scripts.
Here’s a list of some debugging steps I took:
-
As a test, I made at Jetpack 5 natively compiled gstreamer pipeline. It launches and works well. (See code below)
-
I then created a static library output of the above mentioned program, and built an executable that was compiled natively on Jetpack 5 which consumed my statically(and dynamically) built GStreamer pipeline. This works fine.
-
But when I transfer the either the static(.a) or dynamic(.s0) library , into Unreal and calling the function that invokes the pipeline. The same exact error occur at runtime (See stack trace error). Keep in mind the program is built in Unreal on a Windows 10 machine.
Here’s my question, does the native Jetpack5 compiler/linker toolchain have special flags/features that allow access to NVENC accelerated gstreamer components?
Does this mean that in order to take advantage of any Jetson specific hardware acceleration. All programs must be compiled with the native toolchain on the Xavier NX, even if the (hardware accelerated) libraries are dynamically linked via .so files and executed at runtime.
Are there any workarounds for this issue?
test.cpp of Gstreamer pipeline:
#include <gst/gst.h>
int main2(int arg, char *argv[]) {
GstElement *pipeline = nullptr;
GstBus *bus = nullptr;
GstMessage *msg = nullptr;
// gstreamer initialization
gst_init(&arg, &argv);
// building pipeline
pipeline = gst_parse_launch(
"videotestsrc is-live=true ! videoconvert ! video/x-raw,format=NV12 ! nvvidconv ! nvv4l2h264enc ! h264parse ! avdec_h264 ! videoconvert ! autovideosink",
nullptr);
// start playing
gst_element_set_state(pipeline, GST_STATE_PLAYING);
//wait until error or EOS ( End Of Stream )
bus = gst_element_get_bus(pipeline);
msg = gst_bus_timed_pop_filtered(bus, GST_CLOCK_TIME_NONE,
static_cast<GstMessageType>(GST_MESSAGE_ERROR | GST_MESSAGE_EOS));
// free memory
if (msg != nullptr)
gst_message_unref(msg);
gst_object_unref(bus);
gst_element_set_state(pipeline, GST_STATE_NULL);
gst_object_unref(pipeline);
return 0;
}
Stacktrace of error when trying to use nvv4l2h264enc:
Fatal error: [File:.\Runtime/Core/Private/HAL/MallocBinned2.cpp] [Line: 1430]
FMallocBinned2 Attempt to realloc an unrecognized block 0xfffeec050000 canary == 0x0 != 0xe3
Signal 11 caught.
Malloc Size=262146 LargeMemoryPoolOffset=262162
CommonUnixCrashHandler: Signal=11
[2023.04.20-20.54.05:976][688]LogCore: === Critical error: ===
Unhandled Exception: SIGSEGV: invalid attempt to access memory at address 0x0000000000000003
[2023.04.20-20.54.05:976][688]LogCore: Fatal error: [File:.\Runtime/Core/Private/HAL/MallocBinned2.cpp] [Line: 1430]
FMallocBinned2 Attempt to realloc an unrecognized block 0xfffeec050000 canary == 0x0 != 0xe3
0x0000000005ac1e74 UnrealHelloWorld!void DispatchCheckVerify<void, FMallocBinned2::CanaryFail(FMallocBinned2::FFreeBlock const*) const::$_78, FLogCategoryLogMemory, char16_t [84], void*, int, EBlockCanary>(FMallocBinned2::CanaryFail(FMallocBinned2::FFreeBlock const*) const::$_78&&, FLogCategoryLogMemory const&, char16_t const (&) [84], void* const&, int const&, EBlockCanary const&)()
0x0000000005ac08b4 UnrealHelloWorld!FMallocBinned2::GetAllocationSizeExternal(void*, unsigned long&)()
0x0000000005b24178 UnrealHelloWorld!FMallocPoisonProxy::Free(void*)()
0x0000000005af13f0 UnrealHelloWorld!FMemory::Free(void*)()
0x0000ffffb187bab8 libc.so.6!__cxa_finalize(+0x177)
0x0000fffedf893690 libnvfnet.so!UnknownFunction(0x768f)
0x0000ffffb1e7ff18 ld-linux-aarch64.so.1!UnknownFunction(0x12f17)
0x0000ffffb194f07c libc.so.6!_dl_catch_exception(+0xd3)
0x0000ffffb1e80500 ld-linux-aarch64.so.1!UnknownFunction(0x134ff)
0x0000ffffb1e81020 ld-linux-aarch64.so.1!UnknownFunction(0x1401f)
0x0000ffffb194f01c libc.so.6!_dl_catch_exception(+0x73)
0x0000ffffb194f0e8 libc.so.6!_dl_catch_error(+0x3f)
0x0000ffffb1e09838 libdl.so.2!UnknownFunction(0x1837)
0x0000ffffb1e091d0 libdl.so.2!dlclose(+0x27)
0x0000fffeeb5fca14 libv4l2.so.0!UnknownFunction(0x8a13)
0x0000fffeeb5f7270 libv4l2.so.0!v4l2_fd_open(+0xb7)
0x0000fffeeb74e9e4 libgstnvvideo4linux2.so!UnknownFunction(0x2f9e3)
0x0000fffeeb73b444 libgstnvvideo4linux2.so!UnknownFunction(0x1c443)
0x0000fffeeb74c378 libgstnvvideo4linux2.so!UnknownFunction(0x2d377)
0x0000ffff60d3f310 libgstvideo-1.0.so.0!UnknownFunction(0x5630f)
0x0000ffffb1b55ddc libgstreamer-1.0.so.0!gst_element_change_state(+0x43)
0x0000ffffb1b5651c libgstreamer-1.0.so.0!UnknownFunction(0x6851b)
0x0000ffffb1b2c434 libgstreamer-1.0.so.0!UnknownFunction(0x3e433)
0x0000ffffb1b55ddc libgstreamer-1.0.so.0!gst_element_change_state(+0x43)
0x0000ffffb1b5651c libgstreamer-1.0.so.0!UnknownFunction(0x6851b)
0x0000ffffb1b2c434 libgstreamer-1.0.so.0!UnknownFunction(0x3e433)
0x0000ffffb1b55ddc libgstreamer-1.0.so.0!gst_element_change_state(+0x43)
0x0000ffffb1b5651c libgstreamer-1.0.so.0!UnknownFunction(0x6851b)
0x0000ffffb1a96400 libgstrtspserver-1.0.so.0!UnknownFunction(0x1b3ff)
0x0000ffffb1a96ef4 libgstrtspserver-1.0.so.0!UnknownFunction(0x1bef3)
0x0000ffffb1d1f804 libglib-2.0.so.0!g_main_context_dispatch(+0x133)
0x0000ffffb1d1fbb4 libglib-2.0.so.0!UnknownFunction(0x51bb3)
0x0000ffffb1d1fef0 libglib-2.0.so.0!g_main_loop_run(+0x7f)
0x0000ffffb1a936a8 libgstrtspserver-1.0.so.0!UnknownFunction(0x186a7)
0x0000ffffb1d49e18 libglib-2.0.so.0!UnknownFunction(0x7be17)
0x0000ffffb1d4947c libglib-2.0.so.0!UnknownFunction(0x7b47b)
0x0000ffffb1e23624 libpthread.so.0!UnknownFunction(0x7623)
0x0000ffffb191649c libc.so.6!UnknownFunction(0xd149b)
Gstreamer Debug Log of crash: