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 555978 - [ladspa] no elements exposed/found on Cygwin
[ladspa] no elements exposed/found on Cygwin
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
0.10.22
Other Cygwin
: Normal blocker
: 0.10.23
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-10-12 04:35 UTC by Yaakov Selkowitz
Modified: 2009-04-17 11:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case (2.20 KB, text/plain)
2008-10-12 04:37 UTC, Yaakov Selkowitz
  Details
results from plugin (10.79 KB, text/plain)
2008-10-12 04:42 UTC, Yaakov Selkowitz
  Details
results from program (48.40 KB, text/plain)
2008-10-12 04:46 UTC, Yaakov Selkowitz
  Details
results from listplugins (10.71 KB, text/plain)
2008-10-12 04:54 UTC, Yaakov Selkowitz
  Details
full debug log (41.41 KB, application/x-compressed-tar)
2008-10-23 09:34 UTC, Yaakov Selkowitz
  Details
full debug log (with registry deleted) (65.04 KB, application/x-compressed-tar)
2008-10-23 16:51 UTC, Yaakov Selkowitz
  Details
core configure.ac patch (903 bytes, patch)
2009-03-01 07:17 UTC, Yaakov Selkowitz
none Details | Review
Cygwin unsafe fork patch (826 bytes, patch)
2009-03-01 23:19 UTC, Yaakov Selkowitz
none Details | Review
revised Cygwin patch (1.31 KB, patch)
2009-03-09 21:56 UTC, Yaakov Selkowitz
committed Details | Review

Description Yaakov Selkowitz 2008-10-12 04:35:26 UTC
I have got LADSPA (ladspa-sdk, ladspa-cmt, and swh-plugins) working on Cygwin, but the GStreamer ladspa plugin is not registering any elements.  The problem appears to be that the gstladspa plugin is a module; a program made with the same code appears to work as expected.

I'm attaching a test case and results to help figure this out.
Comment 1 Yaakov Selkowitz 2008-10-12 04:37:03 UTC
Created attachment 120419 [details]
Test case

This patch adds some printf()s around the callback, and adds a main.c which will be used to make a program out of the module.
Comment 2 Yaakov Selkowitz 2008-10-12 04:42:26 UTC
Created attachment 120420 [details]
results from plugin

After patching, build and install the ladspa plugin and run "gst-inspect ladspa"; these are the results on my machine.
Comment 3 Yaakov Selkowitz 2008-10-12 04:46:32 UTC
Created attachment 120421 [details]
results from program

