Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several fixes and small enhancements. #23

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

f0rki
Copy link

@f0rki f0rki commented Jan 15, 2024

let me know if you want them split into separate PRs.

Copy link
Owner

@hgarrereyn hgarrereyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for the code! Really appreciate the schema validation you added; I think that would be a big help for people writing harnesses. I left some comments/questions on the details. Also, regarding the ASAN build and some of the uninit protections you added to core, were you hitting errors caused by uninitialized reads or is this just proactive?

core/graph.hpp Outdated
while (sample >= 0) {
sample_idx += 1;
unsigned int sample_idx = 0;
while (sample >= 0 && sample_idx < tree.children.size()) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like sample_idx needs to update inside the loop here

core/graph.hpp Outdated
sample -= tree.children[sample_idx].num_subtrees;
}
if (sample_idx >= tree.children.size()) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious if you hit cases where this went out of bounds; if so, may be a bug with the num_subtrees computation

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. I observed a OOB on tree.childern[sample_idx].

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on second thought. maybe this was just an attempt to fix the loop above.


for (Node n : nodes) {
void *in_ref[n.in_ref_size()];
void *out_ref[n.out_ref_size()];
void *in_ref[n.in_ref_size() + 1];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you explain this part

Copy link
Author

@f0rki f0rki Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UBSan detects zero sized VLA on the stack as UB, so I just made sure the array has at least one element, even if it is not used.

@@ -53,7 +53,7 @@
'''

CPP_SAVE_REF = '''\
out_ref[{out_ref_idx}] = reinterpret_cast<void *>({arg_name});
out_ref[{out_ref_idx}] = (void*)({arg_name});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there was a reason I used reinterpret_cast here over C-style casts, bit I can't remember the specifics. Can you explain the rationale for this change?

Copy link
Author

@f0rki f0rki Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had troubles with harnessing a C library unless I used this. (because of casting a const pointer to a non-const pointer and vice-versa or something. I think const to non-const cast is forbidden with reinterpret_cast).

@f0rki
Copy link
Author

f0rki commented Jan 16, 2024

ok let me redo the bugfix. There might be some unnecessary changes.

f0rki added 6 commits January 16, 2024 16:28
* `global_init` is now a configurable piece of code specified in the
  schema. This allows to perform some setup once globally vs. at every
  testcase (`initializer` and `finalizer` are called on every `LLVMFuzzerTestOneInput`)
* Output the code pieces from `global_init`, `initializer`, and `finalizer` in the testcase writer.
@f0rki
Copy link
Author

f0rki commented Jan 16, 2024

were you hitting errors caused by uninitialized reads or is this just proactive?

I believe this might have been caused by the issue with the subtree sampling in AppendTree. I switched to do this only if debug flag is set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants