After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 740483 - Calling Emit(..) unbalances the stack
Calling Emit(..) unbalances the stack
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-sharp
git master
Other Windows
: Normal major
: 1.0.0
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-11-21 10:20 UTC by Ralph
Modified: 2015-06-16 12:43 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Ralph 2014-11-21 10:20:20 UTC
I'm using gnonlin and when I try to commit the changes to a gnlcomposition by emiting a "commit" signal, I get the following error:

PInvokeStackImbalance was detected
Message: A call to PInvoke function 'gstreamer-sharp!Gst.DynamicSignal::gstsharp_g_type_from_instance' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.


All I'm doing is executing this line:
videoComposition.Emit("commit", changedObject);
Comment 1 Thibault Saunier 2014-11-21 11:05:15 UTC
I am not sure how that is supposed to work with GstSharp, but changedObject is actually the return value of the action signal, usually that value is properly returned by bindings (at least for PyGObject).
Comment 2 Ralph 2014-11-21 11:13:14 UTC
In C# the Emit(..) method definition looks like that:

        public object Emit(string signal, params object[] parameters);

It means that from the C# perspective, the parameters should be passed TO the method, not returned by it.

BTW, calling videoComposition.Emit("commit") without specifying any parameters causes the same PInvokeStackImbalance problem.
Comment 3 Stephan Sundermann 2014-11-22 13:32:33 UTC
Can you share your code which shows this behaviour?
Comment 4 Stephan Sundermann 2014-11-22 13:43:51 UTC
Anyway, you seem to be misusing the Emit function, since you need to pass a new object[] containing the parameters. videoComposition.Emit("commit", new object[] { recurse }); You need to ignore the first parameter since this will be the pointer to the object you are calling Emit on and the user_data parameter. There's a sample how to use the Emit function at https://github.com/gstreamer-sharp/gstreamer-sharp/blob/master/samples/PlaybackTutorial1.cs#L114
Comment 5 Ralph 2014-11-24 11:18:21 UTC
Still crashes:
videoComposition.Emit("commit", new object[] { false });

My sample application demonstrating the problem (it is actually the same application I used for demonstrating a problem with seeking, which has been fixed in GStreamer 1.4.4):

http://ralphos.com/files/SeekTest.zip

In order to run it, edit MainWindow.xaml.cs and change the path to the video file (line 31).
You can use any of your video files or one of my test files:
http://ralphos.com/files/Nigel_Q2_10003.avi
http://ralphos.com/files/PikesPeak-2014.mp4
Emit method is called in two places: line 140 and line 159.
Comment 6 Stephan Sundermann 2014-11-24 20:24:02 UTC
I didn't test on windows, but the code runs fine on linux. (Running just the stuff in MainWindow_Loaded with autovideosink)
Comment 7 Ralph 2014-11-25 10:01:46 UTC
On Windows it definitely crashes :(
But...  I can see that if I ignore the MDA message and keep it running (I have to do it 6 times - 4 for the first Emit(..) call and 2 for the second one), the application works.
Maybe it is one of those situations when the Managed Debugging Assistant is oversensitive and the code will work when the PInvokeStackImbalance is disabled in the Visual Studio?
Comment 8 Stephan Sundermann 2014-11-25 10:16:34 UTC
It's possible that mono has not implemented the PInvokeStackImbalance exception, therefore there won't be an exception on osx/linux.
The DynamicSignal class did not set the calling convention on the DynamicSignal class, I added them in master. Can you try if master fixes your issue?
Comment 9 Ralph 2014-11-25 10:42:44 UTC
Yes, it works!
Thank you very much, I mark this bug as RESOLVED.
Comment 10 Tim-Philipp Müller 2014-11-25 10:48:25 UTC
commit 388f3846edbae79d8fe8f377bc409841337e4fef
Author: Stephan Sundermann <stephansundermann@gmail.com>
Date:   Tue Nov 25 11:15:11 2014 +0100

    DynamicSignal: Add missing calling convention

commit db3ffc2a70592a46fac3aa6b714f64d4f1333da5
Author: Stephan Sundermann <stephansundermann@gmail.com>
Date:   Tue Nov 25 11:13:44 2014 +0100

    DynamicSignal: Reformat to match conventions
Comment 11 Andrés G. Aragoneses (IRC: knocte) 2015-06-16 12:43:07 UTC
> It's possible that mono has not implemented the PInvokeStackImbalance exception

Please report a bug about this to http://bugzilla.xamarin.com/ and when done, link it from here, for reference :)