WO2019006997A1 - Procédé de détection d'interblocage de programmes, support d'informations, dispositif et système - Google Patents
Procédé de détection d'interblocage de programmes, support d'informations, dispositif et système Download PDFInfo
- Publication number
- WO2019006997A1 WO2019006997A1 PCT/CN2017/117366 CN2017117366W WO2019006997A1 WO 2019006997 A1 WO2019006997 A1 WO 2019006997A1 CN 2017117366 W CN2017117366 W CN 2017117366W WO 2019006997 A1 WO2019006997 A1 WO 2019006997A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- thread
- function
- creation function
- program
- creation
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/466—Transaction processing
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
Definitions
- the present invention relates to the field of operating systems, and in particular, to a program deadlock detection method, a storage medium, a device, and a system.
- An application running in the Windows operating system usually creates multiple threads to share the logic operations of its own runtime, thereby effectively improving the efficiency of the application itself.
- the Windows operating system provides a series of thread synchronization and mutual exclusion. Methods to solve the problem of conflicts between threads, for example, signal events, critical sections, mutexes, etc. can be used for thread synchronization and mutual exclusion, but with the use of thread synchronization and mutual exclusion methods, It is the deadlock problem of threads during the running of the application.
- Deadlock refers to a blocking imagination caused by two or more threads in the process of execution, due to competition of resources or communication between each other. Without other external forces, the thread will remain in the wait state, and the program will be in a deadlock state. These threads that are always waiting for each other are called deadlock threads. If it is not known in time that the program has a deadlock, it is aimed at the program. The effective resolution of the deadlock problem will greatly affect the subsequent operation of the program.
- the object of the present invention is to provide a program deadlock detection method, which can timely and effectively determine whether a program has a deadlock.
- the present invention also provides a program deadlock detection system, which can The program's deadlock is effectively detected, so that the program can be judged in a timely and effective manner.
- the technical solution adopted by the present invention includes:
- the resources include a memory physical address, a disk sector, a CPU, and an OS resource of an operating system.
- S2 is specifically:
- the hook function returns the thread handle value returned when the thread is created, the current thread corresponding to the handle creation function, and the thread ID of the current thread.
- the signal event creation function When the signal event creation function performs signal event creation, the signal event handle value returned by the signal event creation, the current thread corresponding to the signal event creation function, and the thread ID of the current thread are obtained by the hook function;
- the hook function When the mutex creation function creates the mutex, the hook function returns the mutex handle value returned when the mutex is created, the current thread corresponding to the mutex creation function, and the thread ID of the current thread.
- the hook function value returned when the critical section is created, the current thread corresponding to the critical section creation function, and the thread ID of the current thread are obtained by the hook function.
- the hook function is also used to join the wait function
- the hook function is used to get the resources that the thread is waiting for.
- the present invention also provides a storage medium having stored thereon a computer program that implements a program deadlock detection method when the computer program is executed by a processor.
- the invention also provides a program deadlock detecting device, comprising a memory and a processor, wherein the memory stores a computer program running on the processor, and the processor implements the deadlock detecting method when the computer program executes the computer program .
- the invention also provides a program deadlock detection system, comprising:
- An injection module for injecting a hook function into a thread's thread handle creation function, a signal event creation function, a mutex creation function, and a critical section creation function;
- the obtaining module is configured to respectively use a hook function when the thread handle creation function, the signal event creation function, the mutex creation function, or the critical section creation function respectively perform thread, signal event, mutex or critical section creation Obtaining a thread handle creation function, a signal event creation function, a current thread corresponding to the cipher creation function and the critical section creation function, and a thread ID of the current thread, and the obtaining module is further configured to acquire a resource that the current thread waits for;
- a storage module configured to store the thread and the thread ID acquired by the acquiring module in a global field, where the storage module is further configured to store the resource owned by the acquired thread in the global field;
- a judging module configured to take two threads from the global field, if the resource waiting for the first thread is the resource owned by the second thread, and the resource waiting for the second thread is the first thread If the resource is owned, the program will be deadlocked. If not, the program will not be deadlocked.
- the resources include a memory physical address, a disk sector, a CPU, and an OS resource of an operating system.
- the injection module is further configured to inject a hook function into the waiting function of the system, and when the waiting function runs, acquire the resource waiting for the thread through the hook function.
- the present invention has the advantages of: injecting a hook function in a thread handle creation function, a signal event creation function, a mutex creation function, and a critical section creation function, respectively acquiring a thread handle creation function by a hook function
- the signal thread creation function, the mutex creation function, and the current thread corresponding to the critical section creation function and the thread ID of the current thread thereby quickly and conveniently acquiring the resources owned by the thread and the resources waiting, facilitating timely threading.
- the judgment of the closed-loop dependency relationship can achieve the purpose of timely learning when the program has a deadlock, and it is convenient to process the deadlock program in time.
- FIG. 1 is a flowchart of a method for detecting a program deadlock according to an embodiment of the present invention
- FIG. 2 is a schematic structural diagram of a program deadlock detecting apparatus according to an embodiment of the present invention.
- an embodiment of the present invention provides a program deadlock detection method, which is used to determine whether a program has a deadlock, a thread synchronization, and a mutual exclusion when a program uses a thread synchronization and mutual exclusion mechanism to perform multi-thread operation.
- the mechanism includes a signal event, a critical section, a mutex, and a thread handle.
- the program runs on the Windows operating system, and the program deadlock detection method in the embodiment of the present invention is completed based on the Windows operating system. For a program that has a deadlock, there must be a loop waiting condition. For example, thread P1 is waiting for the resource occupied by one thread P2, and thread P2 is waiting for the resource occupied by one thread P1. In this case, the deadlock of the program will occur. .
- the signal event has two states, one is the signal state, the other is the no signal state, and the thread is waiting for a signal event with no signal state to be blocked.
- a signal event is created by calling the system's signal event creation function CreateEvent. By waiting for a signal event by calling the wait function WaitForSingleObject, the resource waiting for the current thread can be known.
- the mutex has two states, one is the idle state, and the other is the occupied state.
- the mutex becomes occupied. But the thread will not be blocked, but when a thread waits for a mutex in an occupied state, the thread will be blocked.
- For the current thread create a mutex by calling the mutex creation function, and wait for a mutex through the system call wait function WaitForSingleObject to know the resources waiting for the current thread.
- the critical section has two states, one is the entry state, and the other is the non-entry state.
- the critical section becomes the entry state, but the thread does not. It will be blocked, but the thread will be blocked when it waits for a critical section when entering the state.
- a critical section is created by calling the critical section creation function of the system. By waiting for a critical section by calling the wait function WaitForSingleObject, the resource waiting for the current thread can be known.
- a thread handle when a thread is created by calling the thread handle creation function of the system, a thread handle is obtained. Before the created thread is not exited, the thread handle is signalless. When the created thread finishes running, the thread handle becomes changed. It has a signal state.
- Resources include memory physical addresses, disk sectors, CPUs, and OS (Operating System) resources of the operating system, that is, hardware resources and software resources to be used during the running of the program.
- OS Operating System
- the hook function returns the thread handle value returned when the thread is created, the current thread corresponding to the handle creation function, and the thread ID of the current thread. Because the thread handle creation function CreateThread becomes the CreateThreadHook function, when the program calls the CreateThread function, it will enter the CreateThreadHook function, so through the CreateThreadHook function to get the thread handle value returned when the thread is created, the current thread corresponding to the handle creation function, and The thread ID of the current thread.
- the signal event creation function creates a signal event
- the hook event value returned by the signal event creation, the current thread corresponding to the signal event creation function, and the thread ID of the current thread are obtained through the hook function.
- the signal event creation function CreateEvent becomes the CreateEventHook function
- the program calls the CreateEvent function it will enter the CreateEventHook function, so that the signal event handle value and the signal event creation function corresponding to the signal event creation are obtained through the CreateEventHook function.
- the current thread and the thread ID of the current thread are obtained through the CreateEventHook function.
- the hook function returns the mutex handle value returned when the mutex is created, the current thread corresponding to the mutex creation function, and the thread ID of the current thread. Because the mutex creation function CreateMutex becomes the CreateMutexHook function, when the program calls the CreateMutex function, it will enter the CreateMutexHook function, and the CreateMutexHook function can be used to obtain the mutex handle value and mutex returned when the mutex is created. Create the current thread corresponding to the function and the thread ID of the current thread.
- the hook function value returned when the critical section is created, the current thread corresponding to the critical section creation function, and the thread ID of the current thread are obtained by the hook function.
- the critical section creation function InitializeCriticalSection becomes the InitializeCriticalSectionHook function
- the program calls the InitializeCriticalSection function it will enter the InitializeCriticalSectionHook function, thereby obtaining the critical section handle value and the critical section creation function returned when the critical section is created by the InitializeCriticalSectionHook function.
- the current thread and the thread ID of the current thread are examples of the critical section creation function.
- the hook function is also used to join the wait function WaitForSingleObject; when the wait function WaitForSingleObject is running, the hook function is used to get the resources waiting for the thread. At the same time, the information of the resources that the acquired thread waits for is stored in the global dictionary ResourceWaitDict.
- the resources owned by the thread and the resources waiting for are respectively belonged to the global field and the global dictionary, and are separately saved, so as to facilitate subsequent judgment on whether the program has a deadlock.
- thread A waits for a signal event created in thread B, and thread B depends on thread A to exit to set the signal event to a signal state, ie
- the owner thread of the resource waiting for the thread A is the thread B
- the owner thread of the resource waiting for the thread BA is the thread A. Therefore, the closed loop dependency between the threads is detected, and the program is deadlocked.
- the principle of a program deadlock detection method of the present invention lies in the method of injecting a hook function in a thread handle creation function, a signal event creation function, a mutex creation function, and a critical section creation function, when a thread handle creates a function, a signal
- the event creation function, the mutex creation function, and the critical section creation function respectively create threads, signal events, mutexes, and critical sections, respectively, the thread handle creation function, signal event creation function, and mutex creation are respectively obtained by the hook function.
- the current thread corresponding to the function and the critical section creation function and the thread ID of the current thread thereby quickly and conveniently acquiring the resources owned by the thread and the resources waiting, facilitating the timely judgment of the closed-loop dependency relationship between the threads, thereby obtaining the timely Know whether the program has a deadlock phenomenon, timely judgment, timely processing, and effectively ensure the orderly operation of the program.
- the present invention further provides a storage medium having a computer program stored thereon, and when the computer program is executed by the processor, the steps of the program deadlock detection method described in the above embodiments are implemented.
- the storage medium includes a U disk, a mobile hard disk, a ROM (Read-Only Memory), a RAM (Random Access Memory), a disk or an optical disk, and the like. The medium of the code.
- the present invention further provides a program deadlock detection apparatus, including a memory and a processor, wherein the memory stores a computer program running on the processor, and the processor executes the computer program.
- a program deadlock detection apparatus including a memory and a processor, wherein the memory stores a computer program running on the processor, and the processor executes the computer program.
- the program deadlock detection step of each of the above embodiments is implemented.
- the invention also discloses a program deadlock detection system based on the program deadlock detection method, which comprises an injection module, an acquisition module, a storage module and a determination module.
- the injection module is used to inject a hook function into the thread's thread handle creation function, the signal event creation function, the mutex creation function, and the critical section creation function;
- the acquisition module is used when the thread handle creation function, the signal event creation function, and the mutual
- the repulsion creation function or the critical section creation function respectively creates threads, signal events, mutexes, or critical sections, respectively, the thread handle creation function, the signal event creation function, the mutexe creation function, and the criticality are respectively obtained by the hook function.
- the current thread corresponding to the area creation function and the thread ID of the current thread is further configured to acquire the resource that the current thread waits;
- the storage module is configured to store the thread and the thread ID acquired by the acquiring module in the global field,
- the storage module is further configured to store the resources owned by the acquired thread in the global field;
- the determining module is configured to take two threads from the global field, if the resource waiting for the first thread is the second thread The resources owned, and the resource waiting for the second thread is the resource owned by the first thread, then Sequence deadlock occurs, and if not, then the deadlock does not occur.
- the resources include the physical address of the memory, the disk sector, the CPU, and the OS resources of the operating system.
- the injection module is also used to inject a hook function into the system's wait function WaitForSingleObject.
- WaitForSingleObject When the wait function WaitForSingleObject is running, the hook function acquires the resources that the thread waits for.
- the principle of a program deadlock detection system of the present invention is that the injection module injects a hook function into a thread handle creation function, a signal event creation function, a mutex creation function, and a critical section creation function, when a thread handle creation function,
- the signal event creation function, the mutex creation function, and the critical section creation function respectively acquire the thread handle creation function, the signal event creation function, and the mutex by the hook function when the thread, the signal event, the mutex, and the critical section are respectively created.
- Create the function and the current thread corresponding to the critical section creation function and the thread ID of the current thread thereby quickly and conveniently obtaining the resources owned by the thread and the resources waiting, so that the judgment module can timely judge the closed-loop dependency relationship between the threads. Therefore, it is timely to know whether the program has a deadlock imagination, and to obtain time for the subsequent program deadlock processing, and effectively ensure the orderly operation of the program.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
La présente invention, qui appartient au domaine des systèmes d'exploitation, concerne un procédé de détection d'interblocage de programmes, un support d'informations, un dispositif et un système. Le procédé comprend : S1 : l'ajout d'une fonction de crochet dans une fonction de création de poignée de fil, dans une fonction de création d'événement de signal, dans une fonction de création de mutex et dans une fonction de création de région critique d'un fil; S2 : l'obtention d'un fil actuel et d'un ID du fil actuel correspondant respectivement à la fonction de création de poignée de fil, à la fonction de création d'événement de signal, à la fonction de création de mutex et à la fonction de création de région critique au moyen de la fonction de crochet; S3 : le stockage du fil et de l'ID de fil obtenus et des ressources possédées par le fil obtenu dans un champ global; S4 : selon l'ID de fil dans le champ global, l'appel d'une fonction d'attente d'un système pour obtenir les ressources que chaque fil attend dans le champ global; S5 : la sélection de deux fils dans le champ global pour déterminer un interblocage. Selon la présente invention, l'interblocage d'un programme peut être efficacement détecté de manière opportune.
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201710528372.5A CN109213576B (zh) | 2017-07-01 | 2017-07-01 | 程序死锁检测方法、存储介质、设备及系统 |
| CN201710528372.5 | 2017-07-01 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2019006997A1 true WO2019006997A1 (fr) | 2019-01-10 |
Family
ID=64950581
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2017/117366 Ceased WO2019006997A1 (fr) | 2017-07-01 | 2017-12-20 | Procédé de détection d'interblocage de programmes, support d'informations, dispositif et système |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN109213576B (fr) |
| WO (1) | WO2019006997A1 (fr) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111767155A (zh) * | 2020-08-06 | 2020-10-13 | 腾讯科技(深圳)有限公司 | 死锁检测方法、装置、设备及计算机可读存储介质 |
| CN111858075A (zh) * | 2020-06-30 | 2020-10-30 | 广东浪潮大数据研究有限公司 | 一种死锁检测的方法、系统、设备及可读存储介质 |
| CN112199203A (zh) * | 2020-11-16 | 2021-01-08 | 奥士康科技股份有限公司 | 一种多表操作引起死锁的解决方法及系统 |
| CN114840847A (zh) * | 2021-02-02 | 2022-08-02 | 武汉斗鱼鱼乐网络科技有限公司 | 在目标进程中安全创建线程的方法、装置、介质及设备 |
Families Citing this family (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110837465A (zh) * | 2019-10-15 | 2020-02-25 | 珠海金山网络游戏科技有限公司 | 一种基于Android的句柄泄露检测方法及其系统 |
| CN111831557B (zh) * | 2020-06-19 | 2023-10-20 | 北京华三通信技术有限公司 | 死锁检测的方法及装置 |
| CN114035970B (zh) * | 2022-01-10 | 2022-04-22 | 南京云信达科技有限公司 | 一种数据并发竞争冲突检测分析方法及系统 |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103761182A (zh) * | 2013-12-26 | 2014-04-30 | 上海华为技术有限公司 | 一种死锁检测方法及装置 |
| JP2014119964A (ja) * | 2012-12-17 | 2014-06-30 | Hitachi Ltd | 計算機システムおよびプログラム |
| CN106681811A (zh) * | 2016-12-08 | 2017-05-17 | 腾讯科技(深圳)有限公司 | 基于线程池的多线程调度方法及装置 |
Family Cites Families (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102222015B (zh) * | 2010-04-13 | 2016-04-27 | 三星电子(中国)研发中心 | 检测多线程程序中的死锁的方法及系统 |
| CN102073588B (zh) * | 2010-12-28 | 2013-11-20 | 北京邮电大学 | 一种基于代码静态分析的多线程死锁检测方法及系统 |
| CN102567096B (zh) * | 2011-12-30 | 2017-02-08 | 中国科学院软件研究所 | 一种在多任务环境下防止死锁的互斥信号量管理方法 |
| CN103246552B (zh) * | 2012-02-14 | 2018-03-09 | 腾讯科技(深圳)有限公司 | 防止线程出现阻塞的方法和装置 |
| US9477576B2 (en) * | 2013-04-11 | 2016-10-25 | International Business Machines Corporation | Using application state data and additional code to resolve deadlocks |
| CN105511969B (zh) * | 2015-11-25 | 2020-05-19 | 中国船舶工业系统工程研究院 | 一种跨进程的线程间进行互斥的方法 |
-
2017
- 2017-07-01 CN CN201710528372.5A patent/CN109213576B/zh active Active
- 2017-12-20 WO PCT/CN2017/117366 patent/WO2019006997A1/fr not_active Ceased
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2014119964A (ja) * | 2012-12-17 | 2014-06-30 | Hitachi Ltd | 計算機システムおよびプログラム |
| CN103761182A (zh) * | 2013-12-26 | 2014-04-30 | 上海华为技术有限公司 | 一种死锁检测方法及装置 |
| CN106681811A (zh) * | 2016-12-08 | 2017-05-17 | 腾讯科技(深圳)有限公司 | 基于线程池的多线程调度方法及装置 |
Cited By (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111858075A (zh) * | 2020-06-30 | 2020-10-30 | 广东浪潮大数据研究有限公司 | 一种死锁检测的方法、系统、设备及可读存储介质 |
| CN111767155A (zh) * | 2020-08-06 | 2020-10-13 | 腾讯科技(深圳)有限公司 | 死锁检测方法、装置、设备及计算机可读存储介质 |
| CN112199203A (zh) * | 2020-11-16 | 2021-01-08 | 奥士康科技股份有限公司 | 一种多表操作引起死锁的解决方法及系统 |
| CN114840847A (zh) * | 2021-02-02 | 2022-08-02 | 武汉斗鱼鱼乐网络科技有限公司 | 在目标进程中安全创建线程的方法、装置、介质及设备 |
| CN114840847B (zh) * | 2021-02-02 | 2025-02-18 | 中曙云控数字科技(南通)有限公司 | 在目标进程中安全创建线程的方法、装置、介质及设备 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN109213576B (zh) | 2022-04-08 |
| CN109213576A (zh) | 2019-01-15 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2019006997A1 (fr) | Procédé de détection d'interblocage de programmes, support d'informations, dispositif et système | |
| US8176489B2 (en) | Use of rollback RCU with read-side modifications to RCU-protected data structures | |
| EP2972885B1 (fr) | Gestion de comptage de références d'objet mémoire avec évolutivité améliorée | |
| US8924655B2 (en) | In-kernel SRCU implementation with reduced OS jitter | |
| KR101835250B1 (ko) | 트랜잭셔널 메모리를 사용한 비인가 메모리 수정 및 액세스의 검출 | |
| US10915424B2 (en) | Defeating deadlocks in production software | |
| US8495638B2 (en) | Component-specific disclaimable locks | |
| KR101970390B1 (ko) | 2진 변환 기반 프로세서들에 의한 록 생략 | |
| RU2746155C2 (ru) | Уничтожение объекта на основе последовательности выполняемых действий | |
| CN102222015A (zh) | 检测多线程程序中的死锁的方法及系统 | |
| US8769546B2 (en) | Busy-wait time for threads | |
| US9207967B2 (en) | Using nonspeculative operations for lock elision | |
| US20150113233A1 (en) | Automatic Mutual Exclusion | |
| US8135690B2 (en) | Concurrency object classification | |
| CN101295266A (zh) | 检测和解除死锁的方法、装置和系统 | |
| CN111767155A (zh) | 死锁检测方法、装置、设备及计算机可读存储介质 | |
| CN111435314A (zh) | 一种不阻塞线程等待异步消息的方法、系统、服务器及存储介质 | |
| US8893137B2 (en) | Transaction-based shared memory protection for high availability environments | |
| WO2019047376A1 (fr) | Procédé et dispositif d'appel de tâches d'interface, dispositif électronique et support d'informations lisible | |
| US20160320984A1 (en) | Information processing device, parallel processing program and method for accessing shared memory | |
| US10983839B2 (en) | Method, apparatus, and electronic device for improving CPU performance | |
| US9928072B1 (en) | Detecting and recording atomic execution | |
| US9507817B2 (en) | Method for synchronizing access to shared resources of a computing system and detecting and eliminating deadlocks using lock files | |
| de Oliveira et al. | Nested locks in the lock implementation: The real-time read-write semaphores on linux | |
| KR101012669B1 (ko) | 불법적인 메모리 접근을 진단하는 악성 프로그램 탐지기 및그 제어방법 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 17917062 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 17917062 Country of ref document: EP Kind code of ref document: A1 |