Deepstream h265parser segfaults with gstreamer gst_debug_add_log_function

Consider this a continuation of the previously closed issue:

Basically, when adding a custom log function to a gstreamer app that uses the deepstream v4l2 plugins to decode h265, a SEGFAULT will be generated at line 744 of gstv4l2h26xparser.c.
The segfault is caused by use of the GST_DEBUG macro on a codepath where the result of the INITIALIZE_DEBUG_CATEGORY macro has not been executed, leaving the default category uninitialized.

The source of the problem can be found by examining the nvidia sources for the v4l2 packages.
(these can be found in the BSP sources for Jetson, here: https://developer.nvidia.com/downloads/embedded/l4t/r35_release_v4.1/sources/public_sources.tbz2/)

In gstv4l2videodec.c:1526, h265_parser_identify_nalu is called with a NULL for the first arg, which bypasses a normal code path that would have initialized the Gstreamer default debug category (in the file gstv4l2h26xparser.c, the macro INITIALIZE_DEBUG_CATEGORY is only called on certain code paths, and calling h265_parser_identify_nalu this way will skip initialization.

Without a custom log function being added, gstreamer logging will not cause the segfault due to some short-circuit checks for null GstDebugCategory; but when there are custom log functions involved, a different code path triggers a deref of the GstDebugCategory which is null, and creates the segfault.

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) Jetson Orin, also x86_64 dGPU
• DeepStream Version 6.3
• JetPack Version (valid for Jetson only) provided with 6.3 DS containers
• TensorRT Version provided with 6.3 DS containers
• NVIDIA GPU Driver Version (valid for GPU only) irrelevant
• Issue Type( questions, new requirements, bugs) SEGFAULT
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)

See the referenced issue for details. Basically, add a custom log function to a gstreamer app that decodes h265 video using the NVIDIA deepstream v4l2 plugin and it will be triggered.

It can be worked around by either modifying the code, or by explicitly calling (or causing to be called)h265_parser_new before the decoding occurs in the presence of a custom debug log function.

• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks

Hi @matt.deboer , could you provide a simple code demo with deepstream_test1_app.c for this scenario? I test that with deepstream_test1_app.c and h265 stream, but it doesn’t crash.

void my_log_func(GstDebugCategory * category,
                 GstDebugLevel level,
                 const gchar * file,
                 const gchar * function,
                 gint line,
                 GObject * object,
                 GstDebugMessage * message,
                 gpointer user_data) {

    printf("Test: [Level:%d] %s:%s:%d  %s\n",
            level, file, function, line,
            gst_debug_message_get(message));

}
  gst_debug_add_log_function(my_log_func, NULL, NULL);
  gst_debug_set_active(TRUE);
  gst_debug_set_default_threshold(GST_LEVEL_INFO);

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.