Debug Baron
Debugging Red Baron's startup crash on FreeBSD
Red Baron 3.10 is already extracted, its original Linux libraries are installed,
and an X11 display is available. Running the browser still produces a
segmentation fault. This post follows that failure from a system-call trace
to a core dump, through libc5's allocator, and finally to a Linuxulator
brk compatibility bug.
The commands and output below come from a fresh investigation in the baron
jail on October 30, 2026. Output marked “selected” contains lines from a
longer result; whitespace is simplified in some listings. The disassembly
is actual tool output. Explanations appear outside those listings. Addresses,
process IDs, and core-file offsets describe this capture and can differ
on another system.
1. Prepare an unmodified run
The jail has a working VNC display at :1, using depth 24 and the required
X11 fonts. Installation and display setup are outside this investigation.
Except where marked host, commands run as root inside the jail, in
/bin/sh. The tools used include FreeBSD's tracing tools, readelf,
objdump, Clang and LLD, plus xwininfo for the final window check.
ssh baron
sh
uname -v
freebsd-version -u
sysctl compat.linux.osrelease
Output:
FreeBSD 15.1-RELEASE-p1 releng/15.1-n283582-0f691888dc56 GENERIC
15.1-RELEASE-p4
compat.linux.osrelease: 5.15.0
The kernel build is 15.1-RELEASE-p1; the jail's userland is p4. A jail
shares its host's kernel. The Linux release string is a compatibility
setting, not a separate Linux kernel running inside the jail.
We will need a core dump: a snapshot of the crashed process. On the FreeBSD host, check the global setting:
sysctl kern.coredump
It was already enabled for this capture:
kern.coredump: 1
If it is disabled on your host, record that previous value and run
sysctl kern.coredump=1 there before continuing. Restore the previous value
when finished. This setting belongs on the host, not inside the jail.
Inside the jail, prepare a separate working directory and environment:
WORK=$(mktemp -d /tmp/debug-baron.XXXXXX)
cd "$WORK"
printf 'WORK=%s\n' "$WORK"
BROWSER=/compat/linux/usr/lib/redbaron/redbaron_3.10
LIBC=/compat/linux/lib/libc.so.5.3.12
unset LD_PRELOAD
export DISPLAY=:1 XAUTHORITY=/root/.Xauthority
export HOME="$WORK/home" LANG=C LC_ALL=C
export REDBARON=/usr/lib/redbaron
export XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB
export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/X11R6/lib
mkdir "$HOME"
ulimit -c unlimited
The directory created for this run was:
WORK=/tmp/debug-baron.hvhWii
The private home directory separates this test's preferences from the
existing browser session. XAUTHORITY still points to the credentials for
the existing display; adjust that path for your setup.
Use the original executable directly. The installed /usr/local/bin/redbaron
wrapper sets LD_PRELOAD to an allocator workaround. Unsetting the variable
before invoking that wrapper would not disable the workaround, because the
wrapper sets it again.
2. Identify the executable and reproduce the crash
file "$BROWSER"
readelf -l "$BROWSER"
readelf -d "$BROWSER"
Selected output:
/compat/linux/usr/lib/redbaron/redbaron_3.10: ELF 32-bit LSB executable, Intel i386, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux.so.1, not stripped
[Requesting program interpreter: /lib/ld-linux.so.1]
0x00000001 (NEEDED) Shared library: [libXt.so.6]
0x00000001 (NEEDED) Shared library: [libX11.so.6]
0x00000001 (NEEDED) Shared library: [libm.so.5]
0x00000001 (NEEDED) Shared library: [libdl.so.1]
0x00000001 (NEEDED) Shared library: [libc.so.5]
This is a 32-bit Linux executable. Its ELF interpreter selects the old
Linux loader, /lib/ld-linux.so.1, which loads Linux libraries. FreeBSD's
native runtime linker does not load Red Baron's libraries. “Not stripped”
means function names remain available for later disassembly.
Capture the failure and exit status:
{
"$BROWSER"
printf 'exit status: %s\n' "$?"
} > first-run.txt 2>&1
cat first-run.txt
Output:
Segmentation fault (core dumped)
exit status: 139
The banner does not appear in this redirected failing run. Output buffering can leave text unwritten when a process crashes. The shell's message tells us a segmentation fault occurred and a core was produced; it does not identify the defective function.
The next step is to see what the process asked the kernel to do before it crashed.
3. Trace library loading and the last system calls
Ask the Linux loader to list its resolved dependencies:
env LD_TRACE_LOADED_OBJECTS=1 "$BROWSER"
Output:
libXt.so.6 => /usr/X11R6/lib/libXt.so.6
libX11.so.6 => /usr/X11R6/lib/libX11.so.6
libm.so.5 => /lib/libm.so.5
libdl.so.1 => /lib/libdl.so.1
libc.so.5 => /lib/libc.so.5
libSM.so.6 => /usr/X11R6/lib/libSM.so.6
libICE.so.6 => /usr/X11R6/lib/libICE.so.6
These are Linux-side paths. Linuxulator locates the installed compatibility
files beneath /compat/linux. The list has no unresolved dependency, but
it does not establish that the application can initialize successfully.
FreeBSD's ktrace records kernel interactions; kdump turns that binary
record into readable text:
ktrace -di -f "$WORK/redbaron.ktrace" "$BROWSER"
kdump -f "$WORK/redbaron.ktrace" > redbaron.kdump
tail -n 24 redbaron.kdump
Selected output:
2791 redbaron_3.10 CALL linux_mprotect(0x28399000,0x92472,0x5)
2791 redbaron_3.10 RET linux_mprotect 0
2791 redbaron_3.10 CALL linux_mprotect(0x28464000,0x6c45,0x5)
2791 redbaron_3.10 RET linux_mprotect 0
2791 redbaron_3.10 CALL linux_mprotect(0x2846d000,0x11337,0x5)
2791 redbaron_3.10 RET linux_mprotect 0
2791 redbaron_3.10 CALL linux_personality(0)
2791 redbaron_3.10 RET linux_personality 0
2791 redbaron_3.10 CALL linux_geteuid16
2791 redbaron_3.10 RET linux_geteuid16 0
2791 redbaron_3.10 CALL linux_getuid16
2791 redbaron_3.10 RET linux_getuid16 0
2791 redbaron_3.10 CALL linux_getgid16
2791 redbaron_3.10 RET linux_getgid16 0
2791 redbaron_3.10 CALL linux_getegid16
2791 redbaron_3.10 RET linux_getegid16 0
2791 redbaron_3.10 CALL linux_brk(0x82ee290)
2791 redbaron_3.10 RET linux_brk 137293824/0x82ef000
2791 redbaron_3.10 PSIG SIGSEGV SIG_DFL code=SEGV_MAPERR
2791 redbaron_3.10 NAMI "redbaron_3.10.core"
Library setup progressed to memory protection and application startup.
The last syscall before the signal is brk, which changes the logical end
of the traditional process heap. Its requested and returned addresses differ.
That is a clue, but being the last syscall does not prove it caused the crash.
The trace cannot show ordinary library calls such as malloc and strcpy.
To find the instruction that faulted, inspect the core from this second run.
4. Read the saved instruction pointer from the core
CORE="$WORK/redbaron_3.10.core"
readelf -h "$CORE"
readelf -n "$CORE" | sed -n '1,3p'
Selected output:
Class: ELF32
Data: 2's complement, little endian
Type: CORE (Core file)
Machine: Intel 80386
Displaying notes found at file offset 0x00000334 with length 0x00000d4c:
Owner Data size Description
CORE 0x00000090 NT_PRSTATUS (prstatus structure)
The NT_PRSTATUS note contains saved registers. Decode them using the
Linux/i386 layout written by Linuxulator. The relevant source definitions
are linux_elf_prstatus
and linux_pt_regset32,
pinned to the running kernel's source revision.
Start with the note header:
od -An -tx1 -j $((0x334)) -N 20 "$CORE"
Output:
05 00 00 00 90 00 00 00 01 00 00 00 43 4f 52 45
00 00 00 00
The first three little-endian words are the owner-name length (5),
descriptor length (0x90), and note type (1). The 12-byte header is
followed by CORE, its terminating zero, and padding to a four-byte boundary.
The descriptor therefore starts at 0x334 + 12 + 8 = 0x348.
In this 32-bit structure, signal fields, masks, process IDs, and four 8-byte timevals occupy 72 bytes before the registers. The register order is:
ebx ecx edx esi edi ebp eax ds es fs gs orig_eax eip cs eflags esp ss
EIP, the instruction pointer, is register 12, counting from zero. Its core
offset is 0x348 + 72 + 12*4 = 0x3c0:
od -An -tx4 -j $((0x3c0)) -N 4 "$CORE"
Output:
2840643f
The faulting instruction was at 0x2840643f. The -tx4 interpretation
works here because the amd64 machine reading the core is also little-endian.
Next, identify the mapping containing that address.
5. Match the faulting mapping to libc5
readelf -l "$CORE"
readelf -l "$LIBC"
Selected core header:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x3da000 0x28399000 0x00000000 0x93000 0x93000 R E 0x1000
Selected libc5 header:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x00000000 0x00000000 0x92472 0x92472 R E 0x1000
The instruction address lies inside the mapping beginning at 0x28399000.
A core LOAD row does not name its library, so verify the identity by
comparing the mapped bytes with libc5's executable segment:
dd if="$CORE" bs=1 skip=$((0x3da000)) count=$((0x92472)) 2>/dev/null | sha256
dd if="$LIBC" bs=1 count=$((0x92472)) 2>/dev/null | sha256
Output:
91e0f48bab58aa124b6f5a471fc66b47d0fcd53296878f53d3b3b082e8c9e487
91e0f48bab58aa124b6f5a471fc66b47d0fcd53296878f53d3b3b082e8c9e487
The bytes match. Because libc5's segment has ELF virtual address zero, its
load bias—the amount added to its ELF addresses—is 0x28399000.
Subtract that from the saved instruction pointer:
printf 'fault offset: 0x%x\n' $((0x2840643f-0x28399000))
readelf -s "$LIBC" | grep ' strcpy$'
Output:
fault offset: 0x6d43f
104: 0006d42c 30 FUNC GLOBAL DEFAULT 10 strcpy
300: 0006d42c 30 FUNC GLOBAL DEFAULT 10 strcpy
The offset falls inside strcpy, which begins at 0x6d42c.
The two rows come from the dynamic and full symbol tables.
objdump -d --start-address=0x6d42c --stop-address=0x6d44a "$LIBC"
Selected output:
0006d42c <strcpy>:
6d42c: 56 pushl %esi
6d42d: 8b 74 24 08 movl 0x8(%esp), %esi
6d431: 8b 54 24 0c movl 0xc(%esp), %edx
6d435: 89 f0 movl %esi, %eax
6d437: 29 d0 subl %edx, %eax
6d439: 8d 48 ff leal -0x1(%eax), %ecx
6d43c: 8a 02 movb (%edx), %al
6d43e: 42 incl %edx
6d43f: 88 04 11 movb %al, (%ecx,%edx)
The instruction at 0x6d43f stores one byte at the address formed by
ECX + EDX. We need the saved registers and arguments to determine where
that store was going.
6. Recover the null destination and the text being copied
Read ECX, EDX, and ESI, followed by the stack pointer, ESP, from the same register note:
od -An -tx4 -j $((0x348+0x48+4)) -N 12 "$CORE"
od -An -tx4 -j $((0x348+0x48+15*4)) -N 4 "$CORE"
printf 'store address: 0x%08x\n' $(((0xf7d94222+0x0826bdde)&0xffffffff))
Output:
f7d94222 0826bdde 00000000
ffffb02c
store address: 0x00000000
The store's address is zero after 32-bit arithmetic wraps. ESI, which the function loaded with the original destination argument, is also zero.
To confirm the arguments on the stack, locate the stack mapping in
readelf -l "$CORE":
LOAD 0x4c1000 0xfffdc000 0x00000000 0x20000 0x20000 RWE 0x1000
Convert a process address to an offset in the core using:
core offset = LOAD file offset + (process address - LOAD virtual address)
Read four words at ESP:
od -An -tx4 -j $((0x4c1000+0xffffb02c-0xfffdc000)) -N 16 "$CORE"
Output:
282affb0 0807037e 00000000 0826bddd
On i386, arguments are passed on the stack. At this instruction strcpy
has also pushed ESI, so those four words are:
| Stack position | Meaning | Value |
|---|---|---|
| ESP | Saved caller ESI | 0x282affb0 |
| ESP+4 | Return address | 0x0807037e |
| ESP+8 | Destination | 0x00000000 |
| ESP+12 | Source | 0x0826bddd |
The source belongs to this executable mapping:
LOAD 0x002000 0x08000000 0x00000000 0x2ae000 0x2ae000 RWE 0x1000
Read the source string, including its terminating zero:
od -An -tc -j $((0x2000+0x0826bddd-0x08000000)) -N 9 "$CORE"
Output:
S p y g l a s s \0
The crash is equivalent to:
strcpy(NULL, "Spyglass");
That means “copy the text Spyglass into memory at address zero.” Address
zero is not writable process memory, so the copy faults. This conclusion
comes from the core and disassembly; the syscall trace alone cannot show it.
The next question is where the null destination came from.
7. Connect the destination to libc5's malloc
The stack's return address, 0x0807037e, points back into Red Baron.
Find the enclosing function, then disassemble the beginning of main:
readelf -s "$BROWSER" | grep ' main$'
objdump -d --start-address=0x8070310 --stop-address=0x8070381 "$BROWSER"
Selected output:
9836: 08070310 890 FUNC GLOBAL DEFAULT 10 main
8070360: e8 1b 12 0d 00 calll 0x8141580 <gcc2_compiled.>
8070365: 83 c4 04 addl $0x4, %esp
8070368: a3 6c a2 2e 08 movl %eax, 0x82ea26c
807036d: a1 74 a2 2e 08 movl 0x82ea274, %eax
8070372: 50 pushl %eax
8070373: a1 6c a2 2e 08 movl 0x82ea26c, %eax
8070378: 50 pushl %eax
8070379: e8 4a 5e f9 ff calll 0x80061c8 <strcpy@plt>
807037e: 83 c4 08 addl $0x8, %esp
An i386 function returns a pointer in EAX. The call's result is saved at
0x82ea26c, then pushed as strcpy's destination. There is no intervening
test for NULL. The instruction after the copy call is 0x807037e, matching
the return address recovered from the core.
The call target has another symbol at the same address:
readelf -s "$BROWSER" | grep ' SM_Malloc$'
objdump -d --start-address=0x8141580 --stop-address=0x81415a4 "$BROWSER"
Selected output:
6898: 08141580 36 FUNC GLOBAL DEFAULT 10 SM_Malloc
08141580 <SM_Malloc>:
8141580: 55 pushl %ebp
8141581: 89 e5 movl %esp, %ebp
8141583: 8b 45 08 movl 0x8(%ebp), %eax
8141586: 50 pushl %eax
8141587: e8 9c 52 ec ff calll 0x8006828 <malloc@plt>
814158c: 83 c4 04 addl $0x4, %esp
814158f: 89 c2 movl %eax, %edx
8141591: 89 d0 movl %edx, %eax
SM_Malloc delegates to the imported malloc and passes the result back.
The @plt label identifies a runtime-linked call through the Procedure
Linkage Table.
We can also verify which allocator the loader selected. Find the relocation
slot for malloc, and its offset within libc5:
readelf -r "$BROWSER" | grep ' malloc$'
readelf -s "$LIBC" | grep ' malloc$'
Output:
082d2aac 00008507 R_386_JUMP_SLOT 08006828 malloc
112: 00038efc 0 FUNC WEAK DEFAULT 10 malloc
726: 00038efc 0 FUNC WEAK DEFAULT 10 malloc
The slot at process address 0x082d2aac lies in this core mapping:
LOAD 0x2b0000 0x082ae000 0x00000000 0x25000 0x25000 RW 0x1000
Read its resolved address, then compare it with libc5's symbol offset plus the library's load bias:
od -An -tx4 -j $((0x2b0000+0x082d2aac-0x082ae000)) -N 4 "$CORE"
printf 'libc5 malloc address: 0x%x\n' $((0x28399000+0x38efc))
Output:
283d1efc
libc5 malloc address: 0x283d1efc
The call really resolved to libc5's allocator. We have connected the null
destination to that allocator's result. We still need to explain why it
failed, which brings us back to the suspicious brk result.
8. Find the connection between malloc and brk
malloc manages memory in user space. When its existing heap is insufficient,
this allocator uses helpers to request more memory. sbrk is a library
function that changes the heap size using the kernel's brk syscall. That
known relationship gives us a specific place to investigate; a syscall trace
cannot directly name the library function that issued a call.
Look for those functions and their linking information in the installed libc:
readelf -s "$LIBC" | grep -E ' (malloc|sbrk|__sbrk|__morecore|__default_morecore|__default_morecore_init)$'
readelf -r "$LIBC" | grep -E '__sbrk|__morecore|__default_morecore'
Selected output:
112: 00038efc 0 FUNC WEAK DEFAULT 10 malloc
226: 000182d4 0 FUNC WEAK DEFAULT 10 sbrk
227: 000182d4 120 FUNC GLOBAL DEFAULT 10 __sbrk
1015: 000962ac 4 OBJECT GLOBAL DEFAULT 13 __morecore
1017: 0003abd0 75 FUNC GLOBAL DEFAULT 10 __default_morecore_init
1053: 0003abac 35 FUNC GLOBAL DEFAULT 10 __default_morecore
000962ac 0003f901 R_386_32 0003abd0 __default_morecore_init
00098694 0003f706 R_386_GLOB_DAT 000962ac __morecore
000986a0 00041d06 R_386_GLOB_DAT 0003abac __default_morecore
0009869c 0003f906 R_386_GLOB_DAT 0003abd0 __default_morecore_init
000984cc 0000e307 R_386_JUMP_SLOT 000182d4 __sbrk
sbrk and __sbrk name the same code at 0x182d4. Disassemble that range:
objdump -d --start-address=0x182d4 --stop-address=0x1834c "$LIBC"
Selected output:
182f9: 8b 08 movl (%eax), %ecx
182fb: 01 f1 addl %esi, %ecx
182fd: b8 2d 00 00 00 movl $0x2d, %eax
18302: 53 pushl %ebx
18303: 89 cb movl %ecx, %ebx
18305: cd 80 int $0x80
18307: 5b popl %ebx
18308: 8b 93 fc 0b 00 00 movl 0xbfc(%ebx), %edx
1830e: 89 02 movl %eax, (%edx)
18310: 8b 83 fc 0b 00 00 movl 0xbfc(%ebx), %eax
18316: 8b 38 movl (%eax), %edi
18318: 39 cf cmpl %ecx, %edi
1831a: 75 0c jne 0x18328 <sbrk+0x54>
On Linux/i386, EAX supplies the syscall number, EBX supplies its first
argument, and int $0x80 enters the kernel. 0x2d is decimal 45: brk.
ECX holds the requested address. The returned EAX is saved and loaded into
EDI, then compared with ECX. A mismatch branches to this error path:
18328: e8 bb e0 ff ff calll 0x163e8 <.plt+0x2860>
1832d: c7 00 0c 00 00 00 movl $0xc, (%eax)
18333: b8 ff ff ff ff movl $0xffffffff, %eax # imm = 0xFFFFFFFF
It sets errno to 12 (ENOMEM) and returns (void *)-1. Our traced
0x082ee290 request and 0x082ef000 return necessarily fail that comparison.
Here ENOMEM reports libc5 rejecting the result; it does not show that the
machine actually ran out of RAM.
The “morecore” helpers translate that failure for the allocator:
objdump -d --start-address=0x3abac --stop-address=0x3ac1b "$LIBC"
Selected output from __default_morecore:
3abbe: e8 75 bc fd ff calll 0x16838 <.plt+0x2cb0>
3abc3: 83 c4 04 addl $0x4, %esp
3abc6: 83 f8 ff cmpl $-0x1, %eax
3abc9: 75 02 jne 0x3abcd <__default_morecore+0x21>
3abcb: 31 c0 xorl %eax, %eax
The call is through the __sbrk linkage slot. If it returns -1, the helper
zeros EAX, returning NULL. __default_morecore_init has the same conversion
at 0x3ac11 through 0x3ac16.
To verify the linkage rather than relying on objdump's generic .plt label:
readelf -d "$LIBC" | grep PLTGOT
objdump -d --start-address=0x16838 --stop-address=0x16848 "$LIBC"
printf 'PLT slot offset: 0x%x\n' $((0x984cc-0x97998))
Selected output:
0x00000003 (PLTGOT) 0x97998
16838: ff a3 34 0b 00 00 jmpl *0xb34(%ebx)
PLT slot offset: 0xb34
That offset selects the 0x984cc relocation previously identified as
__sbrk.
We now have an explanation for the failed heap growth. To decide whether libc5 or Linuxulator is incompatible with Linux, test the syscall directly.
9. Reproduce the return-value mismatch without libc
The raw Linux brk syscall returns the exact new logical break on success,
and the unchanged current break on failure. The C library's brk() wrapper,
which normally returns zero or minus one, is a different interface. Linux's
brk(2) manual, “C library/kernel differences”
describes that distinction.
The logical break can lie between page boundaries even though memory mappings use whole pages. Returning the mapped page boundary loses the byte-precise address the caller requested.
Save this complete program as brk-probe.S in the working directory:
.section .data
.balign 4
results:
.long 0, 0, 0
.section .text
.globl _start
_start:
movl $45, %eax
xorl %ebx, %ebx
int $0x80
movl %eax, results
leal 1(%eax), %ebx
movl %ebx, results+4
movl $45, %eax
int $0x80
movl %eax, results+8
movl $4, %eax
movl $1, %ebx
movl $results, %ecx
movl $12, %edx
int $0x80
movl results+4, %eax
cmpl results+8, %eax
movl $0, %ebx
setne %bl
movl $1, %eax
int $0x80
.section .note.GNU-stack,"",@progbits
It queries the current break with brk(0), requests one byte more, and
writes three 32-bit words: initial, requested, and returned addresses.
Its exit status is 1 if the request and result differ, otherwise 0.
Build it with FreeBSD's Clang and linker:
cc -target i386-unknown-linux-gnu -c brk-probe.S -o brk-probe.o
ld -m elf_i386 -static -e _start -o brk-probe brk-probe.o
brandelf -t Linux brk-probe
file brk-probe
The build commands succeeded without output. file reported:
brk-probe: ELF 32-bit LSB executable, Intel i386, version 1 (GNU/Linux), statically linked, not stripped
There is no libc or runtime loader involved. Run it, keeping its exit status before displaying the binary output:
if ./brk-probe > brk-probe.out; then status=0; else status=$?; fi
od -An -tx4 brk-probe.out
printf 'exit status: %s\n' "$status"
Output:
00403000 00403001 00404000
exit status: 1
The requested 0x00403001 became 0x00404000. An ordinary refusal would
have returned the previous break, 0x00403000, not this larger rounded value.
Confirm the syscall boundary with FreeBSD's truss:
truss -o brk-probe.truss ./brk-probe > brk-probe-traced.out
grep linux_brk brk-probe.truss
Output:
linux_brk(0x0) = 4206592 (0x403000)
linux_brk(0x403001) = 4210688 (0x404000)
This reproduces the incompatibility without Red Baron, its allocator, shared libraries, or X11. It places the problem at the emulated syscall interface. We can now inspect the matching kernel source to explain the rounding.
10. Locate the rounding in Linuxulator and kern_break
Use source matching the running kernel revision, rather than assuming the
machine's current /usr/src matches its booted kernel. From the working
directory, retrieve the two relevant files:
fetch -q -o linux_misc.c \
https://raw.githubusercontent.com/freebsd/freebsd-src/0f691888dc56/sys/compat/linux/linux_misc.c
fetch -q -o vm_unix.c \
https://raw.githubusercontent.com/freebsd/freebsd-src/0f691888dc56/sys/vm/vm_unix.c
sed -n '218,232p' linux_misc.c
The downloads succeeded without output. The source listing is:
int
linux_brk(struct thread *td, struct linux_brk_args *args)
{
struct vmspace *vm = td->td_proc->p_vmspace;
uintptr_t new, old;
old = (uintptr_t)vm->vm_daddr + ctob(vm->vm_dsize);
new = (uintptr_t)args->dsend;
if ((caddr_t)new > vm->vm_daddr && !kern_break(td, &new))
td->td_retval[0] = (register_t)new;
else
td->td_retval[0] = (register_t)old;
return (0);
}
new starts as the Linux caller's requested address. The handler passes
its address, &new, to kern_break, then returns the possibly modified
value through td_retval[0].
Find where kern_break changes it:
grep -n -E 'round_page\(\*addr\)|\*addr = new' vm_unix.c
Output:
98: new = round_page(*addr);
232: *addr = new;
kern_break
performs the native VM work: checking limits, mapping or unmapping pages,
and updating accounting. It rounds the requested address and, on success,
writes that rounded value back through its pointer argument.
linux_brk
then exposes it as the Linux syscall result. This accounts for both the
browser's trace and the independent probe.
Removing kern_break would omit the actual memory-management work. A proper
repair must preserve that work while tracking and returning the exact Linux
logical break. Query and failure results must preserve that precision too.
The handler's final C return (0) is a FreeBSD syscall-handler status;
the Linux program receives the address in td_retval[0], not that zero.
11. Bypass the failing allocator and test startup again
A user-space workaround can avoid libc5's heap-growth path. The existing
malloc_shim.c implements malloc,
calloc, realloc, free, and strdup with Linux/i386 mmap and munmap
syscalls. It is freestanding and needs no libc of its own.
Replacing the family together keeps allocation ownership consistent: a
pointer allocated by the shim must also be resized and freed by compatible
functions. It does not mean every function in that family independently
calls brk.
For this capture, the source was already in /root/redbaron-install:
cp /root/redbaron-install/malloc_shim.c "$WORK/malloc_shim.c"
cc -target i386-unknown-linux-gnu -m32 -O2 -fPIC -ffreestanding \
-fno-builtin -fno-stack-protector -c malloc_shim.c -o malloc_shim.o
ld -m elf_i386 -shared --hash-style=sysv -soname libredbaron_compat.so \
-o libredbaron_compat.so malloc_shim.o
brandelf -t Linux libredbaron_compat.so
readelf -d libredbaron_compat.so
readelf --dyn-syms libredbaron_compat.so
On another installation, copy the linked source into the working directory first. The build commands succeeded without output. The resulting dynamic section and exported symbols were:
Dynamic section at offset 0x768 contains 7 entries:
Tag Type Name/Value
0x0000000e (SONAME) Library soname: [libredbaron_compat.so]
0x00000006 (SYMTAB) 0x134
0x0000000b (SYMENT) 16 (bytes)
0x00000005 (STRTAB) 0x1cc
0x0000000a (STRSZ) 57 (bytes)
0x00000004 (HASH) 0x194
0x00000000 (NULL) 0x0
Symbol table '.dynsym' contains 6 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00001220 126 FUNC GLOBAL DEFAULT 5 malloc
2: 000012a0 42 FUNC GLOBAL DEFAULT 5 free
3: 000012d0 147 FUNC GLOBAL DEFAULT 5 calloc
4: 00001370 572 FUNC GLOBAL DEFAULT 5 realloc
5: 000015b0 438 FUNC GLOBAL DEFAULT 5 strdup
There are no NEEDED entries for other libraries. The old Linux loader
also needs the traditional SysV hash table produced by --hash-style=sysv.
Start a test browser with this library preloaded and trace it:
ktrace -di -f "$WORK/shim.ktrace" env \
LD_PRELOAD="$WORK/libredbaron_compat.so" \
"$BROWSER" -url file:/usr/lib/redbaron/help/index.htm > shim-run.txt 2>&1 &
browser_pid=$!
sleep 2
ps -p "$browser_pid" -o pid= -o comm=
cat shim-run.txt
The other exported variables remain as established in step 1. LD_PRELOAD
is assigned by env for the browser, rather than exported into the shell
where native diagnostic programs would also inherit it.
Output:
3046 redbaron_3.10
RedHat Redbaron: Linux i486 (Linux 2.0) Version 3.10
Check the X window as well as the process:
xwininfo -root -tree | grep -E 'Help Index|redbaron'
Selected output:
0xc0011e "Help Index": ("mosaicShell" "redbaron") 700x600+0+24 +1+25
Inspect that window, using the ID from your own output:
xwininfo -id 0xc0011e | grep -E 'Window id|Width:|Height:|Depth:|Map State:'
Output:
xwininfo: Window id: 0xc0011e "Help Index"
Width: 700
Height: 600
Depth: 24
Map State: IsViewable
The test process has reached a mapped Help Index window. Its memory map also contains both the new shim and the original libc5:
procstat -v "$browser_pid" | grep -E 'libredbaron_compat|libc.so.5.3.12'
Selected output:
3046 0x282b7000 0x282b8000 r-x 1 1 4 2 CN--- vn /tmp/debug-baron.hvhWii/libredbaron_compat.so
3046 0x2839d000 0x28430000 r-x 147 173 4 2 CN--- vn /compat/linux/lib/libc.so.5.3.12
Finally, inspect the trace while this test browser is still running:
kdump -f "$WORK/shim.ktrace" > shim.kdump
grep -E 'linux_brk|linux_mmap|linux_munmap' shim.kdump | tail -n 12
if grep -q linux_brk shim.kdump; then
printf 'brk calls found\n'
else
printf 'no linux_brk calls in shim trace\n'
fi
Selected output:
3046 redbaron_3.10 CALL linux_mmap(0xffffad50)
3046 redbaron_3.10 RET linux_mmap 685125632/0x28d63000
3046 redbaron_3.10 CALL linux_mmap(0xffffad0c)
3046 redbaron_3.10 RET linux_mmap 702652416/0x29e1a000
3046 redbaron_3.10 CALL linux_mmap(0xffffacf8)
3046 redbaron_3.10 RET linux_mmap 702660608/0x29e1c000
no linux_brk calls in shim trace
The shim bypasses the problematic path; it does not repair or intercept the
kernel's brk implementation. It still uses Linuxulator to perform its
mmap and munmap calls.
Stop only the test process when finished:
kill -TERM "$browser_pid"
That command completed without output. The existing browser and VNC session were left running. Restore the host's previous core-dump setting if you changed it in step 1.
12. What the investigation established
The evidence connects the failure across three boundaries:
Linuxulator brk returns a rounded address
-> libc5's sbrk rejects the mismatch and reports failure
-> heap growth fails and malloc returns NULL
-> Red Baron passes NULL to strcpy without checking
-> strcpy writes to address zero and the process crashes
Two defects contribute: Linuxulator returns an incompatible logical break, and Red Baron does not handle allocation failure. The core establishes the null allocation result and the invalid copy. Disassembly establishes libc5's address comparison and error conversion. The syscall-only probe independently demonstrates the ABI defect. This investigation did not single-step every instruction in the original allocation.
The allocator shim is one workaround. A separate patched-kernel test, recorded on October 28, started Red Baron with its original allocator and no shim; that work is described in the kernel-repair investigation and the presentation's second repair option. A full kernel correction also needs to handle an initial break inside the last data/BSS page, exact queries and failure returns, fork, and exec. Simply changing one successful return expression is insufficient. No kernel was rebuilt, installed, or booted for the fresh capture in this post.
The fresh shim test establishes startup to a mapped Help Index window and
absence of brk calls in its startup trace. It does not establish sustained
browsing stability or compatibility with modern websites.
For matching this capture, the input checksums were:
sha256 "$BROWSER" "$LIBC" "$CORE"
SHA256 (/compat/linux/usr/lib/redbaron/redbaron_3.10) = 7d37ac54146bc9c23fb5f2eb1d0521d0d3e02737a97fccb0fc243252737d1d84
SHA256 (/compat/linux/lib/libc.so.5.3.12) = 2a2341f5d1e6c31f340efb42557babdb1229dcb978ef2ccf4088004e84bab555
SHA256 (/tmp/debug-baron.hvhWii/redbaron_3.10.core) = 88ed0956eb2a1f331cd11463c829717d5000980c3ef7974e2e74e7fe10b37324
The fresh core and full traces were retained in baron:/tmp/debug-baron.hvhWii.
That is a temporary working directory; copy it to durable storage if needed.
The older core at /root/redbaron_3.10.core was not overwritten.