<div dir="ltr"><div dir="ltr"><div>Hi Nicolas,</div><div><br></div><div>Thank you for the quick response.</div><div><br></div><div>Please find attached 4 MATLAB crash reports, along with matching gdb (MinGW 64-bit) outputs.</div><div><br></div><div>Thank you,<br></div><div>MarcG</div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-size:12.8px"><div style="font-size:small"><span><p dir="ltr" style="line-height:1.44;margin-top:0pt;margin-bottom:0pt"><br></p><p dir="ltr" style="line-height:1.44;margin-top:0pt;margin-bottom:0pt">On Wed, 6 Feb 2019 at 02:13, <<a href="mailto:gstreamer-devel-request@lists.freedesktop.org">gstreamer-devel-request@lists.freedesktop.org</a>> wrote:<br></p></span></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">---------- Forwarded message ----------<br>From: Nicolas Dufresne <<a href="mailto:nicolas@ndufresne.ca" target="_blank">nicolas@ndufresne.ca</a>><br>To: Discussion of the development of and with GStreamer <<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a>><br>Cc: <br>Bcc: <br>Date: Tue, 5 Feb 2019 22:42:32 -0500<br>Subject: Re: Random access violation (seg. fault) when calling GStreamer functions from MATLAB context in Windows<br><div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr">Le mar. 5 févr. 2019 16 h 57, Marc Gelinas <<a href="mailto:mgelinas@kinova.ca" target="_blank">mgelinas@kinova.ca</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><font face="monospace, monospace">Hello,</font><div><font face="monospace, monospace"><br></font></div><div><div><font face="monospace, monospace">I wonder if anyone has ever been able to use GStreamer libraries with MATLAB in Windows.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Context</font></div><div><font face="monospace, monospace">-------</font></div><div><font face="monospace, monospace"><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">We are developing a custom adapter to be used with </span>MATLAB's Image Acquisition Toolbox add-on library (imaqmex.mexw64). Our adapter is a library (.dll in Windows) and uses GStreamer to access an RTSP video feed.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">MATLAB --> imaqmex.mexw64 --> our_custom_adapter.dll --> gstreamer libraries</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">The components are:</font></div><div><font face="monospace, monospace">- Windows 7</font></div><div><font face="monospace, monospace">- MATLAB R2018b (v9.5.0.944444) with Image Acquisition Toolbox v5.5</font></div><div><font face="monospace, monospace"><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">- GStreamer libraries v1.14.4 for Windows</span><br></font></div><div><font face="monospace, monospace"><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">- Visual S</span></font><span style="font-family:monospace,monospace">tudio 2015 (because it appears that the </span><span style="font-family:monospace,monospace">imaqmex.mexw64 was built with VS 2015).</span></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Issue</font></div><div><font face="monospace, monospace">-----</font></div><div><font face="monospace, monospace">At some point in MATLAB's Command Window, we type 'imaqhwinfo'. This results in the Image Acquisition Toolbox library calling our adapter's initialization code, which in turn calls gst_init_check(), after checking that it's not already initialized (i.e. gst_is_initialized).</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Then, somewhere along the line, an access violation (segmentation fault) randomly occurs in a GStreamer function (doesn't always occur when calling the same function). I have noticed that it often occurs when "calling" GST_LOG or GST_DEBUG macros, but it can also occur when calling any other function. For instance, calling gst_tag_register from plugin_init (isomp4-plugin.c).</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">It looks like there's an alignment issue between the MATLAB context and the GStreamer libraries.<br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">I've tried to change multiple compiler and linker options but I didn't find any combination to make it work.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">- Does anyone have any idea what could be the issue and how to fix it?</font></div></div></div></div></div></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Best would be to share a backtrace of the crash, with additional information about local variables and their location.</div><div dir="auto"><br></div><div dir="auto">If it's always in a logging function, you would try and provide as many different logging functions that crash, from there we may find something they have in common.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><div><font face="monospace, monospace">- Is it just a question of setting the proper compiler/linker options or it's more complex than that?</font></div></div></div></div></div></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">It can be from very simple to very complex. GStreamer is built with a very ancient Mingw toolchain, which sometimes have some oops. We are working on moving to something newer, but this is still being worked on.</div><div dir="auto"><br></div><div dir="auto">An example issue we faced, was that this old mingw was not aligning the stack properly for use with vector variables (from intrinsic, like SSE instructions). We workaround that using compiler hints, that was on 32bit windows only though.</div><div dir="auto"><br></div><div dir="auto">For log function, we use a lot of vararg, and variable size must fit the format. I'm also wondering if the calling convention or just the mix of compiler may not have some incompatibility we are not aware of.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">It must be noted that with Linux, the same code (obviously with appropriate #ifdef/#ifndef _WIN32</font><span style="font-family:monospace,monospace"> where required) works without any issues.</span></div><div><font face="monospace, monospace"><br></font></div><div><span style="font-family:monospace,monospace"><br></span></div><div><span style="font-family:monospace,monospace">Finally, in the GStreamer instructions for </span><a href="https://gstreamer.freedesktop.org/documentation/installing/on-windows.html#installing-on-windows" style="font-family:monospace,monospace" rel="noreferrer" target="_blank">Installing on Windows</a><span style="font-family:monospace,monospace">, it's said that the property pages only work with Visual Studio 2010. What do we need to change to make them work with Visual Studio 2015? I didn't face any issue loading them in Visual Studio 2015.</span></div></div></div></div></div></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">That is likely just outdated doc (and slightly miss written) I imagine it was meant to say that you need *at least* VS 2010. Of course it could break in the future, we have not control over that, but the is not report in the direction yet.</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><div><br></div></div><div><span style="font-family:monospace,monospace"><br></span></div><div><span style="font-family:monospace,monospace"><br></span></div><div><span style="font-family:monospace,monospace">Thank you in advance for any help, it will be greatly appreciated.</span></div><div><span style="font-family:monospace,monospace"><br></span></div><div><span style="font-family:monospace,monospace">Regards,</span></div><div><span style="font-family:monospace,monospace">MarcG</span></div></div></div></div></div></div>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org" rel="noreferrer" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" rel="noreferrer noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
</blockquote></div></div></div>
<br>
</blockquote></div></div>