Skip to content

Instantly share code, notes, and snippets.

@niedbalski
Created December 2, 2024 12:58
Show Gist options
  • Save niedbalski/36cd5b03061d78297f9298b6a6143563 to your computer and use it in GitHub Desktop.
Save niedbalski/36cd5b03061d78297f9298b6a6143563 to your computer and use it in GitHub Desktop.
heap-after-free.c
Test filter_parser_use_system_timezone... [2024/12/02 07:40:22] [ info] [fluent bit] version=3.2.3, commit=4acffc2ce8, pid=89607
[2024/12/02 07:40:22] [debug] [engine] coroutine stack size: 36864 bytes (36.0K)
[2024/12/02 07:40:22] [ info] [storage] ver=1.5.2, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2024/12/02 07:40:22] [ info] [simd ] disabled
[2024/12/02 07:40:22] [ info] [cmetrics] version=0.9.9
[2024/12/02 07:40:22] [ info] [ctraces ] version=0.5.7
[2024/12/02 07:40:22] [ info] [input:lib:lib.0] initializing
[2024/12/02 07:40:22] [ info] [input:lib:lib.0] storage_strategy='memory' (memory only)
[2024/12/02 07:40:22] [debug] [lib:lib.0] created event channels: read=25 write=26
[2024/12/02 07:40:22] [debug] [lib:lib.0] created event channels: read=29 write=30
[2024/12/02 07:40:22] [ info] [sp] stream processor started
[2024/12/02 07:40:23] [debug] [task] created task=0x60f000007840 id=0 OK
[2024/12/02 07:40:23] [debug] [test_filter_parser] received message: [1676394000.000000,{"message":"This is an example"}]
[2024/12/02 07:40:23] [debug] [out flush] cb_destroy coro_id=0
[2024/12/02 07:40:23] [debug] [task] destroy task=0x60f000007840 (task_id=0)
[2024/12/02 07:40:23] [ info] [fluent bit] version=3.2.3, commit=4acffc2ce8, pid=89607
[2024/12/02 07:40:23] [debug] [engine] coroutine stack size: 36864 bytes (36.0K)
[2024/12/02 07:40:23] [ info] [storage] ver=1.5.2, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2024/12/02 07:40:23] [ info] [simd ] disabled
[2024/12/02 07:40:23] [ info] [cmetrics] version=0.9.9
[2024/12/02 07:40:23] [ info] [ctraces ] version=0.5.7
[2024/12/02 07:40:23] [ info] [input:lib:lib.0] initializing
[2024/12/02 07:40:23] [ info] [input:lib:lib.0] storage_strategy='memory' (memory only)
[2024/12/02 07:40:23] [debug] [lib:lib.0] created event channels: read=29 write=30
[2024/12/02 07:40:23] [debug] [lib:lib.0] created event channels: read=33 write=34
[2024/12/02 07:40:23] [ info] [sp] stream processor started
[2024/12/02 07:40:24] [debug] [task] created task=0x60f000007930 id=0 OK
[2024/12/02 07:40:24] [debug] [test_filter_parser] received message: [1697533200.000000,{"message":"This is an example"}]
[2024/12/02 07:40:24] [debug] [out flush] cb_destroy coro_id=0
[2024/12/02 07:40:24] [debug] [task] destroy task=0x60f000007930 (task_id=0)
[2024/12/02 12:40:24] [ info] [fluent bit] version=3.2.3, commit=4acffc2ce8, pid=89607
[2024/12/02 12:40:24] [debug] [engine] coroutine stack size: 36864 bytes (36.0K)
[2024/12/02 12:40:24] [ info] [storage] ver=1.5.2, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2024/12/02 12:40:24] [ info] [simd ] disabled
[2024/12/02 12:40:24] [ info] [cmetrics] version=0.9.9
[2024/12/02 12:40:24] [ info] [ctraces ] version=0.5.7
[2024/12/02 12:40:24] [ info] [input:lib:lib.0] initializing
[2024/12/02 12:40:24] [ info] [input:lib:lib.0] storage_strategy='memory' (memory only)
[2024/12/02 12:40:24] [debug] [lib:lib.0] created event channels: read=33 write=34
[2024/12/02 12:40:24] [debug] [lib:lib.0] created event channels: read=37 write=38
[2024/12/02 12:40:24] [ info] [sp] stream processor started
[2024/12/02 12:40:25] [debug] [task] created task=0x60f000007a20 id=0 OK
[2024/12/02 12:40:25] [debug] [test_filter_parser] received message: [1705744800.000000,{"message":"This is an example"}]
[2024/12/02 12:40:25] [debug] [out flush] cb_destroy coro_id=0
[2024/12/02 12:40:25] [debug] [task] destroy task=0x60f000007a20 (task_id=0)
=================================================================
==89607==ERROR: AddressSanitizer: heap-use-after-free on address 0x602000000a93 at pc 0x0001076634d8 bp 0x00016b1ea4e0 sp 0x00016b1e9ca0
READ of size 1 at 0x602000000a93 thread T0
#0 0x1076634d4 in strlen+0x264 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x174d4)
#1 0x1894494d4 in __setenv_locked+0x80 (libsystem_c.dylib:arm64e+0x54d4)
#2 0x1894493b8 in setenv+0x94 (libsystem_c.dylib:arm64e+0x53b8)
#3 0x104c22278 in test_parser_timestamp_timezone filter_parser.c:596
#4 0x104c22550 in flb_test_filter_parser_use_system_timezone filter_parser.c:634
#5 0x104c26c50 in acutest_do_run_ acutest.h:1034
#6 0x104c1e934 in main acutest.h:1769
#7 0x189223150 (<unknown module>)
0x602000000a93 is located 3 bytes inside of 11-byte region [0x602000000a90,0x602000000a9b)
freed by thread T0 here:
#0 0x1076a0e88 in realloc+0x9c (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x54e88)
#1 0x1894494fc in __setenv_locked+0xa8 (libsystem_c.dylib:arm64e+0x54fc)
#2 0x1894493b8 in setenv+0x94 (libsystem_c.dylib:arm64e+0x53b8)
#3 0x104c220b4 in test_parser_timestamp_timezone filter_parser.c:570
#4 0x104c22550 in flb_test_filter_parser_use_system_timezone filter_parser.c:634
#5 0x104c26c50 in acutest_do_run_ acutest.h:1034
#6 0x104c1e934 in main acutest.h:1769
#7 0x189223150 (<unknown module>)
previously allocated by thread T0 here:
#0 0x1076a0c04 in malloc+0x94 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x54c04)
#1 0x189449644 in __setenv_locked+0x1f0 (libsystem_c.dylib:arm64e+0x5644)
#2 0x1894493b8 in setenv+0x94 (libsystem_c.dylib:arm64e+0x53b8)
#3 0x104c220b4 in test_parser_timestamp_timezone filter_parser.c:570
#4 0x104c22550 in flb_test_filter_parser_use_system_timezone filter_parser.c:634
#5 0x104c26c50 in acutest_do_run_ acutest.h:1034
#6 0x104c1e934 in main acutest.h:1769
#7 0x189223150 (<unknown module>)
SUMMARY: AddressSanitizer: heap-use-after-free (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x174d4) in strlen+0x264
Shadow bytes around the buggy address:
0x602000000800: fa fa fd fa fa fa fd fd fa fa fd fd fa fa fd fd
0x602000000880: fa fa fd fd fa fa fd fa fa fa fd fa fa fa fd fa
0x602000000900: fa fa fd fd fa fa fd fa fa fa fd fd fa fa fd fd
0x602000000980: fa fa fd fa fa fa fd fd fa fa fd fa fa fa fd fa
0x602000000a00: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fa
=>0x602000000a80: fa fa[fd]fd fa fa fd fd fa fa fd fa fa fa fd fa
0x602000000b00: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
0x602000000b80: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fd
0x602000000c00: fa fa fd fa fa fa fd fd fa fa fd fa fa fa fd fd
0x602000000c80: fa fa fd fa fa fa fd fd fa fa fd fa fa fa fd fa
0x602000000d00: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Test interrupted by signal 5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment