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 340338 - [v4l2src] crashes with tuner interface in gst-python if device not open yet
[v4l2src] crashes with tuner interface in gst-python if device not open yet
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other All
: Normal critical
: 0.10.11
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks: 338818
 
 
Reported: 2006-05-01 20:29 UTC by Fredrik Persson
Modified: 2007-11-13 22:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
simple C program to show when Tuner interface is available (1.99 KB, text/plain)
2007-10-15 08:26 UTC, Edgard Lima
Details

Description Fredrik Persson 2006-05-01 20:29:14 UTC
Steps to reproduce:
Run this simple pyton script. It will give this error message:
"GStreamer-CRITICAL **: gst_implements_interface_cast: assertion
`gst_element_implements_interface (GST_ELEMENT (from), iface_type)' failed
Segmentation fault

import gst
import gobject

source = gst.element_factory_make("v4l2src")
print source.get_channel()



Stack trace:
(gdb) bt
  • #0 gst_tuner_get_channel
    at tuner.c line 174
  • #1 initinterfaces
    from /usr/lib/python2.4/site-packages/gst-0.10/gst/interfaces.so
  • #2 PyEval_EvalFrame
  • #3 PyEval_EvalCodeEx
  • #4 PyEval_EvalCode
  • #5 PyRun_FileExFlags
  • #6 PyRun_SimpleFileExFlags
  • #7 Py_Main
  • #8 __libc_start_main
    from /lib/libc.so.6
  • #9 _start

Other information:
Using the tuner interface in c doesn't seem to be a problem at all. For example,
this test program runs fine: http://bugzilla.gnome.org/attachment.cgi?id=63735
Comment 1 Edward Hervey 2006-05-03 15:28:04 UTC
same here.

 Can't try it for the time being but it's high on my todo list.
Comment 2 Andy Wingo 2006-05-04 12:27:16 UTC
(of course, there's no tuner interface implemented until the device is open)
Comment 3 Fredrik Persson 2006-05-04 12:45:51 UTC
Andy, that's correct! 

If I understand this correctly, the device (/dev/video0 in this case) will be opened when the source element is put in READY state (or higher). I can't try it out right now, but I'm pretty sure I tried this:

import gst
import gobject

source = gst.element_factory_make("v4l2src")
source.set_state(READY)
print source.get_channel()

... which gave the same result as I've shown above. I'll test this and get back here.

Comment 4 Fredrik Persson 2006-05-04 16:57:14 UTC
Ok, now I've confirmed that the following script:

import gst
import gobject

source = gst.element_factory_make("v4l2src")
source.set_state(gst.STATE_READY)
print source.get_channel()

... produces the exakt same result as you can see in comment #1.

I also tried with gst.STATE_PLAYING, same result.

I also must say that I'm not 100% sure putting the v4l2src element in these states actually opens the /dev/video0 device. That's just what I've heard.
Comment 5 Fredrik Persson 2006-05-04 16:59:01 UTC
Oops! Of course, I don't mean comment #1 in comment #4, I mean my original bug report, above. Sorry.
Comment 6 Fredrik Persson 2006-07-21 20:47:29 UTC
Any progress on this one?
Comment 7 Zaheer Abbas Merali 2006-08-03 13:32:35 UTC
I confirm this problem with v4lsrc.  Even when v4lsrc is playing inside a pipeline, get_channel() segfaults.
Comment 8 Zaheer Abbas Merali 2006-09-22 10:18:38 UTC


  • #0 gst_tuner_get_channel
    at tuner.c line 179
  • #0 gst_tuner_get_channel
    at tuner.c line 179
  • #1 initinterfaces
    from /usr/lib/python2.4/site-packages/gst-0.10/gst/interfaces.so
  • #2 PyEval_EvalFrame
    from /usr/lib/libpython2.4.so.1.0
  • #3 PyEval_EvalCodeEx
    from /usr/lib/libpython2.4.so.1.0
  • #4 PyEval_EvalCode
    from /usr/lib/libpython2.4.so.1.0
  • #5 PyEval_EvalFrame
    from /usr/lib/libpython2.4.so.1.0
  • #6 PyEval_EvalCodeEx
    from /usr/lib/libpython2.4.so.1.0
  • #7 PyEval_EvalFrame
    from /usr/lib/libpython2.4.so.1.0
  • #8 PyEval_EvalCodeEx
    from /usr/lib/libpython2.4.so.1.0
  • #9 PyEval_EvalFrame
    from /usr/lib/libpython2.4.so.1.0
  • #10 PyEval_EvalFrame
    from /usr/lib/libpython2.4.so.1.0
  • #11 PyEval_EvalCodeEx
    from /usr/lib/libpython2.4.so.1.0

Comment 9 Edward Hervey 2006-09-22 11:42:24 UTC
The problem is that v4l2src doesn't implement GstImplementsInterface interface properly. It should implement the ->supported method (just like v4lsrc does).

Changing title accordingly
Comment 10 Edward Hervey 2006-09-22 14:15:09 UTC
Fredrik, could you give me some backtraces:

_ with G_DEBUG=fatal_warnings
_ with G_DEBUG=""

make them with:
> ulimit -c unlimited
> G_DEBUG=... python yourtest.py
> gdb python <corefile>
> bt full

Thanks
Comment 11 Fredrik Persson 2006-09-22 15:30:35 UTC
With G_DEBUG=fatal_warnings:

(gdb) bt full
  • #0 __kernel_vsyscall
  • #1 raise
    from /lib/tls/i686/cmov/libc.so.6
  • #2 abort
    from /lib/tls/i686/cmov/libc.so.6
  • #3 g_logv
    from /usr/lib/libglib-2.0.so.0
  • #4 g_log
    from /usr/lib/libglib-2.0.so.0
  • #5 g_return_if_fail_warning
    from /usr/lib/libglib-2.0.so.0
  • #6 gst_implements_interface_cast
    at gstinterface.c line 147
  • #7 initinterfaces
    from /usr/lib/python2.4/site-packages/gst-0.10/gst/interfaces.so
  • #8 PyEval_EvalFrame
  • #9 PyEval_EvalCodeEx
  • #10 PyEval_EvalCode
  • #11 PyRun_FileExFlags
  • #12 PyRun_SimpleFileExFlags
  • #13 Py_Main
  • #14 __libc_start_main
    from /lib/tls/i686/cmov/libc.so.6
  • #15 _start
  • #0 gst_tuner_get_channel
    at tuner.c line 174
  • #1 initinterfaces
    from /usr/lib/python2.4/site-packages/gst-0.10/gst/interfaces.so
  • #2 PyEval_EvalFrame
  • #3 PyEval_EvalCodeEx
  • #4 PyEval_EvalCode
  • #5 PyRun_FileExFlags
  • #6 PyRun_SimpleFileExFlags
  • #7 Py_Main
  • #8 __libc_start_main
    from /lib/tls/i686/cmov/libc.so.6
  • #9 _start
  • #0 __kernel_vsyscall
  • #1 raise
    from /lib/tls/i686/cmov/libc.so.6
  • #2 abort
    from /lib/tls/i686/cmov/libc.so.6
  • #3 g_logv
    from /usr/lib/libglib-2.0.so.0
  • #4 g_log
    from /usr/lib/libglib-2.0.so.0
  • #5 g_return_if_fail_warning
    from /usr/lib/libglib-2.0.so.0
  • #6 gst_implements_interface_cast
    at gstinterface.c line 147
  • #7 _wrap_gst_tuner_get_channel
    at interfaces.c line 1775
  • #8 PyEval_EvalFrame
  • #9 PyEval_EvalCodeEx
  • #10 PyEval_EvalCode
  • #11 PyRun_FileExFlags
  • #12 PyRun_SimpleFileExFlags
  • #13 Py_Main
  • #14 __libc_start_main
    from /lib/tls/i686/cmov/libc.so.6
  • #15 _start
  • #0 gst_tuner_get_channel
    at tuner.c line 179
  • #1 _wrap_gst_tuner_get_channel
    at interfaces.c line 1775
  • #2 PyEval_EvalFrame
  • #3 PyEval_EvalCodeEx
  • #4 PyEval_EvalCode
  • #5 PyRun_FileExFlags
  • #6 PyRun_SimpleFileExFlags
  • #7 Py_Main
  • #8 __libc_start_main
    from /lib/tls/i686/cmov/libc.so.6
  • #9 _start

Comment 12 Fredrik Persson 2006-09-22 17:29:17 UTC
Changing the script from:

import gst
import gobject

source = gst.element_factory_make("v4l2src")
print source.get_channel()

... to...

import gst
import gobject

source = gst.element_factory_make("v4l2src")
source.set_property("device","/dev/video0")
source.set_state(gst.STATE_PLAYING)
channel = source.get_channel()
print channel.label

... fixed the problem.
Comment 13 Edgard Lima 2006-09-25 13:30:53 UTC
Yes, Since v4l2src inherts from GstPushSrc it will be ok just in PLAYING state.

Hi Edward,

v4l2src implements gst_v4l2src_iface_supported (in gstv4l2src.c:145) just like v4lsrc.
Please let me know if I am missing something here.

BR,
Edgard
Comment 14 Thomas Vander Stichele 2006-10-03 14:04:15 UTC
I double-checked this; the first application still makes both vl4src and v4l2src segfault.  It doesn't matter that they both do the same thing - they should not segfault because of this code.  This needs to be fixed.
Comment 15 Wim Taymans 2007-03-02 09:52:35 UTC
ping?
Comment 16 Fredrik Persson 2007-07-22 12:10:02 UTC
I just tried the script that triggered this error on a Ubuntu Feisty machine, which seems to run -good 0.10.5. 

It no longer segfaults, but instead returns "None".

This is the printout:

frepe@lovin:~$ python simple_segfault.py 

(simple_segfault.py:18318): GStreamer-CRITICAL **: gst_implements_interface_cast: assertion `gst_element_implements_interface (GST_ELEMENT (from), iface_type)' failed

