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 341170 - libdevhelp linking stratagy
libdevhelp linking stratagy
Status: RESOLVED FIXED
Product: devhelp
Classification: Applications
Component: General
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Mikael Hallendal
Mikael Hallendal
: 305557 341054 346778 348410 (view as bug list)
Depends on:
Blocks: 374709
 
 
Reported: 2006-05-09 18:32 UTC by Tristan Van Berkom
Modified: 2007-02-02 15:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to add 'ldflags' variable in libdevhelp-1.0.pc for external external executables (1.25 KB, patch)
2007-01-23 14:43 UTC, Naba Kumar
none Details | Review

Description Tristan Van Berkom 2006-05-09 18:32:25 UTC
Ideally,
     `pkg-config --cflags --libs libdevhelp-1.0` should get
me all the compile flags I need to link in the gecko, currently
it doesnt.

The problem here as I see it... is a little more complex than
adding requires firefox-gtkmozembed to the .pc file (which I guess
should ideally take care of everything).

Note that currently; I link against libdevhelp-1.0 using the .pc and
the build passes... at my home computer everything "just works"...
(probably due to some magic gecko build that actually works in stock
releases, or something to do with hardcoded link paths etc)
here at work it consistantly segfaults in Embed::Realize() unless
I set the env var MOZILLA_FIVE_HOME to the installation directory of
the gecko.

I'm filing this bug here... because I believe that linking the gecko
should be implicit to linking in devhelp... although I havent really
thought out a solution yet (admittedly.. I think most of the real
problem resides in the gecko build process, which in some cases results
in bug 334867, at other times it generates a mozembed test program that
will only run from the directory it was built in... and theres also that
nasty env var... that shouldnt be nescisary)
Comment 1 Johannes Schmid 2006-05-10 16:16:54 UTC
Possibly also related to Bug #341054!

IMHO, it would be cool, if libdevhelp would allow to completly skip gecko/gtkmozembed and to allow the application to decide wether it wants to use gecko or gtkhtml for example.
Comment 2 Richard Hult 2006-05-12 07:53:29 UTC
I'm not interested in supporting different HTML widgets, we did that in the past and it simply didn't work. (The subset of common functionality/API is close to zero and it was a lot of extra work.)

The main focus here is the devhelp app, the library is just a side-effect.
Comment 3 Johannes Schmid 2006-05-12 11:59:14 UTC
I thought about it once more and it became clear that supporting other html widgets does not really makes sense as gtkhtml is likely to be deprecated.

Although you might thing the library is just a side effect it would be great of you would take care of it. I think most people who use the library are willing to help out but it is at you to accept patches/proposels.

Having an intergrated API help is a real advantage!
Comment 4 Richard Hult 2006-05-16 07:21:20 UTC
I wonder if we can put -R<...> in the pc file. That would probably be the best solution. That's what devhelp itself does.
Comment 5 Tristan Van Berkom 2006-05-16 13:34:06 UTC
Hmmm, thats similar to what Naba Kumar and I were thinking...

maybe the -R should be applied directly to the libdevhelp.so
itself and not to the application linking it ?

I'm going to try to reproduce this consistantly at home...
maybe using jhbuild/opt prefix, then hopefully I can see
a fix work before really proposing one.
Comment 6 Richard Hult 2006-05-16 16:19:36 UTC
That sounds like the best way indeed!
Comment 7 Paolo Borelli 2006-05-19 20:17:31 UTC
here is some debug cruft as requested by tristan on irc, since on my system glade3 crashes as soon as I try to press the documentation button, apparently to faulty gecko linking.


paolo@murdock:~/cvs/gnome2/gedit$ ldd /opt/gnomecvs/lib/glade-3/plugins/libgladedevhelp.so
        linux-gate.so.1 =>  (0xffffe000)
        libdevhelp-1.so.0 => /opt/gnomecvs/lib/libdevhelp-1.so.0 (0xb7f38000)
        libgnomeui-2.so.0 => /opt/gnomecvs/lib/libgnomeui-2.so.0 (0xb7eb3000)
        libSM.so.6 => /usr/lib/libSM.so.6 (0xb7e98000)
        libICE.so.6 => /usr/lib/libICE.so.6 (0xb7e80000)
        <... snip many gnome libs ...>
        libglade-2.0.so.0 => /opt/gnomecvs/lib/libglade-2.0.so.0 (0xb740e000)
        libgtkembedmoz.so => /usr/lib/firefox/libgtkembedmoz.so (0xb73fa000)
        libxpcom.so => /usr/lib/firefox/libxpcom.so (0xb73f7000)
        libplds4.so => /usr/lib/libplds4.so (0xb73f4000)
        <... snip other libs ...>
        libXinerama.so.1 => /usr/lib/libXinerama.so.1 (0xb6eeb000)
        /lib/ld-linux.so.2 (0x80000000)
        libpng12.so.0 => /usr/lib/libpng12.so.0 (0xb6ec8000)
        libxpcom_core.so => /usr/lib/firefox/libxpcom_core.so (0xb6e2d000)
        <... snip more libs ...>

