CN104679645A - Method for detecting stack space allowance on real time - Google Patents

Method for detecting stack space allowance on real time Download PDF

Info

Publication number
CN104679645A
CN104679645A CN201310625924.6A CN201310625924A CN104679645A CN 104679645 A CN104679645 A CN 104679645A CN 201310625924 A CN201310625924 A CN 201310625924A CN 104679645 A CN104679645 A CN 104679645A
Authority
CN
China
Prior art keywords
stack
stack space
space
surplus
real
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.)
Pending
Application number
CN201310625924.6A
Other languages
Chinese (zh)
Inventor
谢娟
胡豪东
黄浩
陈挺
杨佳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
AVIATION POWER CONTROL SYSTEM RESEARCH INSTITUTE OF AVIATION INDUSTRY Corp OF CHINA
Original Assignee
AVIATION POWER CONTROL SYSTEM RESEARCH INSTITUTE OF AVIATION INDUSTRY Corp OF CHINA
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by AVIATION POWER CONTROL SYSTEM RESEARCH INSTITUTE OF AVIATION INDUSTRY Corp OF CHINA filed Critical AVIATION POWER CONTROL SYSTEM RESEARCH INSTITUTE OF AVIATION INDUSTRY Corp OF CHINA
Priority to CN201310625924.6A priority Critical patent/CN104679645A/en
Publication of CN104679645A publication Critical patent/CN104679645A/en
Pending legal-status Critical Current

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention provides a method for detecting stack space allowance on real time, and aims at solving the technical problems that most of the existing engine control software in domestic completely have one stack space which is shared by all tasks or interrupting processing operations, and the stack space and other data areas share the internal memory, thus stack overflowing caused by any function process can even damage the resource of the whole system and leads to the breakdown of the whole system. The method can detect the use condition of the stack space and whether the stack overflows, and the sue condition of the stack can be reported to the application software on real time; if the application software finds that the use of the stack exceeds the specified limit, corresponding measures can be carried out, and thus, the strength of the software can be improved.

Description

