[LLVMbugs] [Bug 15995] New: Let developers annotate, and the analyzer catch, threading requirements on function/method calls
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue May 14 08:13:57 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=15995
Bug ID: 15995
Summary: Let developers annotate, and the analyzer catch,
threading requirements on function/method calls
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Static Analyzer
Assignee: kremenek at apple.com
Reporter: iamleeg at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Summary:
some frameworks, notably AppKit and UIKit, require particular methods to be
called on particular threads, but contain no checks for this requirement.
Please could clang give the ability to annotate functions with thread
requirements, and the analyzer check for simple transgressions?
Steps to reproduce:
I imagine being able to write code like this:
@interface UIView
//…
- (void)removeFromSuperview __attribute__((main_thread_only));
@end
and calling that like this:
dispatch_async(my_non_main_queue, ^{[someLabel removeFromSuperview];}]);
Expected results:
running scan-build on the above code should emit a message that the method with
a main_thread_only attribute is dispatched to a queue that doesn't schedule
work on the main thread.
Actual results:
This is an enhancement request, the expected functionality does not yet exist.
Regression: none.
Notes:
This analyzer rule could catch use of main-thread code on private dispatch
queues, global dispatch queues and non-main NSOperationQueues, in addition to
non-main threads created via pthread_create() or (ideally, though with
difficulty) +[NSThread detachNewThread…].
While ideally the check for which thread an object needs to be used on would be
either handled by that object or part of the object's contract with its
callers, there are performance implications on including such tests at runtime.
There are also benefits to detecting the problems at build time. Both of these
reasons motivate this request for the analyzer to detect such issues.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130514/c512fb93/attachment.html>
More information about the llvm-bugs
mailing list