Aw: Re: GStreamer application access violation in random locations

pfarmer flacone at gmx.de
Tue Jan 5 04:36:45 PST 2016


Hello, 

  

I am not able to crash the function I posted before earlier. It crashed for sure once, but it may have been realated to some logging initialization that were still in memory at Simulink. So I narrowed it down to the debugging functions of gstreamer. Here the new minimal s-function that crashes every now and then: 

  

#define S_FUNCTION_LEVEL 2

#define S_FUNCTION_NAME  sfunc_gstmin 

  

#include <simstruc.h> 

#include <gst/gst.h> 

  

static void gstLogFunction(GstDebugCategory* category,
        GstDebugLevel level, const gchar* file, const gchar* function, 

	gint line, GObject* object, GstDebugMessage* message, 

	gpointer user_data) 

{} 

  

static void mdlInitializeSizes(SimStruct* S) 

{ 

	ssSetNumSFcnParams(S, 0); 

} 

  

static void mdlInitializeSampleTimes(SimStruct* S) 

{ 

	gst_debug_set_default_threshold(GST_LEVEL_LOG); 

	gst_init(NULL, NULL); 

	gst_debug_remove_log_function(&gst_debug_log_default); 

	gst_debug_add_log_function(&gstLogFunction, NULL, NULL); 

} 

  

static void mdlOutputs(SimStruct* S, int_T tid) 

{} 

  

static void mdlTerminate(SimStruct *S) 

{} 

  

  

// Required S-function trailer 

  

#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */ 

#include "simulink.c"      /* MEX-file interface mechanism */ 

#else 

#include "cg_sfun.h"       /* Code generation registration function */ 

#endif 

  

  

  

This crashes with: 

  

Stack Trace (from fault): 
[  0] 0x000007fef66c1122                                   <unknown-module>+00000000 
[  1] 0x0000000188377781 C:\gstreamer\1.0\x86_64\bin\libgstreamer-1.0-0.dll+00227201 gst_debug_log_valist+00000209 
[  2] 0x0000000188377860 C:\gstreamer\1.0\x86_64\bin\libgstreamer-1.0-0.dll+00227424 gst_debug_log+00000064 
[  3] 0x0000000188377c0f C:\gstreamer\1.0\x86_64\bin\libgstreamer-1.0-0.dll+00228367 gst_debug_remove_log_function+00000127 
[  4] 0x000007fef570e42f C:\builddbg\sfunc_gstreamer.mexw64+00058415 SpanGstreamer::installMessageHandler+00000047 
[  5] 0x000007fef5709752 C:\workcopies\VideoForSpaceTeleoperation\Software\h264block\builddbg\sfunc_gstreamer.mexw64+00038738 mdlInitializeSampleTimes+00000178 
[  6] 0x000007fef570464d C:\builddbg\sfunc_gstreamer.mexw64+00017997 mexFunction+00002669 
[  7] 0x00000000fc5f3701 C:\Program Files\MATLAB\R2014b\bin\win64\libmex.dll+00079617 mexRunMexFile+00000129 

  

Note that it also crashes with the empty gstLogFunction(). 

I would like however "redirect" the the gstreamer messages to the Simulink output. So I would like to use those functions. 

Does someone know what I could do to avoid the crashing? 

  

BR 


 

Gesendet: Montag, 04. Januar 2016 um 12:56 Uhr 
Von: "pfarmer [via GStreamer-devel]" <ml-node+s966125n4675109h81 at n4.nabble.com> 
An: pfarmer <flacone at gmx.de> 
Betreff: Re: GStreamer application access violation in random locations 

Thank a lot for the answer. Sorry for the super late response. 

I tried to make a minimal example: 

This is the *.cpp file that is compiled with VS2013 64bit: 


#define S_FUNCTION_LEVEL 2 
#define S_FUNCTION_NAME  sfunc_gstmin 

#include <simstruc.h> 

#include <cstring> 

#include <gst/gst.h> 
#include <gst/app/gstappsink.h> 

enum {VIDEO_HEIGHT=640, VIDEO_WIDTH=360}; 

static void mdlInitializeSizes(SimStruct* S) 
{ 
        if (!ssSetNumOutputPorts(S, 1)) return; 
        ssSetOutputPortDataType(S, 0, SS_UINT32); 
        ssSetOutputPortMatrixDimensions(S, 0, VIDEO_HEIGHT, VIDEO_WIDTH); 
        ssSetNumPWork(S, 1); 
        ssSetNumSampleTimes(S, 1); 


} 

static void mdlInitializeSampleTimes(SimStruct* S) 
{ 
        ssSetSampleTime(S, 0, -1); 
} 

#define MDL_START 
static void mdlStart(SimStruct* S) 
{ 
        gst_init(NULL, NULL); 
        GstElement* pipeline = gst_parse_launch( 
                 "videotestsrc horizontal-speed=1 ! capsfilter name=filter ! appsink max-buffers=3 drop=true name=sink", 
                 NULL); 
        GstElement* filter = gst_bin_get_by_name(GST_BIN(pipeline), "filter"); 
        GstCaps* caps = gst_caps_new_simple("video/x-raw", 
                  "format", G_TYPE_STRING, "RGBA", 
                  "width", G_TYPE_INT, VIDEO_WIDTH, 
                  "height", G_TYPE_INT, VIDEO_HEIGHT, 
                  "framerate", GST_TYPE_FRACTION, 10, 1, 
        NULL); 
        g_object_set(filter, "caps", caps, NULL); 
        gst_element_set_state(pipeline, GST_STATE_PLAYING); 

        ssGetPWork(S)[0] = static_cast<void *>(pipeline); 
} 

static void mdlOutputs(SimStruct* S, int_T tid) 
{ 
        UNUSED_ARG(tid); 
        uint32_T* signal = static_cast<uint32_T*>(ssGetOutputPortSignal(S, 0)); 
        GstElement* pipeline = static_cast<GstElement*>(ssGetPWork(S)[0]); 
        GstElement* sink = gst_bin_get_by_name(GST_BIN(pipeline), "sink"); 
        GstMapInfo map; 
        GstSample* sample = gst_app_sink_pull_sample(GST_APP_SINK(sink)); 
        if (sample != NULL) 
        { 
                GstBuffer* buffer = gst_sample_get_buffer(sample); 
                if (gst_buffer_map(buffer, &map, GST_MAP_READ)) 
                { 
                        std::memcpy(signal, map.data, map.size); 
                        gst_buffer_unmap(buffer, &map); 
                } 
                gst_sample_unref(sample); 
        } 
} 

static void mdlTerminate(SimStruct *S) 
{ 
        GstElement* pipeline = static_cast<GstElement*>(ssGetPWork(S)[0]); 
        gst_element_set_state(pipeline, GST_STATE_NULL); 
} 


// Required S-function trailer 

#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */ 
#include "simulink.c"      /* MEX-file interface mechanism */ 
#else 
#include "cg_sfun.h"       /* Code generation registration function */ 
#endif 



This is that run as a a user-defined S-Function inside Simulink. 
This crashes very infrequently. 



 


If you reply to this email, your message will be added to the discussion below: 
http://gstreamer-devel.966125.n4.nabble.com/GStreamer-application-access-violation-in-random-locations-tp4674999p4675109.html 

To start a new topic under GStreamer-devel, email ml-node+s966125n966125h77 at n4.nabble.com 
To unsubscribe from GStreamer application access violation in random locations, click here . 
NAML 








--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/GStreamer-application-access-violation-in-random-locations-tp4674999p4675116.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160105/8aac3e9d/attachment-0001.html>


More information about the gstreamer-devel mailing list