You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To implement counters and the pc-table, Ruzzy hooks coverage events similar to Ruby's builtin Coverage module. It's great that this functionality is built into Ruby and we don't have to modify the Ruby bytecode during execution, or use some other heavy-handed means of tracking coverage. However, coverage instrumentation is not currently part of Ruby's public C API. To gather coverage instrumentation, Ruzzy has to perform two hacky actions:
Hook the internal-only RUBY_EVENT_COVERAGE_BRANCH event:
As the comment mentions, we must call Coverage.setup, which calls rb_set_coverages. If this is not called, then rb_get_coverages will return NULL in iseq.c, and coverage tracking will not be enabled.
To simplify Ruzzy's coverage tracking, I would request that both of these pieces of functionality be made a part of Ruby's public C interface. Particularly, the RUBY_EVENT_COVERAGE_BRANCH event, so we can hook coverage events with the standard rb_add_event_hook function. And a means to initialize Ruby's global coverage state, similar to rb_set_coverages, so a C extension can enable and gather coverage information. It would be very helpful if coverage events like lines and branches were added to the TracePoint API, both for Ruby and for C extensions.
An additional nice to have would be extending the public tracearg functionality to include additional coverage information. Currently, tracearg offers information like rb_tracearg_lineno and rb_tracearg_path. It would be helpful if it also provided additional coverage information like coverage.c's column information and a unique identifier for each branch. Currently, Ruzzy has to use (path, lineno) as a unique identifier for a branch because that's what's offered by the public API, but more information would be helpful for uniquely identify branches.
The text was updated successfully, but these errors were encountered:
Ruzzy implements libFuzzer's SanitizerCoverage to achieve coverage-guided fuzzing of Ruby code.
It achieves this via three of SanitizerCoverage's features:
To implement counters and the pc-table, Ruzzy hooks coverage events similar to Ruby's builtin Coverage module. It's great that this functionality is built into Ruby and we don't have to modify the Ruby bytecode during execution, or use some other heavy-handed means of tracking coverage. However, coverage instrumentation is not currently part of Ruby's public C API. To gather coverage instrumentation, Ruzzy has to perform two hacky actions:
Hook the internal-only
RUBY_EVENT_COVERAGE_BRANCH
event:ruzzy/ext/cruzzy/cruzzy.c
Lines 12 to 16 in 5e39944
Call the Ruby interface to the
Coverage
module to enable coverage tracking, rather than a public C API:ruzzy/ext/cruzzy/cruzzy.c
Lines 195 to 211 in 5e39944
As the comment mentions, we must call
Coverage.setup
, which callsrb_set_coverages
. If this is not called, thenrb_get_coverages
will returnNULL
iniseq.c
, and coverage tracking will not be enabled.To simplify Ruzzy's coverage tracking, I would request that both of these pieces of functionality be made a part of Ruby's public C interface. Particularly, the
RUBY_EVENT_COVERAGE_BRANCH
event, so we can hook coverage events with the standardrb_add_event_hook
function. And a means to initialize Ruby's global coverage state, similar torb_set_coverages
, so a C extension can enable and gather coverage information. It would be very helpful if coverage events like lines and branches were added to theTracePoint
API, both for Ruby and for C extensions.An additional nice to have would be extending the public
tracearg
functionality to include additional coverage information. Currently,tracearg
offers information likerb_tracearg_lineno
andrb_tracearg_path
. It would be helpful if it also provided additional coverage information likecoverage.c
's column information and a unique identifier for each branch. Currently, Ruzzy has to use(path, lineno)
as a unique identifier for a branch because that's what's offered by the public API, but more information would be helpful for uniquely identify branches.The text was updated successfully, but these errors were encountered: