-
Notifications
You must be signed in to change notification settings - Fork 49
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
[asan] various test and core bug repairs toward asan testing #1737
Conversation
7bd26c7
to
292a607
Compare
Rebased. The test fail was due to the write error, so hopefully the updates on master will take care of it. |
Codecov Report
@@ Coverage Diff @@
## master #1737 +/- ##
==========================================
- Coverage 79.33% 79.31% -0.02%
==========================================
Files 184 184
Lines 34555 34559 +4
==========================================
- Hits 27414 27411 -3
- Misses 7141 7148 +7
|
The PR title is more descriptive of the commit than the commit title, so maybe use it to update the commit title? Suggestion: if there are a few more asan/test fixes coming, perhaps we should hold off merging this and you can tack them on here? |
292a607
to
a7a6043
Compare
With the various vixes from @chu11 and @SteVwonder plus what's in here, the entire test suite can run under asan and PASS. There are still many leaks, and certain tests tickle other issues, but running like this: |
Fixes flux-framework#1722 The buf used in the first loop was probably sized before the largest of the bad inputs was added. The comment over printable says give at least double, it was giving 80 bytes for a 90 byte + input. Rather than minimally increasing it, the 512 byte buffer used in the second loop is now shared by both loops.
The lua_string_to_cpu_setp function always accessed the first two bytes, even if there aren't two bytes to access. Switched to strncmp to avoid reading past the end of a string.
a7a6043
to
b565740
Compare
These are some good finds! One nit: I'd prefer that we fix the subset of TAP tests that use the bad idiom, rather than create an |
This should do it for that test diff --git a/src/broker/test/attr.c b/src/broker/test/attr.c
index 8f91208..cb002aa 100644
--- a/src/broker/test/attr.c
+++ b/src/broker/test/attr.c
@@ -102,7 +102,7 @@ int main (int argc, char **argv)
*/
val = attr_first (attrs);
ok (val && !strcmp (val, "foo"),
- "attr_first returned %s", val);
+ "attr_first returned foo");
ok (attr_next (attrs) == NULL,
"attr_next returned NULL");
ok (attr_add (attrs, "foo1", "42", 0) == 0
@@ -112,19 +112,19 @@ int main (int argc, char **argv)
"attr_add foo1, foo2, foo3, foo4 works");
val = attr_first (attrs);
ok (val && !strncmp (val, "foo", 3),
- "attr_first returned %s", val);
+ "attr_first returned foo-prefixed attr");
val = attr_next (attrs);
ok (val && !strncmp (val, "foo", 3),
- "attr_next returned %s", val);
+ "attr_next returned foo-prefixed attr");
val = attr_next (attrs);
ok (val && !strncmp (val, "foo", 3),
- "attr_next returned %s", val);
+ "attr_next returned foo-prefixed attr");
val = attr_next (attrs);
ok (val && !strncmp (val, "foo", 3),
- "attr_next returned %s", val);
+ "attr_next returned foo-prefixed attr");
val = attr_next (attrs);
ok (val && !strncmp (val, "foo", 3),
- "attr_next returned %s", val);
+ "attr_next returned foo-prefixed attr");
ok (attr_next (attrs) == NULL,
"attr_next returned NULL");
@@ -134,28 +134,28 @@ int main (int argc, char **argv)
"attr_add_active_int works");
a = 0;
ok (attr_get (attrs, "a", &val, NULL) == 0 && val && !strcmp (val, "0"),
- "attr_get on active int tracks value: %s", val);
+ "attr_get on active int tracks val=0");
a = 1;
ok (attr_get (attrs, "a", &val, NULL) == 0 && !strcmp (val, "1"),
- "attr_get on active int tracks value: %s", val);
+ "attr_get on active int tracks val=1");
a = -1;
ok (attr_get (attrs, "a", &val, NULL) == 0 && !strcmp (val, "-1"),
- "attr_get on active int tracks value: %s", val);
+ "attr_get on active int tracks val=-1");
a = INT_MAX - 1;
ok (attr_get (attrs, "a", &val, NULL) == 0
&& strtol (val, NULL, 10) == INT_MAX - 1,
- "attr_get on active int tracks value: %s", val);
+ "attr_get on active int tracks val=INT_MAX-1");
a = INT_MIN + 1;
ok (attr_get (attrs, "a", &val, NULL) == 0
&& strtol (val, NULL, 10) == INT_MIN + 1,
- "attr_get on active int tracks value: %s", val);
+ "attr_get on active int tracks val=INT_MIN+1");
ok (attr_set (attrs, "a", "0", false) == 0 && a == 0,
- "attr_set on active int sets value: %d", a);
+ "attr_set on active int sets val=0");
ok (attr_set (attrs, "a", "1", false) == 0 && a == 1,
- "attr_set on active int sets value: %d", a);
+ "attr_set on active int sets val=1");
ok (attr_set (attrs, "a", "-1", false) == 0 && a == -1,
- "attr_set on active int sets value: %d", a);
+ "attr_set on active int sets val=-1");
errno = 0;
ok (attr_delete (attrs, "a", false) < 0 && errno == EPERM,
"attr_delete on active attr fails with EPERM");
@@ -168,19 +168,19 @@ int main (int argc, char **argv)
"attr_add_active_uint32 works");
b = 0;
ok (attr_get (attrs, "b", &val, NULL) == 0 && val && !strcmp (val, "0"),
- "attr_get on active uin32_t tracks value: %s", val);
+ "attr_get on active uin32_t tracks val=0");
b = 1;
ok (attr_get (attrs, "b", &val, NULL) == 0 && !strcmp (val, "1"),
- "attr_get on active uint32_t tracks value: %s", val);
+ "attr_get on active uint32_t tracks val=1");
b = UINT_MAX - 1;
ok (attr_get (attrs, "b", &val, NULL) == 0
&& strtoul (val, NULL, 10) == UINT_MAX - 1,
- "attr_get on active uint32_t tracks value: %s", val);
+ "attr_get on active uint32_t tracks val=UINT_MAX-1");
ok (attr_set (attrs, "b", "0", false) == 0 && b == 0,
- "attr_set on active uint32_t sets value: %d", b);
+ "attr_set on active uint32_t sets val=0");
ok (attr_set (attrs, "b", "1", false) == 0 && b == 1,
- "attr_set on active uint32_t sets value: %d", b);
+ "attr_set on active uint32_t sets val=1");
ok (attr_delete (attrs, "b", true) == 0,
"attr_delete (force) works on active attr");
@@ -190,10 +190,10 @@ int main (int argc, char **argv)
"attr_add_active_int FLUX_ATTRFLAG_IMMUTABLE works");
c = 42;
ok (attr_get (attrs, "c", &val, NULL) == 0 && val && !strcmp (val, "42"),
- "attr_get returns initial value: %s", val);
+ "attr_get returns initial val=42");
c = 43;
ok (attr_get (attrs, "c", &val, NULL) == 0 && val && !strcmp (val, "42"),
- "attr_get ignores value changes: %s", val);
+ "attr_get ignores value changes");
errno = 0;
ok (attr_delete (attrs, "c", true) < 0 && errno == EPERM,
"attr_delete (force) fails with EPERM"); |
This is probably my fault as @trws had asked on slack which method to use and I had agreed that if we could fix it in ok() that would be nice (if accepted upstream). Sorry! |
While the failure path frees the nodeset, the success path did not.
Found this through asan on sharness tests of dmesg, the flux-loggger command uses read_all and then assumes that the result is null-terminated.
b565740
to
d16f725
Compare
Ok, applied the patch from @garlick (thanks!), and rebased out the original change to safe_ok. Assuming I didn't miss something in the rebase I think this is GTG. |
LGTM, thanks! |
Fixes #1722
The buf used in the first loop was probably sized before the largest of
the bad inputs was added. The comment over printable says give at least
double, it was giving 80 bytes for a 90 byte + input. Rather than
minimally increasing it, the 512 byte buffer used in the second loop is
now shared by both loops.