mirror of
https://github.com/lemonade-sdk/mac_linuxgpu.git
synced 2026-11-22 23:57:31 -10:00
kmemcheck painted canaries around every kmalloc and recorded it in a table under a global lock, and checked both on kfree: a cost on every allocation of the driver. It is a heap debugging aid, so it now compiles only with DEBUG defined. A release build keeps a small header (the payload's size for ksize, and the allocation to free) and goes straight to the allocator: no canaries, no tracking, no lock. kmemcheck_enabled() returns 0 and the checks find nothing. km_clear_sensitive (the wipe in kfree_sensitive) is unchanged. The define reaches only linuxu sources, never upstream objects: the dext's linuxu objects include a generated build/gen/mlg_build_mode.h that `make lib-dext DEBUG=1` fills in (rewritten only when the mode changes, so they rebuild), and Xcode's Debug configuration defines DEBUG=1 and passes it to that make. The host library the offline tests link is always a debug build, and the tests whose leak or corruption checks rely on kmemcheck build its sources with DEBUG=1. make check-release builds lib-dext in release and fails if it carries kmemcheck's symbols (scripts/check-release.sh, whose patterns are first checked against a debug build), then runs test_kmem_release in both modes: sizes, alignment, zeroing, ksize, kmemdup and caches behave the same, and only the debug build reports a write past an object.
12 lines
618 B
Bash
Executable File
12 lines
618 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
work=$(mktemp -d "${TMPDIR:-/tmp}/memory-containers.XXXXXX")
|
|
trap 'rm -rf "$work"' EXIT
|
|
clang -w -std=gnu11 -g -O1 -DDEBUG=1 -fsanitize=address,undefined -fno-sanitize-recover=all \
|
|
-ffunction-sections -fdata-sections -Ilinuxu/headers \
|
|
linuxu/tests/test_memory_containers.c linuxu/src/xarray.c linuxu/src/rcu.c linuxu/src/sync.c linuxu/src/llist.c \
|
|
linuxu/src/shims/interval_tree.c third_party/linux/lib/rbtree.c linuxu/src/kmem/{kmemalloc,kmemcheck}.c \
|
|
-Wl,-dead_strip -lpthread -o "$work/test_memory_containers"
|
|
"$work/test_memory_containers"
|