luzer: print metrics only once - #93
Open
ligurio wants to merge 4 commits into
Open
Conversation
ligurio
force-pushed
the
ligurio/gh-89-print-metrics-once
branch
from
June 30, 2026 11:02
1b26476 to
2811473
Compare
ligurio
force-pushed
the
ligurio/gh-89-print-metrics-once
branch
from
July 3, 2026 12:42
2811473 to
d8d77c1
Compare
Проблема: На NixOS clang wrapper через hardening flags добавляет -D_FORTIFY_SOURCE=2 после пользовательских флагов, а -O2 — до. Когда CMake переопределяет -O2 на -O0 (для ASan/UBSan тестовых целей), -D_FORTIFY_SOURCE=2 остаётся, и glibc 2.40+ выдаёт ошибку: _FORTIFY_SOURCE requires compiling with optimization (-O). Исправление (в двух файлах): 1. luzer/CMakeLists.txt:46-52 — Добавлен -U_FORTIFY_SOURCE в общие флаги компиляции (belt-and-suspenders). 2. luzer/tests/CMakeLists.txt:218-219, 350-351 — Заменены -O0 на -O1 для ASan/UBSan тестовых целей (luac_asan, luac_ubsan, testlib_asan, testlib_ubsan). -O1 — минимальный рекомендуемый уровень оптимизации для санитайзеров. (cherry picked from commit 563e0a64f0e985562d48687652781a275382cba8)
ligurio
force-pushed
the
ligurio/gh-89-print-metrics-once
branch
from
July 9, 2026 18:11
d8d77c1 to
99695e5
Compare
Buristan
requested changes
Jul 13, 2026
Buristan
left a comment
Collaborator
There was a problem hiding this comment.
Hi, Sergey!
Thanks for the patch set!
Please consider my comments below.
For now tests are failing.
[PATCH 1/2] luzer: print metrics only once
Please consider my comments below.
It would be nice to add the test for fork mode.
[PATCH 2/2] cmake: FORTIFY_SOURCE
This patch looks like it is not ready for review. Commit message is in Russian.
Why -O0 is replaced with -O1?
| check_parent_or_child(void) | ||
| { | ||
| static pid_t saved_pid = -1; | ||
| static bool first_call = true; |
Collaborator
There was a problem hiding this comment.
It looks like this flag is redundant. Let's just use static saved_pid which is defined on library's initialization. Then we don't need this first_call plie.
ligurio
force-pushed
the
ligurio/gh-89-print-metrics-once
branch
from
July 16, 2026 16:40
99695e5 to
18f89c5
Compare
This reverts commit f80a574.
The function metrics_print() is called twice when `-fork`/`-jobs` are used. The reason is that `metrics_print()` is called from `__attribute__((destructor))`, and the destructor is executed in each forked process. When libFuzzer is run with the `-fork=N` or `-jobs=N` flags, it forks child processes. Each child process inherits the loaded shared library and its destructors. Fixes #89
ligurio
force-pushed
the
ligurio/gh-89-print-metrics-once
branch
from
July 17, 2026 18:36
f5b7f27 to
9b0c252
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The function metrics_print() is called twice when
-fork/-jobsare used. The reason is thatmetrics_print()is called from__attribute__((destructor)), and the destructor is executed in each forked process. When libFuzzer is run with the-fork=Nor-jobs=Nflags, it forks child processes. Each child process inherits the loaded shared library and its destructors.The patch fixes that by adding a check to
metrics_print()to skip printing if all metrics are zero (so the parent process with zeros won't print, but the child process with data will).Fixes #89