Summary: When we see `pthread_create(..., ..., foo, ...)`, we want to call the function `foo` to check that its precondition is met. The initial goal was to get rid of the uncouth call to `Summary.get` when what we really want is to analyse `foo` instead of just betting on the fact that it has been analysed already. Besides switching to `Ondemand.analyze_proc_name`, this also changes the matching of the function pointer in the arguments of `pthread_create()` to detect the common case of a constant function name. I also added tests. Reviewed By: jeremydubreil Differential Revision: D9195159 fbshipit-source-id: dfec79f14master
parent
f5edf57cdf
commit
987ef9ef67
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
void dummy() {}
|
||||||
|
|
||||||
|
void deref_pointer(int* x) { int y = *x; }
|
||||||
|
|
||||||
|
int pthread_create_dummy_ok() {
|
||||||
|
pthread_t thread;
|
||||||
|
return pthread_create(&thread, NULL, dummy, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int pthread_create_deref_bad() {
|
||||||
|
pthread_t thread;
|
||||||
|
return pthread_create(&thread, NULL, deref_pointer, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int pthread_create_deref_ok() {
|
||||||
|
pthread_t thread;
|
||||||
|
int x;
|
||||||
|
return pthread_create(&thread, NULL, deref_pointer, &x);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void some_unknown_function(void);
|
||||||
|
|
||||||
|
int pthread_unknown_ok() {
|
||||||
|
pthread_t thread;
|
||||||
|
return pthread_create(&thread, NULL, some_unknown_function, NULL);
|
||||||
|
}
|
Loading…
Reference in new issue