A kind of stack space surplus real-time detection method
Technical field
The present invention is used in engine control software running process or in control software design test process, stack space surplus detects in real time.
Background technology
In existing most domestic engine control software, whole software only has a stack space, all tasks or interrupt processing operation are all this stack spaces shared, and stack space and other data field are shared drives, the stack overflow that any one functional procedure causes so even can destroy the resource of whole system, thus causes the collapse of whole system.And stack overflow has lag-effect and implication widely, a procedural stack overflows can not cause the system failure at once, but it destroys the data of other data field, just can cause the system failure when running to the process of related data, or system crash.This has also manufactured difficulty to the location of fault.
Foreign Engine control software design adopts the timesharing partition operating system of ARINC653 standard mostly, and each subregion physical isolation, is not easy the serious consequence causing system crash, in limited technical information, also do not find stack detection method.Current domestic engine control software, in order to avoid stack overflow, general meeting first estimate stack space size by rule of thumb, then go to revise according to test feedback result, but the coverage rate of test all can not arrive 100%, namely there is the branch do not tested, then there is the possibility that stack overflow appears in the product stage.Therefore, adopting the real-time detection to stack space surplus, being conducive to the diagnosis to breaking down and location.
The domestic engine control software of current major part does not carry out stack space surplus and detects in real time; This method still belongs to the first time application at home.
Summary of the invention
The technical matters that the present invention will solve is to provide a kind of stack space surplus real-time detection method, can detect whether the service condition of stack space and stack overflow by the method, and in real time the service condition of stack is reported to application software, when application software finds that the use of stack exceedes set restriction, corresponding measure can be taked in time, so improve the robustness of software.
The invention provides a kind of stack space surplus real-time detection method, the method comprises the following steps:
The full content in the stack space region distributed also is initialized as the value of a non-zero by configuration stack space;
Stack space is distributed in the non-conterminous isolated area in internal memory;
The address access exception process function that register processor provides;
Create monitoring task call stack surplus detection function;
By monitoring host computer monitoring stack surplus and address access exception in real time, judge whether be about to or sent stack overflow.
In some embodiments of this stack space surplus real-time detection method, in step stack space being distributed in the non-conterminous isolated area in internal memory, the stack space distributed in previous step step is mapped in one section and the non-conterminous address space of other memory headroom by the page address translative mode of the memory management module that purpose processor is provided or block address translative mode.
In some embodiments of this stack space surplus real-time detection method, in the step of the address access exception process function that register processor provides, and the processor after the address access exception of stack being produced in this abnormality processing function is stored in the relevant informations such as the machine state of register are sent to PC implementing monitoring host computer by serial ports automatically.
In some embodiments of this stack space surplus real-time detection method, in described establishment monitoring task call stack surplus detection function step, create hook subfunction in described monitoring task, described Hook Function timing acquisition stack space surplus size, the stack space margin value got sends to the real-time monitoring host computer of PC by serial ports.
In the embodiment of stack space surplus real-time detection method adopting hook subfunction, the formula that stack space surplus calculates is realized by the check_Stack function in described Hook Function, and described check_Stack function comprises:
First time obtains stack space margin value, by the starting position being set at the bottom of stack search, stack top is set to the end position searched, the neutral element value of binary search compares with istackValue, if equal and to carry out former and later two value confirmations still equal, then continue to the search of stack top direction, otherwise to direction search at the bottom of stack;
After searching end, search end position posGetted deducts the value of position at the bottom of stack and is stack space free quantity, and stack space free quantity obtains stack space surplus divided by stack space total amount.
By stack surplus method of real-time provided by the invention, at stack space write particular value, there is the situation to particular value is modified namely can go on record, the stack space use amount that Current software is maximum can be monitored out at any time, so stack overflow or stack surplus is too little can by Timeliness coverage, the broken ring avoiding stack overflow to cause, and produce address access exception when stack overflow, the rear register information preserved can be produced according to abnormal: comprise analysis and the orientation problems such as machine status register(MSR), stack pointer register, data access register, address information register.The present invention, for model, provides truly feasible method for monitoring stack space service condition in control software design process of the test, provides diagnostic method for carrying out stack detection in software test procedure simultaneously.
Accompanying drawing illustrates:
Fig. 1 shows stack space overmeasure computation method
Fig. 2 shows stack space surplus detecting step
Fig. 3 shows stack surplus detection function check_Stack algorithm
Embodiment
This method is applied to engine control software, and the platform of this running software is powerpc8270 processor, below illustrates the specific implementation process of this method:
1) in the chained file of control software design for stack allocation space is 32K byte, stack top location is 0x08208000, position at the bottom of stack is 0x08200000, initialization stack pointer is stack top location, stack pointer accessing operation is 4 byte manipulations, according to step S1, at the bottom of from stack top to stack, 0x0E0E0E0E is initialized as to stack space.
2) according to step S2, allocate memory way to manage is block translative mode (i.e. BAT, arranged by BAT register and realize BAT, one has 8 data BAT registers, 8 data blocks can be set, the size of every block is 128K-256M byte),, initialization DBAT2 register, namely (size of this block is 128K to initialization block, the 32K stack space distributed is mapped 32K above), the start address of this block is 0x08200000, and the block address arranged with other BAT register is non-conterminous.When address is less than 0x08200000, trigger data address conversion loss abnormal (Data TLB Miss on Load/Store Exception).
3) according to step S3, mounting data address translation loses abnormality processing function, abnormality processing function realizes the real-time monitoring host computer abnormal register information preserved of data address conversion loss being sent to PC by serial ports, and these registers comprise the effective address that SRR0(causes next instruction of abnormal program point), SRR1(machine state holding register), MSR (machine status register(MSR)), SP(stack pointer).
4) according to step S4, call stack spatial margin detection function check_Stack in the Hook Function of 5ms task.Every 5ms calls stack space margin value that check_Stack returns returns to PC real-time monitoring host computer by serial ports.
5) according to step S5, real-time monitoring host computer arranges warning light when stack space surplus is less than 20%, and setting data address conversion loss abnormal signal lamp, designer or tester etc. can be monitored and immediate analysis stack space surplus or stack overflow in real time by the data of monitoring host computer display in real time and signal lamp.
By said process, the stack space surplus situation of Real-Time Monitoring engine control software can be realized, prevent stack overflow from destroying whole software, and the Real-Time Monitoring realized stack overflow, when there is stack overflow, trigger data address conversion loss is abnormal, loses Information locating and the analyzing failure cause of abnormal rear preservation by producing data address translation.