as you can see the devhelp and gecko seem in place...

and here is the top of the stack trace:

Program received signal SIGSEGV, Segmentation fault.

Thread NaN (LWP 20685)

  • #0 gtk_moz_embed_get_title
    from /usr/lib/firefox/libgtkembedmoz.so
  • #1 gtk_moz_embed_new
    from /usr/lib/firefox/libgtkembedmoz.so
  • #2 IA__g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 77
  • #3 g_type_class_meta_marshal
    at gclosure.c line 567
  • #4 IA__g_closure_invoke
    at gclosure.c line 490
  • #5 signal_emit_unlocked_R
    at gsignal.c line 2368
  • #6 IA__g_signal_emit_valist
    at gsignal.c line 2197
  • #7 IA__g_signal_emit
    at gsignal.c line 2241
  • #8 IA__gtk_widget_realize
    at gtkwidget.c line 2364
  • #9 widget_open_new_tab
    at glade-devhelp.c line 568
  • #10 glade_dh_widget_search
    at glade-devhelp.c line 632
  • #11 glade_util_search_devhelp
    at glade-utils.c line 1756
  • #12 glade_marshal_VOID__STRING_STRING_STRING
    at glade-marshallers.c line 281
  • #13 IA__g_closure_invoke
    at gclosure.c line 490
  • #14 signal_emit_unlocked_R
    at gsignal.c line 2438
  • #15 IA__g_signal_emit_valist
    at gsignal.c line 2197
  • #16 IA__g_signal_emit
    at gsignal.c line 2241
  • #17 glade_editor_on_docs_click
    at glade-editor.c line 237

Comment 8 Tristan Van Berkom 2006-05-19 21:02:55 UTC
<chpe> tristan: that trace says that gecko can't find its xpcom components
<tristan> oooo
<chpe> do you call the devhelp code that does gtk_moz_embed_set_comp_path ?

Apperently the root of the problem here is indeed something about
the gecko linking proceedure...

Note that paolo's mozilla version is 1.5.0.3 dapper... and it is working
fine on my firefox 1.0.7-0 ubuntu build.

The investigation continues...
Comment 9 Richard Hult 2006-05-20 11:59:18 UTC
The above doesn't answer chpe's question. DID you call the devhelp code that does gtk_moz_embed_set_comp_path? :)


Comment 10 Johannes Schmid 2006-05-20 15:55:50 UTC
Both anjuta and glade3 call dh_base_new()/dh_base_get() which itself calls dh_gecko_utils_init which calls gtk_moz_embed_set_comp_path for gecko <= 1.9 and gtk_moz_embed_set_path for gecko = 1.9!

So the answer to chpe's question is yes!

btw, thanks for the code cleanups in dh_base.c
Comment 11 Tristan Van Berkom 2006-05-26 02:07:59 UTC
Ok, I tailored up a patch for test purposes and sent that to Paolo,
basicly it did the configure magic devhelp does to find the system
gecko installation and compile flags, I threw all the resulting 
"-lmozembed -lxpcomstuff..." onto the libgladedevhelp.so (dlopened plugin)
link stage... 

   o The extra linking commands didnt help
   o Throwing -R$(GECKO_HOME) onto the main application link
     stage fixes the problem at his site.

This is a strange behaviour, there are known bugs in mozilla where
older versions require that you set $LD_LIBRARY_PATH and/or
$MOZILLA_FIVE_HOME but have apperently been fixed since, both
Paolo and I have fairly recent gecko versions.

would be nice to know if it worked on other systems using the 
same gecko version. 