Now make the test case into a program:
make main.o
gcc -o test.exe main.o .libs/*.o `pkg-config --libs gstreamer-0.10`
./test

Here are the results from my machine.
Comment 4 Yaakov Selkowitz 2008-10-12 04:54:36 UTC
Created attachment 120422 [details]
results from listplugins

For good measure, this is the output of listplugins (from ladspa-sdk) on my machine.
Comment 5 Stefan Sauer (gstreamer, gtkdoc dev) 2008-10-13 20:45:40 UTC
Have you perhaps installed the ladspa-plugins after the gstreamer one? Does it help to remove the registry cache in $HOME/.gstreamer-0.10/ and re-run gst-inspect.
Comment 6 Yaakov Selkowitz 2008-10-13 21:10:00 UTC
> Does it help to remove the registry cache in $HOME/.gstreamer-0.10/ and 
> re-run gst-inspect.

No, tried that already.
Comment 7 Stefan Sauer (gstreamer, gtkdoc dev) 2008-10-20 11:52:49 UTC
can you please attach a log like this after the registry has been reset
GST_DEBUG="ladspa*:4" GST_DEBUG_NO_COLOR=1 gst-inspect ladspa 2>debug.log
Comment 8 Yaakov Selkowitz 2008-10-23 06:26:41 UTC
The log is empty.
Comment 9 Stefan Sauer (gstreamer, gtkdoc dev) 2008-10-23 08:14:45 UTC
GST_DEBUG="*:4" GST_DEBUG_NO_COLOR=1 gst-inspect 2>debug.log

if its still empty, your gstreamer has logging disabled. It would be quite hard to figure out anything then. For developers its a good idea to have it enabled.
Comment 10 Yaakov Selkowitz 2008-10-23 09:34:55 UTC
Created attachment 121185 [details]
full debug log

> GST_DEBUG="*:4" GST_DEBUG_NO_COLOR=1 gst-inspect 2>debug.log
That's anything but empty; compressing due to bugzilla attachment size limit.
Comment 11 Stefan Sauer (gstreamer, gtkdoc dev) 2008-10-23 10:42:41 UTC
GST_INIT /usr/src/ports/media/gstreamer0.10/gstreamer010-0.10.21-1/src/gstreamer-0.10.21/gst/gst.c:671:scan_and_update_registry: Validating registry cache: /home/Yaakov/.gstreamer-0.10/registry.i686.bin
...
GST_INIT /usr/src/ports/media/gstreamer0.10/gstreamer010-0.10.21-1/src/gstreamer-0.10.21/gst/gst.c:738:scan_and_update_registry: Registry cache has not changed

I was asking for such a log, which out having a registry. The ladspa plugin is registered. But I would need to see a log where the cache is rebuild, to see why the ladspa plugin does not register any elements.
Comment 12 Yaakov Selkowitz 2008-10-23 16:51:50 UTC
Created attachment 121208 [details]
full debug log (with registry deleted)
Comment 13 Stefan Sauer (gstreamer, gtkdoc dev) 2008-10-23 18:50:17 UTC
  pcLADSPAPath = g_strdup_printf ("%s:/usr/lib/ladspa:/usr/local/lib/ladspa",
      getenv ("LADSPA_PATH"));

Have you exported LADSPA_PATH? Is there a standart location where those are installed under windows?
Comment 14 Yaakov Selkowitz 2008-10-23 19:03:48 UTC
Cygwin != Windows.  Cygwin uses a *NIX file hierarchy; the plugins are in /usr/lib/ladspa, and LADSPA_PATH is exported as such.
Comment 15 Stefan Sauer (gstreamer, gtkdoc dev) 2008-10-24 07:44:12 UTC
Sorry, got it. The scanning happens in ext/ladspa/search.c. Could ypu try adding some printfs there or start gst-inspect (after removing the resgistry) in gdb and set a break point to LADSPAPluginSearch ?
Comment 16 Tim-Philipp Müller 2009-02-28 17:52:41 UTC
Yaakov: ping?
Comment 17 Yaakov Selkowitz 2009-03-01 07:17:52 UTC
Created attachment 129771 [details] [review]
core configure.ac patch

Thanks for the nudge.  I took a fresh look at this and I finally figured this out.

Since the loading of LADSPA plugins is left to the client code, and the base LADSPA plugins are not built with libtool, the Cygwin Ports ladspa-* packages use the .so extension as on other platforms.

The problem here was that GStreamer was ignoring the LADSPA plugins because they didn't match the .dll extension usually used on Cygwin (as defined by G_MODULE_SUFFIX).

I'm attaching a patch for core's configure.ac which defines GST_EXTRA_MODULE_SUFFIX to fix this issue, and fixes some other platform-specific-settings issues (Cygwin *is* a POSIXy platform, and while we have fork(), it's a bit safer to avoid it if the option exists).
Comment 18 Sebastian Dröge (slomo) 2009-03-01 19:03:27 UTC
While this patch is probably correct this doesn't explain this bug as the ladspa plugin simply tries to dlopen() all files inside the ladspa plugin directories, no matter what extension they have. Do you have an idea why this patch fixes this bug for you?
Comment 19 Yaakov Selkowitz 2009-03-01 23:19:39 UTC
Created attachment 129813 [details] [review]
Cygwin unsafe fork patch

You're right; it looks like I stumbled upon the real solution when I changed the other platform-specific settings.  After testing each of the changes in the patch individually, it turns out the GST_EXTRA_MODULE_SUFFIX isn't the issue after all.

For some reason that I don't perfectly understand yet, if the registry is rebuilt from a fork(), the ladspa plugins either aren't properly loaded.  If the registry fork is disabled, then they load just fine.

Since anyway using fork() on Cygwin can be problematic under certain circumstances, all we need to do is define GST_HAVE_UNSAFE_FORK.  Patch attached.
Comment 20 Sebastian Dröge (slomo) 2009-03-02 15:34:36 UTC
The problem might be that a non-forking registry will already have the ladspa plugins loaded, tries to load them a second time when the gstreamer ladspa plugin is initialized and then things go wrong... but this is just a guess ;)
Comment 21 Stefan Sauer (gstreamer, gtkdoc dev) 2009-03-05 20:55:51 UTC
I have rewritten the plugin loading for ladspa totally. It now uses glibs gmodule and it also G_MODULE_BIND_LOCAL, which might help. Could you retry with gst-plugins-bad from git?
Comment 22 Yaakov Selkowitz 2009-03-06 00:58:28 UTC
(In reply to comment #21)
> I have rewritten the plugin loading for ladspa totally. It now uses glibs
> gmodule and it also G_MODULE_BIND_LOCAL, which might help. Could you retry with
> gst-plugins-bad from git?

Rebuilt core .22 without the UNSAFE_FORK define and tried -bad from git.  Results are the same: ladspa elements are only found if forking is disabled.  FYI, same happens w/o G_MODULE_BIND_LOCAL.

OTOH I see no regressions, and the lrdf support is a plus.
Comment 23 Stefan Sauer (gstreamer, gtkdoc dev) 2009-03-06 20:15:39 UTC
(In reply to comment #22)
> (In reply to comment #21)
> > I have rewritten the plugin loading for ladspa totally. It now uses glibs
> > gmodule and it also G_MODULE_BIND_LOCAL, which might help. Could you retry with
> > gst-plugins-bad from git?
> 
> Rebuilt core .22 without the UNSAFE_FORK define and tried -bad from git. 
> Results are the same: ladspa elements are only found if forking is disabled. 
> FYI, same happens w/o G_MODULE_BIND_LOCAL.
> 
> OTOH I see no regressions, and the lrdf support is a plus.
> 

There is now a bit more logging. Could you reattach a log. What I wonder is if in ladspa_plugin_directory_search() it fails to load the plugins. Maybe you can even add one or two more log-statements there. Thanks for your patience with this.
Comment 24 Yaakov Selkowitz 2009-03-09 21:46:11 UTC
I think I may have made some progress in figuring this out.

Having installed a few more LADSPA plugins since I opened this bug, I see now that different plugins behave differently when the registry is scanned in a fork():

1) vlevel: actually registers!
2) blop: segfaults (caught by GStreamer segtrap)
3) sdk, cmt, caps, swh-plugins, vcf: do not register.

All of the above register when fork() is disabled.

I'm not sure about blop yet, but AFAICS the notable difference between vlevel and the others is that vlevel uses a standard C++ ctor/dtor while the others use __attribute__((ctor/dtor)) _init()/_fini().  Could that make a difference in terms of how they are loaded?
Comment 25 Yaakov Selkowitz 2009-03-09 21:56:32 UTC
Created attachment 130353 [details] [review]
revised Cygwin patch

Looking around in gst/gst.c, I found another Windows-ism applied to Cygwin.  This patch supersedes the last two by adding a fix for that as well.

Let me clarify that this patch should be applied *regardless* of any changes to the ladspa plugin.  Cygwin's fork(), while it generally works, is prone to issues which would better be avoided if the option exists, as it does here.
Comment 26 Tim-Philipp Müller 2009-04-16 00:56:48 UTC
I wonder whether this should go into the prereleases? Marking as blocker for now.
Comment 27 Jan Schmidt 2009-04-17 07:56:23 UTC
Is it intentional to remove the "AC_DEFINE_UNQUOTED(HAVE_WIN32, 1, [Defined if compiling for Windows])" line from the cygwin case in configure.ac?
Comment 28 Yaakov Selkowitz 2009-04-17 10:22:04 UTC
Yes.  The comment explaining HAVE_WIN32 should make it clear exactly why it doesn't apply to Cygwin.
Comment 29 Jan Schmidt 2009-04-17 10:26:33 UTC
Coolo. Thanks!
Comment 30 Tim-Philipp Müller 2009-04-17 11:00:34 UTC
commit 4ce04783b37fd25ffc298b8e642f73ba275a2830
Author: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Date:   Fri Apr 17 11:44:11 2009 +0100

    configure.ac: fork() during registry scanning is unsafe on Cygwin
    
    Fixes #555978.

commit eacfe25cf9d503fd8ca7ec16ca2918551cdd3d83
Author: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Date:   Fri Apr 17 11:39:59 2009 +0100

    gst_init: relocatability is unnecessary on Cygwin
    
    See #555978.