GNOME Bugzilla – Bug 740483
Calling Emit(..) unbalances the stack
Last modified: 2015-06-16 12:43:07 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);
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).
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.
Can you share your code which shows this behaviour?
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
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.
I didn't test on windows, but the code runs fine on linux. (Running just the stuff in MainWindow_Loaded with autovideosink)
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?
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?
Yes, it works! Thank you very much, I mark this bug as RESOLVED.
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
> 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 :)