Docker Alpine - GraphViz - gvpr causes Segmentation fault (core dumped)

Viewed 396

I'm using the docker image node:12-alpine and install graphviz using apk add graphviz, which installs the version graphviz-2.42.3-r0.

But as I try to execute gvpr, I get just a Segmentation fault (core dumped) as you can see in https://gitlab.com/Lepardo/simplewebspider-nodejs/-/jobs/612093260

Any idea, how I can tackle this issue?

1 Answers

The segfault seems to be a bug in the gvpr program.

This bug seems to be fixed on the latest gvpr version from the edge repository, 2.47.0-r2, which could be installed with:

 apk add graphviz --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main

On graphviz 2.44.0 (Alpine 3.13 and 3.12), the bug seems to reproduce still.

In the graphviz gitlab repository, going over the commit history of gvpr.c, this commit from 13 Aug 2020 stands out:

fix: pass format parameter into gverrorf explicitly

Matthew Fernandez authored 8 months ago

The gverrorf function was prototyped in a way that did not align with a function pointer it was stored into. On platforms with more forgiving varargs calling conventions, everything worked out OK. However, on other platforms calling gverrorf through this function pointer would result in stack corruption. This change aligns gverrorf with the type of the function pointer in which it is stored.

This potential stack corruption might very well explain the segfault on Alpine, that is based on musl-libc which is generally a more strict libc implementation. Looking at other commits as well, this seems like the most likely fix.

Related