Skip to content

Commit 6cd2eb1

Browse files
committed
CI: Add address (ASAN) and leak (LSAN) checks
1 parent dd2d883 commit 6cd2eb1

5 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,28 @@ jobs:
342342
path: npm/wasm32
343343
retention-days: 1
344344
if-no-files-found: error
345+
build-asan:
346+
permissions:
347+
contents: read
348+
needs: lint
349+
runs-on: ubuntu-26.04
350+
steps:
351+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
352+
with:
353+
persist-credentials: false
354+
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
355+
with:
356+
node-version: "26"
357+
- run: npm install --ignore-scripts
358+
- run: npm run build:dist
359+
- run: npm run build
360+
env:
361+
CFLAGS: "-fsanitize=address"
362+
LDFLAGS: "-fsanitize=address"
363+
- run: npm run test-unit
364+
env:
365+
LSAN_OPTIONS: "detect_leaks=1:suppressions=test/leak/asan.supp"
366+
LD_PRELOAD: "/usr/lib/x86_64-linux-gnu/libasan.so.8"
345367
release:
346368
permissions:
347369
contents: write
@@ -352,6 +374,7 @@ jobs:
352374
- build-linuxmusl-arm64
353375
- build-qemu
354376
- build-emscripten
377+
- build-asan
355378
steps:
356379
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
357380
with:

‎test/fixtures/index.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ module.exports = {
153153

154154
isLittleEndian: endianness() === 'LE',
155155

156+
isLsan: process.env.LSAN_OPTIONS?.includes('detect_leaks=1'),
157+
156158
// Path for tests requiring human inspection
157159
path: getPath,
158160

‎test/leak/asan.supp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
leak:OPENSSL_init_crypto

‎test/unit/svg.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ suite('SVG input', () => {
8686
});
8787

8888
test('Convert SVG with embedded images to PNG, respecting dimensions, autoconvert to PNG', async (t) => {
89+
if (fixtures.isLsan) return t.skip('LSAN');
8990
t.plan(4);
9091
const { data, info } = await sharp(fixtures.inputSvgWithEmbeddedImages)
9192
.toBuffer({ resolveWithObject: true });

‎test/unit/text.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const { inRange } = require('../../dist/is.cjs');
1111

1212
suite('Text to image', () => {
1313
test('text with default values', async (t) => {
14+
if (fixtures.isLsan) return t.skip('LSAN');
1415
const output = fixtures.path('output.text-default.png');
1516
const text = sharp({
1617
text: {
@@ -44,6 +45,7 @@ suite('Text to image', () => {
4445
});
4546

4647
test('text with width and height', async (t) => {
48+
if (fixtures.isLsan) return t.skip('LSAN');
4749
const output = fixtures.path('output.text-width-height.png');
4850
const text = sharp({
4951
text: {
@@ -67,6 +69,7 @@ suite('Text to image', () => {
6769
});
6870

6971
test('text with dpi', async (t) => {
72+
if (fixtures.isLsan) return t.skip('LSAN');
7073
const output = fixtures.path('output.text-dpi.png');
7174
const dpi = 300;
7275
const text = sharp({
@@ -88,6 +91,7 @@ suite('Text to image', () => {
8891
});
8992

9093
test('text with color and pango markup', async (t) => {
94+
if (fixtures.isLsan) return t.skip('LSAN');
9195
const output = fixtures.path('output.text-color-pango.png');
9296
const dpi = 300;
9397
const text = sharp({
@@ -113,6 +117,7 @@ suite('Text to image', () => {
113117
});
114118

115119
test('text with font', async (t) => {
120+
if (fixtures.isLsan) return t.skip('LSAN');
116121
const output = fixtures.path('output.text-with-font.png');
117122
const text = sharp({
118123
text: {
@@ -133,6 +138,7 @@ suite('Text to image', () => {
133138
});
134139

135140
test('text with justify and composite', async (t) => {
141+
if (fixtures.isLsan) return t.skip('LSAN');
136142
const output = fixtures.path('output.text-composite.png');
137143
const width = 500;
138144
const dpi = 300;

0 commit comments

Comments
 (0)