Summary: | Error in apr_atomic_xchgptr | ||
---|---|---|---|
Product: | APR | Reporter: | Mattias Engdegård <mattiase> |
Component: | APR | Assignee: | Apache Portable Runtime bugs mailinglist <bugs> |
Status: | CLOSED FIXED | ||
Severity: | normal | CC: | danielsh, davi |
Priority: | P2 | Keywords: | FixedInTrunk |
Version: | HEAD | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Linux |
Description
Mattias Engdegård
2011-09-20 18:23:09 UTC
This bug is not necessarily caught by the regression test (testatomic.c), because of a poor choice of test pointer value (NULL). The following patch makes the test stronger, and actually catches the bug: --- test/testatomic.c (revision 1174015) +++ test/testatomic.c (arbetskopia) @@ -84,11 +84,12 @@ static void test_xchgptr(abts_case *tc, void *data) { int a; - volatile void *target_ptr = NULL; + void *ref = "little piggy"; + volatile void *target_ptr = ref; void *old_ptr; old_ptr = apr_atomic_xchgptr(&target_ptr, &a); - ABTS_PTR_EQUAL(tc, NULL, old_ptr); + ABTS_PTR_EQUAL(tc, ref, old_ptr); ABTS_PTR_EQUAL(tc, &a, (void *) target_ptr); } Also note that for the bug to show up, the bad code in atomic/unix/ia32.c must be used, which is only the case when a gcc without builtin sync primitives was used for the configuration script - that is, gcc 4.0.x or older. Fixed in apr 1.4.7 and later releases. |