personally I'm giving up, I may focus on making sure the devhelp 
plugin works/links nicely in anjuta; but will fallback to spawning 
devhelp with the '-s' param from glade-3.
Comment 12 Johannes Schmid 2006-07-06 16:33:10 UTC
*** Bug 346778 has been marked as a duplicate of this bug. ***
Comment 13 Johannes Schmid 2006-07-06 16:33:44 UTC
*** Bug 341054 has been marked as a duplicate of this bug. ***
Comment 14 Johannes Schmid 2006-07-06 16:34:14 UTC
*** Bug 305557 has been marked as a duplicate of this bug. ***
Comment 15 Johannes Schmid 2006-07-23 12:40:20 UTC
*** Bug 348410 has been marked as a duplicate of this bug. ***
Comment 16 Richard Hult 2006-08-19 19:04:26 UTC
Is there anything that you want to change in devhelp? It's not clear to me what the consensus was here...
Comment 17 Tristan Van Berkom 2006-08-20 02:45:24 UTC
Hi,
    Sorry that all of this landed on the devhelp bugzilla product,
I think some things are clear:
 - There is problems with the current gecko linking scheme, and
   that is a gecko problem, not a devhelp problem
 - Since libdevhelp links to a library that doesnt behave correctly
   on all systems without hard coding the gecko path into the executable
   itself, this is in fact - a thing that should be fixed in libdevhelp
   if ever the gecko permits by fixing thier own bugs.

One thing that could be doable - define which gecko installations
support linking without the -R option (by trial and error I suppose,
or by user reports) and require an installation that works - in a 
seperate .pc file used only by plugins ?

That would limit the availability of devhelp plugins, but provide
a stable plugin...

