Skip to content

Conversation

@catenacyber
Copy link
Contributor

Link to redmine ticket:
https://redmine.openinfosecfoundation.org/issues/4125

Describe changes:

  • do not rebuild rust std when instrumenting for coverage (as both seem incompatible)
  • fuzz driver accepts directories as well as single files now

Modifies #5595 with

  • clang-format
  • use of _BSD_SOURCE to get to use DT_REG

TL;DR
To get coverage report including rust with oss-fuzz, we will also need rustc changes, and oss-fuzz changes
To get this manually is possible, cf below

To get coverage, I compile with

export RUSTFLAGS="$RUSTFLAGS -Zinstrument-coverage"
export CFLAGS="-g -O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fprofile-instr-generate -fcoverage-mapping -pthread -fsanitize=fuzzer-no-link"
export CXXFLAGS="-g -O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fprofile-instr-generate -fcoverage-mapping -pthread -fsanitize=fuzzer-no-link -stdlib=libc++"

I also run in rust subdirectory

abspath=`cargo metadata | jq -r '.workspace_root'`
export RUSTFLAGS="$RUSTFLAGS --remap-path-prefix src=$abspath/src"

to get the absolute file paths for suricata's crate, so that llvm-cov can generate a nice report

You need some fresh rust nightly compiler and llvm 10
For LLVM 11 and 12, rust compiler should be just ready cf rust-lang/rust#79365

@catenacyber catenacyber requested a review from a team as a code owner November 30, 2020 20:02
victorjulien added a commit to victorjulien/suricata that referenced this pull request Nov 28, 2025
victorjulien added a commit to victorjulien/suricata that referenced this pull request Nov 28, 2025
victorjulien added a commit to victorjulien/suricata that referenced this pull request Nov 28, 2025
To avoid overhead of copies during syncs, compress the local stats table.

Previously all counters had 2 64bit ints: one for the value, one to
track the number of times the counter was updated. The updates field was
only used for counters of type "average" however. Since only a few
average counters were in use, this effectively meant that almost half of
the space used for the table was wasted.

This patch reduces `StatsLocalCounter` to a single i64. Regular counters
simply use this directly by using their id as an index into the table.

For avg counters the logic is similar, however they effectively use 2
indexes, idx and idx+1. The value is at `idx`, the updates are at `idx +
1`.

Ticket: OISF#5613.
victorjulien added a commit to victorjulien/suricata that referenced this pull request Dec 2, 2025
victorjulien added a commit to victorjulien/suricata that referenced this pull request Dec 2, 2025
victorjulien added a commit to victorjulien/suricata that referenced this pull request Dec 2, 2025
To avoid overhead of copies during syncs, compress the local stats table.

Previously all counters had 2 64bit ints: one for the value, one to
track the number of times the counter was updated. The updates field was
only used for counters of type "average" however. Since only a few
average counters were in use, this effectively meant that almost half of
the space used for the table was wasted.

This patch reduces `StatsLocalCounter` to a single i64. Regular counters
simply use this directly by using their id as an index into the table.

For avg counters the logic is similar, however they effectively use 2
indexes, idx and idx+1. The value is at `idx`, the updates are at `idx +
1`.

Ticket: OISF#5613.
victorjulien added a commit to victorjulien/suricata that referenced this pull request Dec 9, 2025
victorjulien added a commit to victorjulien/suricata that referenced this pull request Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant