You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@apr.apache.org by bu...@apache.org on 2010/01/13 13:36:13 UTC
DO NOT REPLY [Bug 48535] New: Data race detection tools report a
potential data race on allocator->max_index in allocator_alloc()
https://issues.apache.org/bugzilla/show_bug.cgi?id=48535
Summary: Data race detection tools report a potential data race
on allocator->max_index in allocator_alloc()
Product: APR
Version: 1.3.9
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: APR
AssignedTo: bugs@apr.apache.org
ReportedBy: bart.vanassche@gmail.com
When analyzing a multithreaded program that calls both allocator_alloc() and
allocator_free() with a data race detection tool, these tools report a
potential data race on the accesses of allocator->index at the start of
allocator_alloc(). While these conflicting accesses seem harmless to me because
allocator->index is reread after having locked the allocator mutex, this is
annoying.
A straightforward workaround is to move the allocator->mutex locking /
unlocking statements from inside the if-statement to outside the if-statement.
But I'm afraid that doing this would decrease performance.
This issue has been reported previously on the apr-dev mailing list -- see also
http://mail-archives.apache.org/mod_mbox/apr-dev/200908.mbox/%3C4A81D0F4.90406@ruppert-it.de%3E
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
DO NOT REPLY [Bug 48535] Potential data race on allocator->max_index
in allocator_alloc()
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48535
--- Comment #5 from sr-dev@gmx.net 2010-09-04 14:17:44 EDT ---
(In reply to comment #1)
> Isn't this an intentional race condition, following the usual pattern
>
> make a very cheap but imperfect state check
> if it looks good so far:
> get mutex
> check state carefully this time, handle appropriately
> release mutex
Thats true, but the current code does not do this (check again carefully).
Currently it does the following:
if index <= allocator->max_index
get mutex
do something1
release mutex
else
do something2
But it does not check the state carefully again... So I think it should do
this:
if index <= allocator->max_index
get mutex
// max_index could be changed in the mean while
if index <= allocator->max_index
do something1
release mutex
else
release mutex
do something2
else
do something2
However, I do not know the allocator code at all. But without the second if it
is possible to execute do something1 even if index is greater than max_index!
Regards,
Stefan (reporter of the issue on the mailing list ;-)
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
DO NOT REPLY [Bug 48535] Potential data race on allocator->max_index
in allocator_alloc()
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48535
--- Comment #1 from Jeff Trawick <tr...@apache.org> 2010-01-29 04:00:32 UTC ---
Isn't this an intentional race condition, following the usual pattern
make a very cheap but imperfect state check
if it looks good so far:
get mutex
check state carefully this time, handle appropriately
release mutex
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
DO NOT REPLY [Bug 48535] Potential data race on allocator->max_index
in allocator_alloc()
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48535
--- Comment #4 from Bart Van Assche <ba...@gmail.com> 2010-01-31 09:38:46 UTC ---
(In reply to comment #3)
> Is there a -DPURIFY-like constant that is in standard use, which could be used
> to ifdef-munge the code, to avoid the lazy check? Given that the code is valid
> it would be better to fix the analysis tools to be smarter than to make the
> code dumber.
Recent DRD and Helgrind versions support annotations like
ANNOTATE_IGNORE_READS_BEGIN() / ANNOTATE_IGNORE_READS_END(). Unfortunately
these annotations are not supported by thread checking tools on Windows.
An approach that might work with all four mentioned data race detectors is to
replace the read of allocator->index outside the critical section by an atomic
read. Doing so would suppress race reports.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
DO NOT REPLY [Bug 48535] Potential data race on allocator->max_index
in allocator_alloc()
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48535
Bart Van Assche <ba...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Data race detection tools |Potential data race on
|report a potential data |allocator->max_index in
|race on |allocator_alloc()
|allocator->max_index in |
|allocator_alloc() |
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
DO NOT REPLY [Bug 48535] Potential data race on allocator->max_index
in allocator_alloc()
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48535
--- Comment #3 from Joe Orton <jo...@redhat.com> 2010-01-31 06:05:44 UTC ---
Is there a -DPURIFY-like constant that is in standard use, which could be used
to ifdef-munge the code, to avoid the lazy check? Given that the code is valid
it would be better to fix the analysis tools to be smarter than to make the
code dumber.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
DO NOT REPLY [Bug 48535] Potential data race on allocator->max_index
in allocator_alloc()
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48535
--- Comment #2 from Bart Van Assche <ba...@gmail.com> 2010-01-29 04:06:11 UTC ---
(In reply to comment #1)
> Isn't this an intentional race condition, following the usual pattern
>
> make a very cheap but imperfect state check
> if it looks good so far:
> get mutex
> check state carefully this time, handle appropriately
> release mutex
I agree with the above. The reason that I filed this report is not because I
suspect a bug in APR but because the thread checker reports are annoying.
Thread checking tools (Intel Parallel Studio, Intel Thread Checker, DRD,
Helgrind, ...) complain about this construct during every run of every
application that uses the APR.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org