calling overlayWith on a jpeg with an svg segfaulting (docker alpine image)
See original GitHub issueI’m having issues with a particular operation in my operation pipeline, namely overlayWith. My sequence of operations looks something like this:
const frame = new Buffer(`<svg ....`)
image.resize(imageWidth, imageHeight)
.crop('north')
.background({r: 255, g: 255, b: 255, alpha: 255})
.extend(stretchDimensions)
.overlayWith(frame)
.jpeg().toBuffer().then(console.log)
On my computer it all works (Mac OS X). My issue is using one of the many variations of the sharp alpine distro (I’m following this one). As I need to do a bit more, I’ve copied and modified the entries in the Dockerfile to suit my needs, and the end result looks like this:
FROM node:8.2-alpine
...
ENV VIPS_VERSION 8.5.7
ENV SHARP_VERSION 0.18.2
ENV GYP_VERSION 3.6.2
# Compile Vips and Sharp
RUN apk --no-cache add libpng librsvg libgsf libjpeg-turbo musl \
&& apk --no-cache add --virtual .build-dependencies \
g++ libc-dev make python curl tar gtk-doc glib-dev \
libpng-dev libjpeg-turbo-dev librsvg-dev \
gobject-introspection expat-dev giflib-dev \
&& mkdir -p /usr/src \
&& curl -o vips.tar.gz -SL https://github.com/jcupitt/libvips/releases/download/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.gz \
&& tar -xzf vips.tar.gz -C /usr/src/ \
&& rm vips.tar.gz \
&& chown -R nobody.nobody /usr/src/vips-${VIPS_VERSION} \
&& cd /usr/src/vips-${VIPS_VERSION} \
&& ./configure \
&& make \
&& make install \
&& cd / \
&& rm -r /usr/src/vips-${VIPS_VERSION} \
&& yarn add global node-gyp@${GYP_VERSION} sharp@${SHARP_VERSION} \
&& apk del .build-dependencies
...
After the lengthy process of building the image and running my program, it segfaults. I’ve isolated it to the overlayWith call (if I comment it, it works).
I’m aware that this might be an issue with libvips / alpine / smth else, so I’d appreciate at the very least some help in redirecting me to the proper person who can help me (maybe those maintainers are also maintaining sharp?).
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (6 by maintainers)

Top Related StackOverflow Question
@lovell as I went away from the alpine distro for everything involving vips, this is not as important to me anymore. However, I still have my test script to reproduce the segfault. I’ll see if I can allocate some time at the end of the week to test those changes and come back at you with feedback.
Closing due to inactivity but please feel free to re-open with a backtrace.