A method and apparatus are used in accordance with the present invention in concurrent
program analysis for detecting potential race conditions such as data races in computer programs. A feature of the method and apparatus of the present invention is verifying annotations of addressable resources in a program. The present invention verifies annotations by checking if thread-local resources are indeed thread-local, and that thread-shared data spaces are not in fact thread-local. In accordance with the purpose of the invention, the method provides for detecting potential race conditions, such as data races, in a
computer program. The
computer program can spawn a plurality of threads that are capable of being executed concurrently. The method includes receiving a
source code of the
computer program. The
source code includes an element annotated as either thread-local or thread-shared. The method also includes verifying the validity of the thread-local
annotation if the element is annotated in the computer program as thread-local, wherein an invalid thread-local
annotation may cause a
race condition. The method can further include indicating a potential
race condition if upon verifying the validity of the thread-local
annotation it is determined that the element or a portion thereof is visible from more than one, rather than one and only one, of the plurality of threads. In further accordance with the purpose of the invention, the apparatus for concurrent
program analysis includes means for receiving
source code of the computer program. The source code includes an element annotated as either thread-local or thread-shared. The apparatus also includes means for
type checking the source code; and means for thread-local checking located either inside or in series with the
type checking means. The means for thread-local checking includes means for verifying the validity of the thread-local annotation if the element is annotated in the computer program as thread-local, where an invalid thread-local annotation may cause a
race condition such as a data race. The apparatus can further include means for
parsing the source code; and means for creating from the source code an
abstract syntax tree. Accordingly, the present invention beneficially provides for a more effective concurrent
program analysis.