Also shared libraries may contain more than one interface implementation...


André Draszik wrote:
Hi,

Unless I'm missing something, it seems that DirectFB's module loading code is utterly broken for modules where the constructor is not invoked automatically, e.g. due to miscompilation. (I am not sure why it exists in the first place, though. Just for old and broken compilers/linkers?)


Currently, DirectFB's lib/direct/modules.c will try to call a function with a name of shared_library_name with lib and .so removed in case the module did not have an __attribute__((constructor)) function. This works for many cases of the existing modules in the DirectFB source tree, but not for all:

1) the constructor function name of many (but not all) modules has had the string "_ctor" added a while ago.

2) some modules don't fit into this naming scheme (all which use the
DIRECT_INTERFACE_IMPLEMENTATION macro to implement an interface), as they use different cApITAliSaTION rules for the function type name vs. the shared library name (e.g. IDirectFBImageProvider_GIF_ctor() vs.
libidirectfbimageprovider_gif.so).


These two actually mean that trying to call a 'default' constructor function after dlopen() has not been helpful for solving anything for quite a while.


In addition, and this is more severe, even if the constructor can be fixed, we'll likely get memory leaks. The destructor will not be called and nobody would notice, because things will appear to be working, making it hard to find the reason. OK, one could add printf()s and warnings, but still. Or of course add even more code to somehow work around the issue.


The question to be asked - would it be useful? And it appears to me that given the existing code is not working in many cases (and nobody noticed in the last couple of years(!) (AFAIR)), and we may get memory leaks, that today it is not. I propose the removal of the related code.

Please see the patch attached.

What do you think?


Cheers,
Andre'

_______________________________________________
directfb-dev mailing list
directfb-dev@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to