Claims (5)

1. a stack space surplus real-time detection method, is characterized in that, comprising:
The full content in the stack space region distributed also is initialized as the value of a non-zero by configuration stack space;
Stack space is distributed in the non-conterminous isolated area in internal memory;
The address access exception process function that register processor provides;
Create monitoring task call stack surplus detection function;
By monitoring host computer monitoring stack surplus and address access exception in real time, judge whether be about to or sent stack overflow.
2. stack space surplus real-time detection method as claimed in claim 1, is characterized in that:
Stack space is distributed in the step of the non-conterminous isolated area in internal memory described, the stack space distributed in previous step step is mapped in one section and the non-conterminous address space of other memory headroom by the page address translative mode of the memory management module that purpose processor is provided or block address translative mode.
3. a kind of stack space surplus real-time detection method as claimed in claim 1, is characterized in that:
In the step of the address access exception process function that described register processor provides, and the processor after the address access exception of stack being produced in this abnormality processing function is stored in the relevant informations such as the machine state of register are sent to PC implementing monitoring host computer by serial ports automatically.
4. a kind of stack space surplus real-time detection method as described in claim 1-3, is characterized in that:
In described establishment monitoring task call stack surplus detection function step, create hook subfunction in described monitoring task, described Hook Function timing acquisition stack space surplus size, the stack space margin value got sends to the real-time monitoring host computer of PC by serial ports.
5. a kind of stack space surplus real-time detection method as claimed in claim 5, is characterized in that, the formula that stack space surplus calculates is realized by the check_Stack function in described Hook Function, and described check_Stack function comprises:
First time obtains stack space margin value, by the starting position being set at the bottom of stack search, stack top is set to the end position searched, the neutral element value of binary search compares with istackValue, if equal and to carry out former and later two value confirmations still equal, then continue to the search of stack top direction, otherwise to direction search at the bottom of stack;
After searching end, search end position posGetted deducts the value of position at the bottom of stack and is stack space free quantity, and stack space free quantity obtains stack space surplus divided by stack space total amount.
CN201310625924.6A 2013-11-28 2013-11-28 Method for detecting stack space allowance on real time Pending CN104679645A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310625924.6A CN104679645A (en) 2013-11-28 2013-11-28 Method for detecting stack space allowance on real time

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310625924.6A CN104679645A (en) 2013-11-28 2013-11-28 Method for detecting stack space allowance on real time

Publications (1)

Publication Number Publication Date
CN104679645A true CN104679645A (en) 2015-06-03

Family

ID=53314727

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310625924.6A Pending CN104679645A (en) 2013-11-28 2013-11-28 Method for detecting stack space allowance on real time

Country Status (1)

