xserver / unit - test hangs when compiled with -Db_ndebug=true (asserts enabled)
When compiled with -Db_ndebug=true (enabling asserts), the xserver / unit
test hangs in the cmp_attr_fields
function. Without asserts enabled it passes.
This is because the *tags2++
increment happens inside an assert
macro:
static void
cmp_attr_fields(InputAttributes * attr1, InputAttributes * attr2)
{
[...]
/* check for not sharing memory */
tags1 = attr1->tags;
while (*tags1) {
tags2 = attr2->tags;
while (*tags2)
assert(*tags1 != *tags2++);
tags1++;
}
}
static void
dix_input_attributes(void)
{
[...]
orig->tags = xstrtokenize("tag1 tag2 tag3", " ");
new = DuplicateInputAttributes(orig);
cmp_attr_fields(orig, new);
FreeInputAttributes(new);
FreeInputAttributes(orig);
}
The test used g_assert
until commit 196d679b. I don't know the behavior of g_assert
.
Moving the increment outside of the assert causes the test to fail when assert
s are disabled:
diff --git a/test/input.c b/test/input.c
index f092bb46d..5e394d2d3 100644
--- a/test/input.c
+++ b/test/input.c
@@ -1173,8 +1173,10 @@ cmp_attr_fields(InputAttributes * attr1, InputAttributes * attr2)
tags1 = attr1->tags;
while (*tags1) {
tags2 = attr2->tags;
- while (*tags2)
- assert(*tags1 != *tags2++);
+ while (*tags2) {
+ assert(*tags1 != *tags2);
+ tags2++;
+ }
tags1++;
}
But I don't know really what the test is doing to debug the failure.
cc: @whot