Even though you don't specify on what OS and compiler you tried to
compile and run the TestGtkEmbed, this segmentation fault issue is a
"classic" one on many (usually non-Linux) UNIX machines.

I had the same problem myself (on Solaris 10, using Sun Studio 11
compilers) and after a lot of searching on the Internet I could not
find any solution, so I tried to figure out myself how to solve this
problem and after a lot (I mean a lot) of debugging I think I've found
where the problem lies.

The segmentation fault occurs upon the first call of gtkmozembed
library function from the TestGtkEmbed program due to the fact that
those gtkmozembed functions are not exported correctly from the
library.

Open this file:

/mozilla/embedding/browser/gtk/src/gtkmozembed.h

and go to line 70. There is the following macro definition:

#define GTKMOZEMBED_API(type, name, params) \
  typedef type (NS_FROZENCALL * name##Type) params; \
  extern name##Type name NS_HIDDEN;

The NS_HIDDEN macro implies that the name external variable should be
hidden.
This macro is defined in file

/mozilla/xpcom/base/nscore.h

The problem is that in Solaris (and perhaps in several other non-Linux
unix-es) this macro resolves to nothing (null string) making thus the
exported symbol NOT hidden and resulting segmentation fault when
running TestGtkEmbed.

In Sun C++ compiler (the one I use), a symbol is marked as hidden when
the keyword __hidden is prepended to the symbol’s declaration.
Therefore, a quick and dirty (and perhaps non portable) resolution for
this is to modify the macro definition as follows:

#define GTKMOZEMBED_API(type, name, params) \
  typedef type (NS_FROZENCALL * name##Type) params; \
  extern __hidden name##Type name NS_HIDDEN;

After doing this I had no problem whatsoever running TestGtkEmbed.

If you are using another compiler, you should check the compiler's
documentation and find what keyword you should prepend to the
decleration of a symbol in order to render it hidden.

The proper solution, of course, would be to modify the NS_HIDDEN macro
in the nscore.h file so that when the source is configured, the macro
would expand to the appropriated keyword.

Perhaps someone should file a bug at bugzilla.mozilla.org about this.

I hope this helps.
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding

Reply via email to