** (simple_segfault.py:18318): CRITICAL **: gst_tuner_get_channel: assertion `GST_IS_TUNER (tuner)' failed
None

Mind you, I have no device attached to this computer. So I don't know what happens in that case. But it does look promising! I'll try it with a grabber device and see what happens, as soon as possible.
Comment 17 Stefan Sauer (gstreamer, gtkdoc dev) 2007-10-15 06:50:59 UTC
Thomas: can you attach a small test app that triggers the crash (python?)
Comment 18 Edgard Lima 2007-10-15 08:26:09 UTC
Created attachment 97232 [details]
simple C program to show when Tuner interface is available

this is the output:

(a.out:9402): GStreamer-CRITICAL **: gst_implements_interface_cast: assertion `gst_element_implements_interface (GST_ELEMENT (from), iface_type)' failed
  v4l2src just created
    debug 1: tuner is still NULL
    debug 1: channel is still NULL
  v4l2src just added to pipeline and linked

(a.out:9402): GStreamer-CRITICAL **: gst_implements_interface_cast: assertion `gst_element_implements_interface (GST_ELEMENT (from), iface_type)' failed
    debug 2: tuner is still NULL
    debug 2: channel still NULL
  v4l2src just put in playing state
    debug 3: tuner and channel not nil

ok, so please let me know what is the expected output from that C program.
Comment 19 Tim-Philipp Müller 2007-11-13 22:05:52 UTC
As far as I can see, this has been fixed ages ago, in gst-plugins-base 0.10.11 (feisty shipped 0.10.12), by this commit:

 2006-10-17  Tim-Philipp Müller  <tim at centricular dot net>

        * gst-libs/gst/interfaces/tuner.c: (gst_tuner_list_channels),
        (gst_tuner_set_channel), (gst_tuner_get_channel),
        (gst_tuner_list_norms), (gst_tuner_set_norm), (gst_tuner_get_norm),
        (gst_tuner_set_frequency), (gst_tuner_get_frequency),
        (gst_tuner_signal_strength), (gst_tuner_find_norm_by_name),
        (gst_tuner_find_channel_by_name):
          Fix some function guards, add some more function guards.

The way I read the comments so far:
 - the bug happens with edgy (shipping core/base 0.10.10)
 - the bug report has confirmed it does not happen any longer
   with feisty (shipping core/base 0.10.12) (or rather: you
   only get those assertion failures, which is what is expected
   here given the wrong state; same as with the C API in any case)
 - no one claims they can reproduce the bug with anything > -base 0.10.11

If I'm missing something, please re-open (or preferably file a new bug).