mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-12 16:57:26 +00:00
Enable address sanitizer
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
CODEC_URL = https://github.com/AOMediaCodec/libavif/archive/v0.8.0.tar.gz
|
CODEC_URL = https://github.com/AOMediaCodec/libavif/archive/v0.8.0.tar.gz
|
||||||
CODEC_DIR = node_modules/libavif
|
CODEC_DIR = node_modules/libavif
|
||||||
CODEC_BUILD_DIR := $(CODEC_DIR)/build
|
CODEC_BUILD_DIR := $(CODEC_DIR)/build
|
||||||
CODEC_OUT := $(CODEC_BUILD_DIR)/libavif.a
|
CODEC_OUT := $(CODEC_BUILD_DIR)/libavif.a
|
||||||
@@ -22,6 +22,10 @@ all: $(OUT_JS)
|
|||||||
${LDFLAGS} \
|
${LDFLAGS} \
|
||||||
--bind \
|
--bind \
|
||||||
--closure 1 \
|
--closure 1 \
|
||||||
|
-g2 \
|
||||||
|
-fsanitize=address \
|
||||||
|
-s ASAN_SHADOW_SIZE=1074790400 \
|
||||||
|
-s ASSERTIONS=1 \
|
||||||
-s ALLOW_MEMORY_GROWTH=1 \
|
-s ALLOW_MEMORY_GROWTH=1 \
|
||||||
-s MODULARIZE=1 \
|
-s MODULARIZE=1 \
|
||||||
-s 'EXPORT_NAME="$(basename $(@F))"' \
|
-s 'EXPORT_NAME="$(basename $(@F))"' \
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#include <sanitizer/lsan_interface.h>
|
||||||
|
|
||||||
#include <emscripten/bind.h>
|
#include <emscripten/bind.h>
|
||||||
#include <emscripten/val.h>
|
#include <emscripten/val.h>
|
||||||
#include "avif/avif.h"
|
#include "avif/avif.h"
|
||||||
@@ -47,4 +49,5 @@ val decode(std::string avifimage) {
|
|||||||
|
|
||||||
EMSCRIPTEN_BINDINGS(my_module) {
|
EMSCRIPTEN_BINDINGS(my_module) {
|
||||||
function("decode", &decode);
|
function("decode", &decode);
|
||||||
|
function("doLeakCheck", &__lsan_do_recoverable_leak_check);
|
||||||
}
|
}
|
||||||
|
|||||||
1
codecs/avif/dec/avif_dec.d.ts
vendored
1
codecs/avif/dec/avif_dec.d.ts
vendored
@@ -1,5 +1,6 @@
|
|||||||
interface AVIFModule extends EmscriptenWasm.Module {
|
interface AVIFModule extends EmscriptenWasm.Module {
|
||||||
decode(data: BufferSource): ImageData | null;
|
decode(data: BufferSource): ImageData | null;
|
||||||
|
doLeakCheck(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function(opts: EmscriptenWasm.ModuleOpts): AVIFModule;
|
export default function(opts: EmscriptenWasm.ModuleOpts): AVIFModule;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,3 +1,5 @@
|
|||||||
|
#include <sanitizer/lsan_interface.h>
|
||||||
|
|
||||||
#include <emscripten/bind.h>
|
#include <emscripten/bind.h>
|
||||||
#include <emscripten/val.h>
|
#include <emscripten/val.h>
|
||||||
#include "avif/avif.h"
|
#include "avif/avif.h"
|
||||||
@@ -81,4 +83,5 @@ EMSCRIPTEN_BINDINGS(my_module) {
|
|||||||
.field("subsample", &AvifOptions::subsample);
|
.field("subsample", &AvifOptions::subsample);
|
||||||
|
|
||||||
function("encode", &encode);
|
function("encode", &encode);
|
||||||
|
function("doLeakCheck", &__lsan_do_recoverable_leak_check);
|
||||||
}
|
}
|
||||||
|
|||||||
1
codecs/avif/enc/avif_enc.d.ts
vendored
1
codecs/avif/enc/avif_enc.d.ts
vendored
@@ -2,6 +2,7 @@ import { EncodeOptions } from '../../../src/codecs/avif/encoder-meta';
|
|||||||
|
|
||||||
interface AVIFModule extends EmscriptenWasm.Module {
|
interface AVIFModule extends EmscriptenWasm.Module {
|
||||||
encode(data: BufferSource, width: number, height: number, options: EncodeOptions): Uint8Array | null;
|
encode(data: BufferSource, width: number, height: number, options: EncodeOptions): Uint8Array | null;
|
||||||
|
doLeakCheck(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function(opts: EmscriptenWasm.ModuleOpts): AVIFModule;
|
export default function(opts: EmscriptenWasm.ModuleOpts): AVIFModule;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -12,5 +12,6 @@ export async function decode(data: ArrayBuffer): Promise<ImageData> {
|
|||||||
if (!result) {
|
if (!result) {
|
||||||
throw new Error('Decoding error');
|
throw new Error('Decoding error');
|
||||||
}
|
}
|
||||||
|
module.doLeakCheck();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export async function encode(data: ImageData, options: EncodeOptions): Promise<A
|
|||||||
if (!result) {
|
if (!result) {
|
||||||
throw new Error('Encoding error');
|
throw new Error('Encoding error');
|
||||||
}
|
}
|
||||||
|
module.doLeakCheck();
|
||||||
|
|
||||||
// wasm can’t run on SharedArrayBuffers, so we hard-cast to ArrayBuffer.
|
// wasm can’t run on SharedArrayBuffers, so we hard-cast to ArrayBuffer.
|
||||||
return result.buffer as ArrayBuffer;
|
return result.buffer as ArrayBuffer;
|
||||||
|
|||||||
Reference in New Issue
Block a user