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 454259 - Requestable Pad Segfaults When No Name Is Supplied
Requestable Pad Segfaults When No Name Is Supplied
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-python
git master
Other All
: Normal critical
: 0.10.8
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2007-07-06 13:06 UTC by Corey O.
Modified: 2007-07-09 19:47 UTC
See Also:
GNOME target: ---
GNOME version: 2.17/2.18



Description Corey O. 2007-07-06 13:06:39 UTC
Steps to reproduce:
#!/usr/bin/env python

import pygst
pygst.require('0.10')
import gst
import sys
import gobject
gobject.threads_init()

class PyTee(gst.Element):

  __gstdetails__ = ('Tee Plugin',
                    "tee",
                    "Simple Tee Plugin",
                    "Corey O.")

  _srcpadtemplate = gst.PadTemplate ("src%d",
                                     gst.PAD_SRC,
				     gst.PAD_REQUEST,
				     gst.caps_new_any())

  _sinkpadtemplate = gst.PadTemplate ("sink",
                                      gst.PAD_SINK,
                                      gst.PAD_ALWAYS,
                                      gst.caps_new_any())

  __gsttemplates__ = (_srcpadtemplate, _sinkpadtemplate)

  def __init__(self):
    gst.Element.__init__(self)
    self.src_pad_count = 0
    self.src_pads = []

    self.sinkpad = gst.Pad(self._sinkpadtemplate)
    self.add_pad(self.sinkpad)

    self.sinkpad.set_chain_function(self.chainfunc)
    self.sinkpad.set_event_function(self.eventfunc)

  def do_request_new_pad(self, template, name=None):
    name = "src%d" % self.src_pad_count
    self.src_pad_count += 1
    pad = gst.Pad(template, name)
    self.src_pads.append(pad)
    self.add_pad(pad)
    return pad

  def do_release_pad(self, pad):
    self.src_pads.pop(self.src_pads.index(pad))
    self.remove_pad(pad)

  def chainfunc(self, pad, buffer):
    if len(self.src_pads) == 0:
      return gst.FLOW_NOT_LINKED
    else:
      for pad in self.src_pads:
        status = pad.push(buffer)
        if status != gst.FLOW_OK:
          return status
      return gst.FLOW_OK

  def eventfunc(self, pad, event):
    for srcpad in self.src_pads:
      status = srcpad.push_event(event)
    return status

gobject.type_register(PyTee)
gst.element_register(PyTee, 'pytee')

def on_message(bus, message):
  type = message.type
  if type == gst.MESSAGE_ERROR:
    err, debug = message.parse_error()
    print 'MESSAGE_ERROR =', err
    print 'MESSAGE_DEBUG =', debug

def main(args):
  # NOTE: the following two pipelines work properly
  #pipeline = gst.parse_launch ("fakesrc ! pytee name=tee .src0 ! fakesink")
  #pipeline = gst.parse_launch ("fakesrc ! pytee name=tee .src0 ! queue ! fakesink tee.src1 ! queue ! fakesink")
  # this pipeline causes a segfault
  pipeline = gst.parse_launch ("fakesrc ! pytee name=tee ! fakesink")
  bus = pipeline.get_bus()
  bus.add_signal_watch()
  bus.connect('message', on_message)
  pipeline.set_state(gst.STATE_PLAYING)
  try:
    gobject.MainLoop().run()
  except KeyboardInterrupt:
    pipeline.set_state(gst.STATE_NULL)
    return 0
  return -1

if __name__ == '__main__':
  sys.exit(main(sys.argv))

Stack trace:
gdb --args python requesttest.py
GNU gdb 6.6-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
(gdb) run
Starting program: /usr/bin/python requesttest.py
[Thread debugging using libthread_db enabled]
[New Thread -1209837360 (LWP 12926)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1209837360 (LWP 12926)]
0xb7ea3c23 in strlen () from /lib/tls/i686/cmov/libc.so.6
(gdb) tb
Breakpoint 1 at 0xb7ea3c23
(gdb) quit
The program is running.  Exit anyway? (y or n) y

Other information:
The above script segfaults every time before much of the python code is ever run.  The first two commented pipelines work just fine (when names are supplied), but the third, uncommented one (with no pad names) segfaults.

obviously, there's a problem translating NULL
Comment 1 Edward Hervey 2007-07-09 19:47:54 UTC
2007-07-09  Edward Hervey  <bilboed@bilboed.com>

	* gst/gstelement.override:
	Override the proxy method for GstElement::request_new_pad virtual
	methods since it can be called with NULL as the name.
	Fixes #454259