7

I have compiled a PostgreSQL plugin, wal2json, but when try to load it in PostgreSQL, it complains:

ERROR: could not load library "/usr/local/lib/postgresql/wal2json.so": Error relocating /usr/local/lib/postgresql/wal2json.so: __snprintf_chk: symbol not found

I found this documentation for __snprintf_chk.

Where it is and what should I do to provide it to the plugin?

My guess is that it's in some core library but not present in the version I have. Maybe I could link it statically?


Update: I figured out that this is an issue of Alpine Linux which uses musl instead of glibc. I have installed the Alpine packages for glibc, as done in https://github.com/jeanblanchard/docker-alpine-glibc/blob/master/Dockerfile . Didn't help, still the same error.

Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277
  • from the docs it appears to be in glibc. – Jasen Jul 14 '18 at 10:21
  • I had a similar issue with [node-gdal](https://github.com/naturalatlas/node-gdal) and solved it by [building GDAL linking against shared libraries](https://stackoverflow.com/a/54875605/506695). – ezze Mar 06 '19 at 08:23

2 Answers2

2

alpine uses musl libc instead of glibc, lacking some libs as you can check by ldd.

solution: check and install glibc pkg, or gcompact or libc6-compat

apk add gcompat

see also:Docker Alpine executable binary not found even if in PATH

elucida
  • 96
  • 5
0

I switched to another base Docker image, Ubuntu. The result is a bit bigger image, but __snprintf_chk is available and works.

Also, PostgreSQL has a Docker image that already has wal2json available, which I used in the end for the production.

Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277
  • Yeah, I know, It's not a real solution, but the only one I had. I think it's still a valid answer, which spares people few hours of trying. Unless someone comes with something better. – Ondra Žižka Dec 18 '19 at 08:45