Summary: Demonstrate that the per-file type environments don't prevent the deadlock report here. The fear was that when the analyser tries to locate the methods of the endpoint class, it might fail to do so because the types might be stored in different type environments (per file). Reviewed By: mityal Differential Revision: D19225908 fbshipit-source-id: 097e4aeeamaster
parent
0b7e479b34
commit
ca1ba2511b
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "crossfile-1.h"
|
||||
|
||||
// a deadlock should be reported here
|
||||
void CrossFileOne::lock_my_mutex_first_then_the_other() {
|
||||
_mutex.lock();
|
||||
_other->just_lock_my_mutex();
|
||||
_mutex.unlock();
|
||||
}
|
||||
|
||||
void CrossFileOne::just_lock_my_mutex() {
|
||||
_mutex.lock();
|
||||
_mutex.unlock();
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef CROSS_FILE_ONE
|
||||
#define CROSS_FILE_ONE
|
||||
|
||||
/* The goal of this test is to demonstrate that the per-file type
|
||||
environments don't prevent the deadlock report here */
|
||||
|
||||
// unused include to distinguish the two per-file type environments
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
|
||||
class CrossFileOne;
|
||||
|
||||
#include "crossfile-2.h"
|
||||
|
||||
class CrossFileOne {
|
||||
public:
|
||||
CrossFileOne() {}
|
||||
void lock_my_mutex_first_then_the_other();
|
||||
void just_lock_my_mutex();
|
||||
|
||||
private:
|
||||
std::mutex _mutex;
|
||||
CrossFileTwo* _other;
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "crossfile-2.h"
|
||||
|
||||
// a deadlock should be reported here
|
||||
void CrossFileTwo::lock_my_mutex_first_then_the_other() {
|
||||
_mutex.lock();
|
||||
_other->just_lock_my_mutex();
|
||||
_mutex.unlock();
|
||||
}
|
||||
|
||||
void CrossFileTwo::just_lock_my_mutex() {
|
||||
_mutex.lock();
|
||||
_mutex.unlock();
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/* The goal of this test is to demonstrate that the per-file type
|
||||
environments don't prevent the deadlock report here */
|
||||
|
||||
#ifndef CROSS_FILE_TWO
|
||||
#define CROSS_FILE_TWO
|
||||
|
||||
#include <mutex>
|
||||
|
||||
class CrossFileTwo;
|
||||
|
||||
#include "crossfile-1.h"
|
||||
|
||||
class CrossFileTwo {
|
||||
public:
|
||||
CrossFileTwo() {}
|
||||
void lock_my_mutex_first_then_the_other();
|
||||
void just_lock_my_mutex();
|
||||
|
||||
private:
|
||||
std::mutex _mutex;
|
||||
CrossFileOne* _other;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in new issue