Country Link
CN (1) CN104679645A (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105808424A (en) * 2016-02-04 2016-07-27 北京空间飞行器总体设计部 Method suitable for process stack use depth detection of multi-task software
CN106776354A (en) * 2016-11-11 2017-05-31 深圳创维数字技术有限公司 A kind of Dynamic stack EMS memory management process and device
CN107015904A (en) * 2016-01-28 2017-08-04 中兴通讯股份有限公司 The guard method of storehouse and device
CN107045605A (en) * 2016-02-05 2017-08-15 中兴通讯股份有限公司 A kind of real-time metrics method and device
CN107491373A (en) * 2017-08-09 2017-12-19 杭州迪普科技股份有限公司 A kind of task stack overflow monitoring method and system
CN107818034A (en) * 2016-09-14 2018-03-20 华为技术有限公司 The method and device of the running space of process in monitoring calculation machine equipment
WO2019001334A1 (en) * 2017-06-27 2019-01-03 阿里巴巴集团控股有限公司 Stack overflow processing method and device
CN112667460A (en) * 2020-12-07 2021-04-16 沈阳飞机设计研究所扬州协同创新研究院有限公司 Method for monitoring avionics system application task stack space
CN112948000A (en) * 2021-03-17 2021-06-11 星汉智能科技股份有限公司 Stack space statistical method, device and medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1564098A (en) * 2004-04-09 2005-01-12 南京大学 Dynamic stacking memory management method for preventing buffering area from overflow attacking
CN1851648A (en) * 2006-05-25 2006-10-25 浙江大学 Stack overflow protection method in operation for embedded system
CN101241464A (en) * 2007-02-05 2008-08-13 中兴通讯股份有限公司 Method for checking stack frame destruction

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1564098A (en) * 2004-04-09 2005-01-12 南京大学 Dynamic stacking memory management method for preventing buffering area from overflow attacking
CN1851648A (en) * 2006-05-25 2006-10-25 浙江大学 Stack overflow protection method in operation for embedded system
CN101241464A (en) * 2007-02-05 2008-08-13 中兴通讯股份有限公司 Method for checking stack frame destruction

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
逆风而飞: "《http://www.itpub.net/thread-1046263-1-1.html》", 28 August 2008 *

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107015904B (en) * 2016-01-28 2022-04-19 中兴通讯股份有限公司 Stack protection method and device
CN107015904A (en) * 2016-01-28 2017-08-04 中兴通讯股份有限公司 The guard method of storehouse and device
CN105808424B (en) * 2016-02-04 2018-08-07 北京空间飞行器总体设计部 A method of being suitable for multi-tasks Software process stacks and uses depth detection
CN105808424A (en) * 2016-02-04 2016-07-27 北京空间飞行器总体设计部 Method suitable for process stack use depth detection of multi-task software
CN107045605A (en) * 2016-02-05 2017-08-15 中兴通讯股份有限公司 A kind of real-time metrics method and device
CN107818034A (en) * 2016-09-14 2018-03-20 华为技术有限公司 The method and device of the running space of process in monitoring calculation machine equipment
CN107818034B (en) * 2016-09-14 2021-02-12 华为技术有限公司 Method and device for monitoring running space of process in computer equipment
CN106776354A (en) * 2016-11-11 2017-05-31 深圳创维数字技术有限公司 A kind of Dynamic stack EMS memory management process and device
WO2019001334A1 (en) * 2017-06-27 2019-01-03 阿里巴巴集团控股有限公司 Stack overflow processing method and device
CN107491373A (en) * 2017-08-09 2017-12-19 杭州迪普科技股份有限公司 A kind of task stack overflow monitoring method and system
CN112667460A (en) * 2020-12-07 2021-04-16 沈阳飞机设计研究所扬州协同创新研究院有限公司 Method for monitoring avionics system application task stack space
CN112948000A (en) * 2021-03-17 2021-06-11 星汉智能科技股份有限公司 Stack space statistical method, device and medium
CN112948000B (en) * 2021-03-17 2023-03-03 星汉智能科技股份有限公司 Stack space statistical method, device and medium

Similar Documents

Publication Publication Date Title
CN104679645A (en) Method for detecting stack space allowance on real time
CN103109276B (en) System detection method
CN101770551A (en) Method for processing hidden process based on hardware simulator
CN103106134B (en) A kind of performance deficiency detection method, device and system
CN104364769B (en) Run-time instrumentation monitoring of processor characteristics
CN107003899B (en) Interrupt response method, device and base station
CN102663312A (en) ROP attack detection method and system based on virtual machine
WO2009106451A4 (en) Managing use of storage by multiple pageable guests of a computing environment
CN101788949A (en) Method and device for realizing embedded type system function monitoring
CN104380264A (en) Run-time instrumentation reporting
CN110207784A (en) Transformer oil level alarm method, device and terminal device
CN102651062A (en) System and method for tracking malicious behavior based on virtual machine architecture
CN111625383B (en) Process exception event processing method and device, electronic equipment and storage medium
EP2996043B1 (en) Debugging in a data processing apparatus
CN109492406A (en) Monitor the methods, devices and systems of kernel loophole attack
US9176821B2 (en) Watchpoint support system for functional simulator
US20150161030A1 (en) Detecting method and system for concurrency bugs
CN101599113A (en) Driven malware defence method and device
CN102880467B (en) Cache coherence protocol verification method and multi-core processor system
US20180157605A1 (en) Configuration of a memory controller for copy-on-write
CN110727611B (en) Configurable consistency verification system with state monitoring function
US9195524B1 (en) Hardware support for performance analysis
CN106569961A (en) Access address continuity-based cache module and access method thereof
CN113687942B (en) Detection method and device and electronic equipment
CN105183668B (en) Cache flush method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20150603