0

I'm building a new 64bit Debian Squeeze server, and Postgres 8.4 reports the well documented 'undefined __gxx_personality_v0' error when I try to restore a database.

The lib builds/installs fine.

However, the source is c, not c++ which seems to be where __gxx_personality_v0 belongs.

The code is from a 32bit Etch/postgres 8.1 environmnet.

I'm kind of stuck - but I bet the solution is very simple!

1 Answer 1

2

Test to see whether the issue is actually related to PostgreSQL, or if it is a problem with your library build. Here's a simple program you can use to dlopen() your library and resolve a symbol. Compile it with:

gcc dlopentest.c -o dlopentest -ldl

... and run it as:

./dlopentest /path/to/my/lib.so somesymbol

or for more info prefix LD_DEBUG=symbols (for other options LD_DEBUG=help) eg:

LD_DEBUG=symbols ./dlopentest /path/to/my/lib somesymbol

Which symbol to look for depends on your code and what it's for. You haven't provided enough information to say.

This test program won't work with any library that requires symbols from the postgresql executable in order to load and init, so if your code is (for example) a procedural language it won't load. Most simple modules load fine, though.

You should also examine the output of:

ldd /path/to/your/library.so

to see if it's linking to libstdc++ or anything else you don't expect.

Here's the test program:

// Compile with a c99 compiler; I don't use oldstyle declarations
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>

int main(int argc, char * argv[]) {

  if (argc != 3) {
    printf("Usage: %s /path/to/lib/to/load symbol_to_resolve\n", argv[0]);
    printf("   eg: %s libc.so.6 gettimeofday\n", argv[0]);
    return 1;
  }

  char * err;
  const char * const libname = argv[1];
  const char * const symname = argv[2];

  dlerror();  // clear dl error state before starting work

  void * libhandle = dlopen(libname, RTLD_LAZY);
  if ( (err = dlerror()) != NULL ) {
    printf("Failed to load library: %s\n", err);
    return 2;
  }

  void * symhandle = dlsym(libhandle, symname);
  if ( (err = dlerror()) != NULL ) {
    printf("Failed to load symbol: %s\n", err);
    return 2;
  }
  printf("Successfully retrieved symbol %s from library %s\n", symname, libname);

  // Optional since we're existing, but good for testing:
  if ( (err = dlerror()) != NULL ) {
    printf("Failed to close lib during exit: %s\n", err);
    return 2;
  }

  return 0;
}
Sign up to request clarification or add additional context in comments.

4 Comments

Postregs has been installed from a package. The lib is one of our own. The source builds/runs fine on etch, but when built on the new server causes Postgres to complain as described. Isn't Postgres 8.4 the current Squeeze stbale release? If you're referring to 8.1, I know it's old, that's why I'm trying to upgrade :)
Ah, sorry. I missed the fact that you were going up to 8.4 and got the impression you were trying to get 8.1 going with your code on Squeeze.
Is your library code compiled with g++ or with gcc ? Does it link to any other libraries not shipped with the system? Can a simple test program dlopen() your library without problems - ie is the issue only when loaded by PostgreSQL, or is the issue actually loading your custom library at all?
Finally, it'd help to know if your problem library is a PostgreSQL extension (C function/type or similar) or whether it serves some other purpose like a plperl or plpython module, a LD_PRELOAD library, etc. If it is a postgresql extension module with PG_MODULE_MAGIC etc, does it use the V0 or V1 API? Does it build using the standard pgxs, or with some homebrew build script? If you run objdump -T mylibname.so | grep UND do you see the __gxx_personality_v0 symbol listed? Do you only get the error when you try to restore a DB that uses your custom C function / data type? Or any DB?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.