on the other hand plugin writers could work around it by creating
binaries that run as child processes using hand made IPC with
io channels and such...
Comment 18 Naba Kumar 2007-01-23 14:09:57 UTC
(In reply to comment #16)
> Is there anything that you want to change in devhelp? It's not clear to me what
> the consensus was here...
> 
One thing that can be done for now, I believe, is to have a variable in libdevhelp-1.0.pc, perhaps call it ldflags, that contains the '-R$(GEKCO_HOME)' line. If devhelp was built without gecko or gecko is fixed later, the field can be left empty.

Also note that clubing it together with Libs field in .pc won't work if libdevhelp.so is linked against another shared library as in anjuta plugin, because the flag must go with executable to work.

In anjuta or glade3, the flag can be picked up while checking for devhelp and can be passed to the binary executable.

This seems to be the only solution for now to avoid user setting LD_LIBARARY_PATH=/gecko/home explicitly before running either anjuta or glade-3.
Comment 19 Naba Kumar 2007-01-23 14:43:21 UTC
Created attachment 80987 [details] [review]
Patch to add 'ldflags' variable in libdevhelp-1.0.pc for external external executables

Once the patch is applied, in anjuta's configure.in, I did:

if test x$devhelp_enabled = xyes; then
  PLUGIN_DEVHELP_LDFLAGS=`$PKGCONFIG_CONFIG --variable=ldflags libdevhelp-1.0`
  AC_SUBST(PLUGIN_DEVHELP_LDFLAGS)
fi

And in src/Makefile.am:

anjuta_LDFLAGS = $(PLUGIN_DEVHELP_LDFLAGS)

And it worked. glade-3 can probably do the same.
Comment 20 Tristan Van Berkom 2007-01-23 15:31:31 UTC
From what I remember that wasn't enough.

 - If I put -R$(GECKO_HOME) on the ldflags of the glade-3
   executable - it will work on any site.

 - If I dont put the -R$(GECKO_HOME) anywhere - it will work
   on some sites.

 - If I put the -R$(GECKO_HOME) on the libgladedevhelp.so module
   and then dlopen the devhelp plugin module then it will work
   on some sites (i.e. also broken).

The point here is that the application binary itself must
be compiled with the path hardcoded into it - passing the
path to the plugin does not fix the problem.

Comment 21 Naba Kumar 2007-01-23 15:44:09 UTC
(In reply to comment #20)
> From what I remember that wasn't enough.
> 
> The point here is that the application binary itself must
> be compiled with the path hardcoded into it - passing the
> path to the plugin does not fix the problem.
> 
I am not sure if you confusing my point (and the patch). I was talking about the exact same thing. The patch solves it by letting the flag go in executable as demonstrated by me for anjuta binary.
Comment 22 Richard Hult 2007-01-23 16:17:38 UTC
(In reply to comment #19)
> Created an attachment (id=80987) [edit]
> Patch to add 'ldflags' variable in libdevhelp-1.0.pc for external external
> executables
> 
> Once the patch is applied, in anjuta's configure.in, I did:
> 
> if test x$devhelp_enabled = xyes; then
>   PLUGIN_DEVHELP_LDFLAGS=`$PKGCONFIG_CONFIG --variable=ldflags libdevhelp-1.0`
>   AC_SUBST(PLUGIN_DEVHELP_LDFLAGS)
> fi
> 
> And in src/Makefile.am:
> 
> anjuta_LDFLAGS = $(PLUGIN_DEVHELP_LDFLAGS)
> 
> And it worked. glade-3 can probably do the same.

That looks reasonable to me...
Comment 23 Tristan Van Berkom 2007-01-23 16:49:10 UTC
(In reply to comment #21)
> (In reply to comment #20)
> > From what I remember that wasn't enough.
> > 
> > The point here is that the application binary itself must
> > be compiled with the path hardcoded into it - passing the
> > path to the plugin does not fix the problem.
> > 
> I am not sure if you confusing my point (and the patch). I was talking about
> the exact same thing. The patch solves it by letting the flag go in executable
> as demonstrated by me for anjuta binary.
> 

Ok sure, but where does it say in the devhelp.pc that you
can only use this for a final executable ?

From what I see, the devhelp.pc will still create a plugin
module that might crash on some sites, the user of this
pc file needs to be told explicitly that he must use it
for an application, not a module/library.

In gecko-functional world, someone should be able to write
a library or plugin that links to devhelp, that resulting
plugin/library should be usable either by dlopen that plugin
or by linking to that library and using /its/ .pc file.

Comment 24 Naba Kumar 2007-01-23 17:04:37 UTC
(In reply to comment #23)
> (In reply to comment #21)
> 
> Ok sure, but where does it say in the devhelp.pc that you
> can only use this for a final executable ?
> 
> From what I see, the devhelp.pc will still create a plugin
> module that might crash on some sites, the user of this
> pc file needs to be told explicitly that he must use it
> for an application, not a module/library.
> 
Okay, I wasn't even addressing that part of the problem. In a perfect world, libdevhelp should work without the -R path and it should be gecko fixing the problem. But for now, it's a reasonable thing to do especially considering other options such as those you suggested in comment #17.

May be devhelp can document it in README or somewhere.
Comment 25 Richard Hult 2007-01-23 18:00:50 UTC
I kind of agree with Tristan that it's weird that you have to use devhelp's pc file to get linker flags for you APPLICATION, in order to load a plugin that links with devhelp. Surely there must be some other way to solve this?
Comment 26 Tristan Van Berkom 2007-01-23 18:13:27 UTC
Btw, I went and checked and made sure there was a tracker
on mozilla bugzilla, didnt find one and filed this one:

https://bugzilla.mozilla.org/show_bug.cgi?id=367909

Comment 27 Naba Kumar 2007-01-23 19:00:06 UTC
My idea was to live with this workaround until mozilla is fixed. Surely, it's just a matter of a variable in .pc file which can be bypassed when real thing is fixed. I am quite okay to use it in anjuta, but if others feel not to use it and prefer to wait for the official fix, there's nothing preventing it. All the apps using gtkembedmoz, including devhelp, already do it more or less.

Considering that this bug has been in existence for such a long time and mozilla people already aware of this, I won't expect user's installations to have a working version anytime soon. This will atleast prevent all the annoyances (bug #374709) we get with devhelp plugin in anjuta and I am really looking forward to such a crash free devhelp plugin.
Comment 28 Naba Kumar 2007-01-23 19:19:38 UTC
(In reply to comment #25)
> Surely there must be some other way to solve this?
> 
I have tried several things and none has worked for far. As explained in the blog linked in Tristan's bug report (http://benjamin.smedbergs.us/blog/2005/), the mozilla path is always required for the components to be found. Unfortunately, ld.so also doesn't see any changes in LD_LIBRARY_PATH env variable within the process (so you can't change the paths runtime before doing a dlopen and expect the path to be used). This essentially means that it has to be set before the executable is run, either in exporting LD_LIBARARY_PATH or through -R linker flag. It also seems the changes needed to fix this in mozilla isn't trivial either.
Comment 29 Richard Hult 2007-02-02 08:59:55 UTC
Alright, let's add a gecko_home variable (without the the -R), then apps can use this as a workaround, and we can close this bug.

Does that sound OK to you, Naba?
Comment 30 Naba Kumar 2007-02-02 10:06:39 UTC
(In reply to comment #29)
> 
> Does that sound OK to you, Naba?
> 
Yes! Thank you. Finally, we can close this bug :).
Comment 31 Richard Hult 2007-02-02 15:17:33 UTC
Committed. I will close this as the real problem is with Mozilla in my opinion, we have a workaround now that can be used, even if it's a pretty bad solution (apps should not have to bother about what plugins link to).

Sorry for taking so long with this.