Bug#475601: Simple test case

Jurij Smakov jurij at wooyd.org
Tue Aug 12 15:04:54 UTC 2008

Here's a simple test case, which fails on sparc (compile with 
g++ test.cxx -lpt):

#include <stdio.h>
#include <ptlib.h>

int main() {
  PDynaLink *dll = new 
  unsigned (*GetAPIVersion)();
  if (dll->GetFunction("PWLibPlugin_GetAPIVersion", 
(PDynaLink::Function &)GetAPIVersion)) {
    printf("TRUE GetAPIVersion=%p\n", GetAPIVersion);
  } else {
    printf("FALSE GetAPIVersion=%p\n", GetAPIVersion);
When run on sparc, it gives:

TRUE GetAPIVersion=(nil)

which is pretty surprising, given that the code of GetFunction reads:

BOOL PDynaLink::GetFunction(const PString & fn, Function & func) 
  if (dllHandle == NULL) 
    return FALSE; 
#if defined(P_OPENBSD) 
  void * p = dlsym(dllHandle, (char *)(const char *)fn); 
  void * p = dlsym(dllHandle, (const char *)fn); 
  if (p == NULL) 
    return FALSE; 
  func = (Function &)p; 
  return TRUE; 

i.e. there appears to be no way for it to return TRUE and set the 
function pointer to NULL simultaneously. For comparison, on my 386 box 
it returns

TRUE GetAPIVersion=0xb72eecec

as expected.

Jurij Smakov                                           jurij at wooyd.org
Key: http://www.wooyd.org/pgpkey/                      KeyID: C99E03CC

More information about the Pkg-voip-maintainers mailing list