KR20070056862A - Memory Structure and Memory Corruption Detection Method for Dynamic Memory Allocation of System Programs - Google Patents
Memory Structure and Memory Corruption Detection Method for Dynamic Memory Allocation of System Programs Download PDFInfo
- Publication number
- KR20070056862A KR20070056862A KR1020050116006A KR20050116006A KR20070056862A KR 20070056862 A KR20070056862 A KR 20070056862A KR 1020050116006 A KR1020050116006 A KR 1020050116006A KR 20050116006 A KR20050116006 A KR 20050116006A KR 20070056862 A KR20070056862 A KR 20070056862A
- Authority
- KR
- South Korea
- Prior art keywords
- memory
- value
- field
- changed
- program
- 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.)
- Withdrawn
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/0796—Safety measures, i.e. ensuring safe condition in the event of error, e.g. for controlling element
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
-
- 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/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5016—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Quality & Reliability (AREA)
- Techniques For Improving Reliability Of Storages (AREA)
Abstract
본 발명은 시스템 프로그램의 동적 메모리 할당을 위한 메모리 구조 및 메모리 훼손 검출방법에 관한 것으로, 프로그램의 메모리 할당 요청에 따라 메모리 훼손을 검출하기 위한 적어도 하나 이상의 특정값을 포함하는 헤더 필드부와, 실제 데이터를 저장하기 위한 실제 데이터 필드부와, 해당 메모리를 훼손한 프로그램 훼손정보를 포함하는 트레일러 필드로 구분되는 메모리 블록을 동적으로 할당하는 시스템 프로그램의 동적 메모리 할당을 위한 메모리 구조 및 메모리 훼손 검출방법에 관한 것이다.The present invention relates to a memory structure for dynamic memory allocation of a system program and a memory corruption detection method, comprising: a header field unit including at least one specific value for detecting memory corruption according to a memory allocation request of a program, and actual data; The present invention relates to a memory structure and a memory corruption detection method for dynamic memory allocation of a system program for dynamically allocating a memory block divided into a real data field unit for storing a data field and a trailer field including a program corruption information corrupting a corresponding memory. .
Description
도 1은 본 발명의 시스템 프로그램의 동적 메모리 할당을 위한 메모리 구조를 나타내는 도면.1 illustrates a memory structure for dynamic memory allocation of a system program of the present invention.
도 2는 본 발명에 따른 메모리 헤더(Header) 및 트레일러(Trailer)의 c style 데이터 구조를 나타내는 도면.2 illustrates a c style data structure of a memory header and a trailer according to the present invention.
도 3은 본 발명에 따른 시스템 프로그램의 동적 메모리 할당 과정을 나타내는 도면.3 is a diagram illustrating a dynamic memory allocation process of a system program according to the present invention.
도 4는 본 발명에 따른 시스템 프로그램의 동적 메모리 기입(Writing) 과정을 나타내는 도면.4 is a diagram illustrating a dynamic memory writing process of a system program according to the present invention.
도 5는 본 발명에 따른 시스템 프로그램의 동적 메모리 해제 과정을 나타내는 도면.5 is a diagram illustrating a dynamic memory releasing process of a system program according to the present invention.
* 도면의 주요 부분에 대한 부호의 설명 *Explanation of symbols on the main parts of the drawings
10 : 헤더 필드 11 : next 필드10: header field 11: field next
12 : prev 필드 13 : size 필드12: prev field 13: size field
14 : cookie 필드 15 : preguard[] 필드14: cookie field 15: preguard [] field
20 : 실제 데이터 필드 30 : 트레일러 필드20: real data field 30: trailer field
31 : postguard[] 필드 32 : filename 필드31: postguard [] field 32: filename field
33 : linenum 필드 34 : taskid 필드33: linenum field 34: taskid field
본 발명은 시스템 프로그램의 동적 메모리 할당을 위한 메모리 구조 및 메모리 훼손 검출방법에 관한 것이다.The present invention relates to a memory structure and a memory corruption detection method for dynamic memory allocation of a system program.
일반적으로 MCU(Micro controller unit) 등과 같은 시스템 보드에서 동작하는 S/W application들은 메모리(RAM)에 로딩되어 실행되면서 동작 중에 필요한 메모리를 동적으로 할당 받아서 사용하고, 사용이 완료되면 할당받은 메모리를 해당 시스템으로 반환하는 동작을 반복하게 된다.In general, S / W applications that operate on system boards such as microcontroller units (MCUs) are loaded and executed in memory (RAM) to dynamically allocate and use the necessary memory during operation. It will repeat the operation returned to the system.
이와 같은 메모리의 할당, 사용 그리고 해제를 반복하는 과정에서 프로그래머의 실수로 인해 자신이 할당받지 않은 메모리 영역을 사용하는 경우, 메모리를 훼손하게 됨으로써 결국 해당 시스템이 다운되는 결과를 초래하게 된다.In the process of repeatedly allocating, using, and releasing memory, if a programmer's mistake uses a memory area that is not allocated to the memory, the memory is damaged, resulting in a system crash.
즉, 종래에는 메모리 훼손에 대한 완충장치가 없어서 동작 중인 프로그램의 임의의 타스크(Task)에서 메모리 훼손이 발생하게 되면 해당 시스템이 다운되어 정 상 동작하지 않는 현상이 발생하였다. 또한, 이러한 경우에 어느 타스크(Task)에서 메모리를 훼손하였는지 발견하는 것 또한 쉽지 않았다.That is, conventionally, when a memory corruption occurs in an arbitrary task of a running program because there is no buffer for memory corruption, the system is down and does not operate normally. In this case, it was also difficult to find out which task corrupted the memory.
여기서, 타스크(Task)란 시스템 보드의 실시간 운영체제(Real Time Operating System: RTOS) 상에서 동작되는 프로그램 중 각기 다른 기능을 수행하는 프로세서 모듈을 의미하는 것으로, 이와 같이 타스크(Task)에서 할당받은 메모리 경계를 넘어서 메모리를 사용하여 메모리 훼손이 발생이 되면 시스템이 정상적으로 동작하지 않게 되며, 메모리 훼손이 되었을 때 어느 타스크, 어느 부분에서 메모리 훼손이 발생되었는지 발견하기가 어렵다는 문제점이 있었다.Here, a task refers to a processor module that performs different functions among programs operated on a real time operating system (RTOS) of a system board. As described above, a task refers to a memory boundary allocated by the task. In addition, when memory corruption occurs using memory, the system does not operate normally, and when a memory corruption occurs, it is difficult to find out which task and which portion of the memory corruption have occurred.
따라서, 본 발명의 목적은 상기와 같은 문제점을 해결하기 위한 것으로서, 시스템을 다운시키는 혹은 비정상 동작시키는 메모리 훼손을 최대한 방지하고, 이러한 메모리 훼손이 발생하였을 경우 어느 타스크의 어느 부분에서 메모리 훼손이 발생하였는지를 찾을 수 있도록 한 시스템 프로그램의 동적 메모리 할당을 위한 메모리 구조 및 메모리 훼손 검출방법을 제공함에 있다.Accordingly, an object of the present invention is to solve the above problems, and to prevent the memory corruption that causes the system to crash or operate abnormally to the maximum, and when such memory corruption occurs, in which part of the task the memory corruption occurs. The present invention provides a memory structure and a memory corruption detection method for dynamic memory allocation of a system program.
상기한 목적을 달성하기 위한 본 발명에 따른 동적 메모리 할당 시스템의 일 측면에 따르면, 프로그램의 메모리 할당 요청에 따라 메모리 훼손을 검출하기 위한 적어도 하나 이상의 특정값을 포함하는 헤더 필드부와, 실제 데이터를 저장하기 위 한 실제 데이터 필드부와, 해당 메모리를 훼손한 프로그램 훼손정보를 포함하는 트레일러 필드로 구분되는 메모리 블록을 동적으로 할당하는 메모리 할당모듈을 포함한다.According to an aspect of the dynamic memory allocation system according to the present invention for achieving the above object, a header field portion including at least one specific value for detecting memory corruption in response to a memory allocation request of a program, and actual data And a memory allocation module for dynamically allocating a memory block divided into a real data field unit for storing and a trailer field including program damage information corrupting the corresponding memory.
상기 헤더 필드부는, 현재 사용중인 메모리 블록의 이전 메모리 블록을 가리키는 포인터 정보가 설정되는 prev 필드부와, 현재 사용중인 메모리 블록의 다음 메모리 블록을 가리키는 포인터 정보가 설정되는 next 필드부와, 상기 실제 데이터 필드부에 기입할 수 있는 데이터 최대 크기 정보가 설정되는 size 필드부와, 상기 할당된 메모리 블록의 메모리 훼손 및 메모리 인증을 검사하기 위한 cookie 값이 설정되는 cookie 필드부 및 상기 할당된 메모리 블록의 메모리 훼손을 검출하기 위한 preguard 값이 설정되는 preguard[] 필드부로 이루어진다.The header field unit may include: a prev field unit in which pointer information indicating a previous memory block of a currently used memory block is set; a next field unit in which pointer information indicating a next memory block of a currently used memory block is set; and the actual data A size field unit for setting maximum size information of data that can be written to the field unit, a cookie field unit for setting a cookie value for checking memory corruption and memory authentication of the allocated memory block, and a memory of the allocated memory block It consists of a preguard [] field where the preguard value for detecting corruption is set.
상기 cookie 필드부에 설정된 cookie 값은 고정된 값을 갖는다.The cookie value set in the cookie field part has a fixed value.
상기 트레일러 필드부는, 상기 할당된 메모리 블록의 메모리 훼손을 검출하기 위한 postguard 값이 설정되는 postguard[] 필드부와, 상기 메모리 훼손을 발생시킨 해당 프로그램의 파일 네임(filename)이 설정되는 filename 필드부와, 상기 메모리 훼손을 발생시킨 해당 프로그램의 라인 번호(linenum)가 설정되는 linenum 필드부 및 메모리 훼손을 발생시킨 해당 프로그램의 타스크 ID(taskid)가 설정되는 taskid 필드부로 이루어진다.The trailer field unit may include a postguard [] field unit in which a postguard value for detecting memory corruption of the allocated memory block is set, a filename field unit in which a file name of a corresponding program that causes the memory corruption is set; And a linenum field portion for setting a linenum of the corresponding program that caused the memory corruption, and a taskid field portion for setting a task ID of the corresponding program for causing the memory corruption.
상기 preguard[] 필드부에 설정된 preguard 값과 상기 postguard[] 필드부에 설정된 postguard 값은 동일한 값을 갖는다.The preguard value set in the preguard [] field portion and the postguard value set in the postguard [] field portion have the same value.
한편, 상기한 목적을 달성하기 위한 본 발명에 따른 프로그램의 동적 메모리 할당 방법의 일 측면에 따르면, 프로그램의 메모리 할당 요청에 따라 할당된 메모리 블록 헤더의 preguard 값과 cookie 값을 설정하는 단계와, 상기 메모리 블록 트레일러의 postguard 값을 상기 헤더의 preguard 값과 동일한 값으로 설정하는 단계와, 상기 메모리 할당을 요청한 프로그램의 file name, line number, task id를 상기 트레일러의 해당 필드에 각각 설정하는 단계 및 상기 할당된 메모리 블록의 실제 데이터 필드의 시작 주소를 리턴받는 단계로 이루어진다.On the other hand, according to one aspect of the dynamic memory allocation method of the program according to the present invention for achieving the above object, setting the preguard value and cookie value of the allocated memory block header according to the memory allocation request of the program, and Setting the postguard value of the memory block trailer to the same value as the preguard value of the header, setting the file name, line number, and task id of the program requesting the memory allocation to the corresponding fields of the trailer, respectively; And returning the start address of the actual data field of the memory block.
한편, 상기한 목적을 달성하기 위한 본 발명에 따른 프로그램의 동적 메모리 기입 방법의 일 측면에 따르면, 프로그램의 메모리 할당 요청에 따라 할당된 메모리 블록 헤더의 cookie 필드에 설정된 값이 변경되었는지 체크하는 단계와, 상기 cookie 필드에 설정된 값이 변경되지 않은 경우, 상기 메모리 블록의 실제 데이터 필드의 시작 주소를 참조하여 해당 데이터 기입(Writing)을 시작하는 단계와, 상기 메모리 블록 헤더의 size 필드에 설정된 값에 따라 상기 메모리 블록의 실제 데이터 필드에 기입된 데이터가 할당된 영역을 초과하여 기입되었는지 체크하는 단계와, 상기 실제 데이터 필드에 기입된 데이터가 할당된 영역을 초과하여 기입되지 않은 경우, 동일한 값으로 설정된 상기 메모리 블록 트레일러의 preguard 값과 postguard 값이 변경되었는지 체크하는 단계 및 상기 preguard 값과 postguard 값이 변경되지 않은 경우, 상기 실제 데이터 필드의 해당 데이터 기입을 정상적으로 종료하는 단계로 이루어진다.Meanwhile, according to an aspect of a dynamic memory writing method of a program according to the present invention for achieving the above object, a step of checking whether a value set in a cookie field of a memory block header allocated according to a memory allocation request of a program is changed; Starting writing of the data by referring to the start address of the actual data field of the memory block when the value set in the cookie field is not changed; and according to the value set in the size field of the memory block header. Checking whether data written in an actual data field of the memory block has been written over an allocated area; and if data written in the actual data field has not been written over an allocated area, the value set to the same value; To check if the preguard and postguard values of the memory block trailer have changed And if the preguard value and the postguard value have not been changed, terminating the corresponding data writing of the actual data field normally.
상기 cookie 필드에 설정된 값이 변경된 경우, 해당 프로그램의 filename, linenum, taskid를 리턴하여 메모리 훼손이 발생한 부분을 알려주는 단계를 더 포함한다.If the value set in the cookie field is changed, the method further includes the step of returning filename, linenum, and taskid of the corresponding program to indicate a portion of memory corruption.
상기 실제 데이터 필드에 기입된 데이터가 할당된 영역을 초과하여 기입된 경우, 해당 프로그램의 filename, linenum, taskid를 리턴하여 메모리 훼손이 발생한 부분을 알려주는 단계를 더 포함한다.If the data written in the actual data field exceeds the allocated area, the method may further include notifying a part of the memory corruption by returning the filename, linenum, and taskid of the corresponding program.
상기 preguard 값과 postguard 값이 변경된 경우, 해당 프로그램의 filename, linenum, taskid를 리턴하여 메모리 훼손이 발생한 부분을 알려주는 단계를 더 포함한다.When the preguard value and the postguard value are changed, the method may further include informing the part of the memory corruption by returning the filename, linenum, and taskid of the corresponding program.
한편, 상기한 목적을 달성하기 위한 본 발명에 따른 프로그램의 동적 메모리 해제 방법의 일 측면에 따르면, 프로그램의 메모리 해제 요청에 따라 해당 메모리 블록 헤더의 cookie 필드에 설정된 값이 변경되었는지 체크하는 단계와, 상기 cookie 필드에 설정된 값이 변경되지 않은 경우, 상기 메모리 블록 헤더의 preguard 값이 변경되었는지 체크하는 단계와, 상기 preguard 값이 변경되지 않은 경우 상기 메모리 블록 트레일러의 postguard 값이 변경되었는지 체크하는 단계 및 상기 postguard 값이 변경되지 않은 경우, 해당 메모리 블록을 해제하는 단계로 이루어진다.On the other hand, according to an aspect of the dynamic memory release method of the program according to the present invention for achieving the above object, the step of checking whether the value set in the cookie field of the corresponding memory block header in response to the memory release request of the program, and If the value set in the cookie field has not changed, checking whether a preguard value of the memory block header has changed, and if the preguard value has not changed, checking whether a postguard value of the memory block trailer has changed; If the postguard value hasn't changed, then it frees the memory block.
상기 cookie 필드에 설정된 값이 변경된 경우, 해당 프로그램의 filename, linenum, taskid를 리턴하여 메모리 훼손이 발생한 부분을 알려주는 단계를 더 포 함한다.If the value set in the cookie field is changed, the method further includes the step of returning filename, linenum, and taskid of the corresponding program to indicate a portion of memory corruption.
상기 preguard 값이 변경된 경우, 해당 프로그램의 filename, linenum, taskid를 리턴하여 메모리 훼손이 발생한 부분을 알려주는 단계를 더 포함한다.If the preguard value is changed, the method may further include informing a part of the memory corruption by returning a filename, linenum, and taskid of the corresponding program.
상기 postguard 값이 변경된 경우, 해당 프로그램의 filename, linenum, taskid를 리턴하여 메모리 훼손이 발생한 부분을 알려주는 단계를 더 포함한다.If the postguard value is changed, the method may further include informing a part of memory corruption by returning a filename, linenum, and taskid of the corresponding program.
이하, 본 발명의 바람직한 실시예의 상세한 설명이 첨부된 도면들을 참조하여 설명될 것이다. 도면들 중 참조번호들 및 동일한 구성요소들에 대해서는 비록 다른 도면상에 표시되더라도 가능한 한 동일한 참조번호들 및 부호들로 나타내고 있음에 유의해야 한다. 하기에서 본 발명을 설명함에 있어, 관련된 공지 기능 또는 구성에 대한 구체적인 설명이 본 발명의 요지를 불필요하게 흐릴 수 있다고 판단되는 경우에는 그 상세한 설명을 생략한다.DESCRIPTION OF THE PREFERRED EMBODIMENTS Hereinafter, detailed descriptions of preferred embodiments of the present invention will be described with reference to the accompanying drawings. It should be noted that reference numerals and like elements among the drawings are denoted by the same reference numerals and symbols as much as possible even though they are shown in different drawings. In the following description of the present invention, if it is determined that a detailed description of a related known function or configuration may unnecessarily obscure the subject matter of the present invention, the detailed description thereof will be omitted.
도 1은 본 발명의 시스템 프로그램의 동적 메모리 할당을 위한 메모리 구조를 나타내는 도면이고, 도 2는 본 발명에 따른 메모리 헤더(Header) 및 트레일러(Trailer)의 c style 데이터 구조를 나타내는 도면이다.1 is a diagram illustrating a memory structure for dynamic memory allocation of a system program of the present invention, and FIG. 2 is a diagram illustrating a c style data structure of a memory header and a trailer according to the present invention.
도 1에 도시된 바와 같이, 시스템 프로그램의 동적 메모리 할당을 위한 메모리 블록은 헤더(Header) 필드(10)와, 실제 데이터 필드(20)와, 트레일러(Trailer) 필드(30)로 구분되어진다.As shown in FIG. 1, a memory block for dynamic memory allocation of a system program is divided into a
즉, 시스템 보드의 RTOS 상에서 동작하는 프로그램은 도 1과 같은 구조의 메 모리를 할당받게 되며, 메모리 할당을 요청한 프로그램은 실제 사용할 실제 데이터의 시작 주소를 받아서 메모리를 사용할 수 있게 된다.That is, a program running on the RTOS of the system board is allocated the memory of the structure as shown in FIG. 1, and the program requesting the memory allocation receives the start address of the actual data to be used and can use the memory.
여기서, 헤더(Header) 필드(10)는 next 필드(11)와, prev 필드(12)와, size 필드(13)와, cookie 필드(14)와, preguard[] 필드(15)로 구분된다.Here, the
next 필드(11)에는 메모리 할당을 위한 다수개의 메모리 블록 중 현재 사용중인 메모리 블록을 기준으로 다음 메모리 블록을 가리키는 포인터가 저장된다.The
prev 필드(12)에는 메모리 할당을 위한 다수개의 메모리 블록 중 현재 사용중인 메모리 블록을 기준으로 이전 메모리 블록을 가리키는 포인터가 저장된다.The
size 필드(13)에는 상기 실제 데이터 필드(20)에 기입(Writing)할 수 있는 실제 데이터의 최대 크기 정보가 저장된다.The
cookie 필드(14)는 헤더쪽의 메모리 훼손 및 메모리 인증(memory authentication)을 검사하는 용도로 사용되며, 고정된 cookie 값이 설정된다.The
예를 들어, cookie 필드(14)에는 "OxAECB" 와 같은 고정된 cookie 값으로 설정되며, 시스템 프로그램이 동적으로 메모리를 할당받은 후, 메모리를 사용하거나 메모리를 사용한 다음 해제하는 과정에서 상기 고정된 cookie 값의 변경 여부에 따라 메모리 훼손 여부를 체크할 수 있게 된다.For example, the
즉, cookie 필드(14)의 고정된 cookie 값이 변경된 경우에는 메모리 기입(Writing)이나 해제를 할 수 없게 되며, 메모리 할당을 요청한 해당 프로그램의 filename, linenum, taskid를 리턴하게 된다.That is, when the fixed cookie value of the
preguard[] 필드(15)에는 시스템 보드에서 동작하는 특정 프로그램의 메모리 할당 요청에 따라 메모리 할당시 특정 preguard 값이 설정된다. 예를 들어, "OxCAFE" 와 같은 특정값으로 설정되며, 시스템 프로그램이 동적으로 메모리를 할당받은 후, 메모리를 사용하거나 메모리를 사용한 다음 해제하는 과정에서 상기 설정된 특정값의 변경 여부에 따라 메모리 훼손 여부를 체크할 수 있게 된다.The preguard []
즉, preguard[] 필드(15)에 설정된 특정값이 변경된 경우에는 메모리 기입(Writing)이나 해제를 할 수 없게 되며, 메모리 할당을 요청한 해당 프로그램의 filename, linenum, taskid를 리턴하게 된다.That is, when a specific value set in the preguard []
한편, 트레일러(Trailer) 필드(30)는 postguard[] 필드(31)와, filename 필드(32)와, linenum 필드(33)와, taskid 필드(34)로 구분되어진다.The
postguard[] 필드(31)에는 시스템 보드에서 동작하는 특정 프로그램의 메모리 할당 요청에 따라 메모리 할당시 특정값이 설정된다. 여기서, 특정값은 상기 헤더(Header) 필드(10)의 preguard[] 필드(15)에 설정된 특정값과 동일한 값으로 설정된다.The postguard []
예를 들어, "OxCAFE" 와 같은 특정값으로 설정되며, 시스템 프로그램이 동적으로 메모리를 할당받은 후, 메모리를 사용하거나 메모리를 사용한 다음 해제하는 과정에서 상기 설정된 특정값의 변경 여부에 따라 메모리 훼손 여부를 체크할 수 있게 된다.For example, it is set to a specific value such as "OxCAFE", and the memory is damaged depending on whether the specific value is changed in the process of using the memory after the system program is dynamically allocated the memory or using the memory. Can be checked.
즉, postguard[] 필드(31)에 설정된 특정값이 변경된 경우에는 메모리 기입(Writing)이나 해제를 할 수 없게 되며, 메모리 할당을 요청한 해당 프로그램의 filename, linenum, taskid를 리턴하게 된다.In other words, when a specific value set in the postguard []
filename 필드(32)와, linenum 필드(33) 및 taskid 필드(34)에는 현재 메모리 할당을 요청한 프로그램의 file name, line number와 task id 가 각 필드에 설정된다.In the
특히, 이와 같은 트레일러(Trailer) 필드(30)의 filename 필드(32)와, linenum 필드(33)와, taskid 필드(34)는 메모리 훼손이 발생하였을 때 어느 부분에서 어느 타스크(Task)가 훼손을 하였는지 발견하는데 이용을 하게 된다.In particular, the
이상과 같이 설명한 메모리 헤더(Header) 및 트레일러(Trailer)의 c style 데이터 구조는 도 2와 같은 구조를 갖는다.The c style data structure of the memory header and the trailer described above has the structure shown in FIG. 2.
도 3은 본 발명에 따른 시스템 프로그램의 동적 메모리 할당 과정을 나타내는 도면이다.3 is a diagram illustrating a dynamic memory allocation process of a system program according to the present invention.
도 3에 도시된 바와 같이, 시스템 보드의 RTOS 상에서 동작하는 프로그램의 메모리 할당 요청에 따라 헤더(Header)와, 실제 데이터와, 트레일러(Trailer) 필드로 구분되는 메모리 블록을 할당하게 된다.As shown in FIG. 3, a memory block divided into a header, actual data, and a trailer field is allocated according to a memory allocation request of a program running on an RTOS of a system board.
즉, 메모리 할당시 먼저 헤더(Header)의 preguard 값을 특정값으로 설정(S10)한다. 예를 들어, "OxCAFE" 와 같은 특정값으로 설정된다.That is, when allocating memory, first, the preguard value of the header is set to a specific value (S10). For example, it is set to a specific value such as "OxCAFE".
이어서, 헤더(Header)의 cookie값을 특정값으로 설정(S20)한다. 예를 들어, "OxAECB" 와 같은 특정값으로 설정하며 이때 설정되는 특정값은 고정된 값을 갖게 된다.Next, the cookie value of the header is set to a specific value (S20). For example, it is set to a specific value such as "OxAECB" and the specific value set at this time has a fixed value.
이어서, 트레일러(Trailer)의 postguard 값을 헤더(Header)의 preguard 값과 동일한 값으로 설정(S30)한다. 예를 들어, "OxCAFE" 와 같은 특정값으로 설정된다.Subsequently, the postguard value of the trailer is set to the same value as the preguard value of the header (S30). For example, it is set to a specific value such as "OxCAFE".
이어서, 현재 메모리 할당을 요청한 프로그램의 file name, line number, task id를 트레일러(Trailer)의 filename 필드와, linenum 필드 및 taskid 필드에 각각 설정(S40)한다.Subsequently, the file name, line number, and task id of the program that has currently requested memory allocation are set in the filename field, the linenum field, and the taskid field of the trailer (S40), respectively.
이어서, 메모리 할당을 요청한 프로그램은 해당 메모리를 사용하기 위해 실제 사용할 실제 데이터 필드의 시작 주소를 리턴(S50)받게 된다.Subsequently, the program requesting the memory allocation is returned (S50) with the start address of the actual data field actually used to use the memory.
도 4는 본 발명에 따른 시스템 프로그램의 동적 메모리 기입(Writing) 과정을 나타내는 도면이다.4 is a diagram illustrating a dynamic memory writing process of a system program according to the present invention.
도 4에 도시된 바와 같이, 메모리 할당을 요청한 프로그램이 해당 메모리를 사용하기 위해 실제 사용할 실제 데이터 필드의 시작 주소를 리턴받게 되면 먼저, 헤더(Header)의 cookie 필드에 설정된 고정값이 변경되었는지를 체크(S10)한다.As shown in FIG. 4, when a program requesting a memory allocation receives a start address of an actual data field to be actually used to use a corresponding memory, first, it is checked whether a fixed value set in a cookie field of a header is changed. (S10).
체크 결과, 만약 cookie 필드에 설정된 고정값이 변경되지 않은 경우에는 포인터가 가리키고 있는 실제 데이터 필드의 시작 주소를 참조하여 실제 메모리에 데이터를 기입(Writing)(S20)하게 된다.As a result of the check, if the fixed value set in the cookie field is not changed, data is written to the real memory by referring to the start address of the actual data field indicated by the pointer (W 20).
이어서, 헤더(Header)의 size 필드에 설정된 실제 데이터의 최대값 정보를 기준으로 하여 실제 데이터 영역에 기입한 데이터가 해당 메모리 영역의 경계를 초과하여 기입되었는지를 체크(S30)한다.Subsequently, it is checked whether data written in the actual data area is written beyond the boundary of the memory area based on the maximum value information of the actual data set in the size field of the header (S30).
체크 결과, 실제 데이터 영역에 기입한 데이터가 해당 메모리 영역의 경계를 초과하여 기입되지 않은 경우에는 동일한 값으로 설정된 preguard 값이나 postguard 값이 변경되었는지를 체크(S40)한다.As a result of the check, if the data written in the actual data area is not written beyond the boundary of the memory area, it is checked whether the preguard value or the postguard value set to the same value is changed (S40).
체크 결과, 동일한 값으로 설정된 preguard 값이나 postguard 값이 변경되지 않은 경우에는 할당받은 실제 메모리 영역에 해당 데이터를 정상적으로 기입(S50)하게 된다.As a result of the check, if the preguard value or the postguard value set to the same value is not changed, the corresponding data is normally written to the allocated real memory area (S50).
그러나, 상기 S10 과정에서 만약 고정된 cookie 값이 변경된 경우 또는, 상기 S30 과정에서 실제 데이터 영역에 기입한 데이터가 해당 메모리 영역의 경계를 초과하여 기입된 경우 또는, 상기 S40 과정에서 동일한 값으로 설정된 preguard 값이나 postguard 값이 사용자 옵션(user option)에 의해 변경된 경우에는 메모리가 훼손된 경우이므로 프로그램이 할당받은 메모리에 해당 데이터를 기입(Writing)할 수 없게 된다.However, if the fixed cookie value is changed in step S10 or if the data written in the actual data area is written beyond the boundary of the corresponding memory area in step S30, or is set to the same value in step S40 If the value or postguard value is changed by the user option, the memory is corrupted and the program cannot write the data to the allocated memory.
이에 따라, 메모리 할당을 요청한 해당 프로그램의 filename, linenum, taskid를 리턴(S60)하여 메모리 훼손이 발생한 부분을 알려줌으로써, 메모리 훼손 관련 디버깅을 용이하게 할 수 있게 된다.Accordingly, by returning the filename, linenum, and taskid of the corresponding program requesting the memory allocation (S60), the memory corruption may be reported, thereby facilitating debugging related to memory corruption.
도 5는 본 발명에 따른 시스템 프로그램의 동적 메모리 해제 과정을 나타내는 도면이다.5 is a diagram illustrating a dynamic memory releasing process of a system program according to the present invention.
도 5에 도시된 바와 같이, 프로그램이 할당된 메모리를 사용한 후에는 해당 메모리를 해제하기 위하여 먼저 헤더(Header)의 고정된 cookie 값이 변경되었는지를 체크(S10)한다.As shown in FIG. 5, after the program uses the allocated memory, it is first checked whether the fixed cookie value of the header is changed in order to release the memory (S10).
체크 결과, 만약 cookie 필드에 설정된 고정값이 변경되지 않은 경우에는 헤 더(Header)의 preguard 값이 변경되었는지를 체크(S20)한다.As a result of the check, if the fixed value set in the cookie field is not changed, it is checked whether the header preguard value has changed (S20).
체크 결과, 만약 헤더(Header)의 preguard 값이 변경되지 않은 경우에는 트레일러(Trailer)의 postguard 값이 변경되었는지를 연이어 체크(S30)한다.As a result of the check, if the preguard value of the header has not been changed, it is successively checked whether the postguard value of the trailer has changed (S30).
이어서, 트레일러(Trailer)의 postguard 값이 변경되지 않은 경우에는 해당 메모리를 해제하여 할당받은 메모리 블록 중에서 프리 블록(free block)으로 이동(S40)하게 된다.Subsequently, when the postguard value of the trailer is not changed, the corresponding memory is released and moved to a free block among the allocated memory blocks (S40).
그러나, 상기 S10 과정에서 만약 고정된 cookie 값이 변경된 경우 또는, 상기 S20 과정에서 헤더(Header)의 preguard 값이 변경된 경우 또는, 상기 S30 과정에서 트레일러(Trailer)의 postguard 값이 변경된 경우에는 메모리가 훼손된 경우이므로 프로그램이 사용한 메모리를 해제할 수 없게 된다.However, if the fixed cookie value is changed in step S10, the preguard value of the header is changed in step S20, or the postguard value of the trailer is changed in step S30, the memory is corrupted. In this case, the memory used by the program cannot be released.
이에 따라, 해당 프로그램의 filename, linenum, taskid를 리턴(S50)하여 메모리 훼손이 발생한 부분을 알려줌으로써, 메모리 훼손 관련 디버깅을 용이하게 할 수 있게 된다.Accordingly, by returning the filename, linenum, and taskid of the corresponding program (S50) to inform the part where the memory corruption has occurred, debugging of the memory corruption can be facilitated.
이상에서는 본 발명에서 특정의 바람직한 실시예에 대하여 도시하고 또한 설명하였다. 그러나, 본 발명은 상술한 실시예에 한정되지 아니하며, 특허 청구의 범위에서 첨부하는 본 발명의 요지를 벗어남이 없이 당해 발명이 속하는 기술분야에서 통상의 지식을 가진 자라면 누구든지 다양한 변형 실시가 가능할 것이다.In the above, specific preferred embodiments of the present invention have been illustrated and described. However, the present invention is not limited to the above-described embodiment, and various modifications can be made by any person having ordinary skill in the art without departing from the gist of the present invention attached to the claims. will be.
본 발명에 따르면, 시스템 보드의 RTOS 상에서 동작하는 프로그램의 메모리 훼손을 미리 검사하고, 메모리 훼손 정도에 따라 시스템에 영향을 주지 않는 정도의 메모리 훼손은 무시함으로써, 시스템의 안정성 향상을 가져오게 되며, 메모리 훼손이 발생한 경우 메모리 훼손 부분을 쉽게 발견할 수 있게 되어 각 보드의 프로그램을 개발하는 개발기간을 단축시키게 되는 효과가 있다.According to the present invention, by examining the memory corruption of the program running on the RTOS of the system board in advance, and ignoring the memory corruption that does not affect the system according to the degree of memory corruption, the stability of the system is improved, and the memory In the event of corruption, the memory corruption can be easily found, which shortens the development time for developing a program for each board.
또한, 운용중인 시스템의 메모리 훼손 문제가 발생하였을 경우 메모리 훼손 관련 디버깅을 용이하게 함으로써, 시스템의 유지 보수 비용을 절감시키게 되는 효과가 있다.In addition, when a memory corruption problem occurs in a running system, memory corruption related debugging is facilitated, thereby reducing the maintenance cost of the system.
Claims (14)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| KR1020050116006A KR20070056862A (en) | 2005-11-30 | 2005-11-30 | Memory Structure and Memory Corruption Detection Method for Dynamic Memory Allocation of System Programs |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| KR1020050116006A KR20070056862A (en) | 2005-11-30 | 2005-11-30 | Memory Structure and Memory Corruption Detection Method for Dynamic Memory Allocation of System Programs |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| KR20070056862A true KR20070056862A (en) | 2007-06-04 |
Family
ID=38354562
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| KR1020050116006A Withdrawn KR20070056862A (en) | 2005-11-30 | 2005-11-30 | Memory Structure and Memory Corruption Detection Method for Dynamic Memory Allocation of System Programs |
Country Status (1)
| Country | Link |
|---|---|
| KR (1) | KR20070056862A (en) |
Cited By (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US9891919B2 (en) | 2016-01-06 | 2018-02-13 | International Business Machines Corporation | Caller protected stack return address in a hardware managed stack architecture |
| US9940475B2 (en) | 2016-01-06 | 2018-04-10 | Intfrnational Business Machines Corporation | Interlinking routines with differing protections using stack indicators |
| US10120745B2 (en) | 2016-01-06 | 2018-11-06 | International Business Machines Corporation | Providing instructions to protect stack return addresses in a hardware managed stack architecture |
| US10229266B2 (en) | 2016-01-06 | 2019-03-12 | International Business Machines Corporation | Architected store and verify guard word instructions |
| US10228992B2 (en) | 2016-01-06 | 2019-03-12 | International Business Machines Corporation | Providing instructions to facilitate detection of corrupt stacks |
-
2005
- 2005-11-30 KR KR1020050116006A patent/KR20070056862A/en not_active Withdrawn
Cited By (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US9891919B2 (en) | 2016-01-06 | 2018-02-13 | International Business Machines Corporation | Caller protected stack return address in a hardware managed stack architecture |
| US9940475B2 (en) | 2016-01-06 | 2018-04-10 | Intfrnational Business Machines Corporation | Interlinking routines with differing protections using stack indicators |
| US10114971B2 (en) | 2016-01-06 | 2018-10-30 | International Business Machines Corporation | Interlinking routines with differing protections using stack indicators |
| US10120745B2 (en) | 2016-01-06 | 2018-11-06 | International Business Machines Corporation | Providing instructions to protect stack return addresses in a hardware managed stack architecture |
| US10229266B2 (en) | 2016-01-06 | 2019-03-12 | International Business Machines Corporation | Architected store and verify guard word instructions |
| US10228992B2 (en) | 2016-01-06 | 2019-03-12 | International Business Machines Corporation | Providing instructions to facilitate detection of corrupt stacks |
| US10496462B2 (en) | 2016-01-06 | 2019-12-03 | International Business Machines Corporation | Providing instructions to facilitate detection of corrupt stacks |
| US10635441B2 (en) | 2016-01-06 | 2020-04-28 | International Business Machines Corporation | Caller protected stack return address in a hardware managed stack architecture |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US7111307B1 (en) | Method and system for monitoring and verifying software drivers using system resources including memory allocation and access | |
| US7000225B2 (en) | Method for inserting global breakpoints | |
| US6742148B1 (en) | System and method for testing memory while an operating system is active | |
| KR102254159B1 (en) | Method for detecting real-time error in operating system kernel memory | |
| CN108804230B (en) | Method, device and medium for allocating resources according to types of PCI (peripheral component interconnect) equipment | |
| KR20070056862A (en) | Memory Structure and Memory Corruption Detection Method for Dynamic Memory Allocation of System Programs | |
| US11822419B2 (en) | Error information processing method and device, and storage medium | |
| US7418367B2 (en) | System and method for testing a cell | |
| JP5392263B2 (en) | Information processing apparatus and memory protection method thereof | |
| US7797134B2 (en) | System and method for testing a memory with an expansion card using DMA | |
| CN103853551B (en) | Detect the method that the memory of no initializtion is read | |
| EP2645249A1 (en) | Information processing apparatus, and method of controlling information processing apparatus | |
| KR101548134B1 (en) | Real-time monitoring system for stack and method thereof | |
| JP2009175960A (en) | Virtual multiprocessor system | |
| US20090100116A1 (en) | Electronic equipment and memory managing program | |
| JP2001356971A (en) | System and method for testing multiprocessor memory | |
| US7711874B1 (en) | Usage of EHCI companion USB controllers for generating periodic events | |
| JP2014182676A (en) | Log collection device, arithmetic unit, and log collection method | |
| JP2002055851A (en) | Monitoring method for detecting unauthorized memory access in computer system, program therefor, and recording medium therefor | |
| US7769976B2 (en) | Identifying code that wastes virtual memory | |
| JP2009223841A (en) | Instruction log acquisition program and virtual machine system | |
| CN113157513B (en) | Heap memory damage detection method and device, electronic equipment and storage medium | |
| US8095784B2 (en) | Computer system and method for activating basic program therein | |
| JP2007323167A (en) | Method of testing memory | |
| CN113010407A (en) | System information acquisition method, device and system |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PA0109 | Patent application |
Patent event code: PA01091R01D Comment text: Patent Application Patent event date: 20051130 |
|
| PG1501 | Laying open of application | ||
| PC1203 | Withdrawal of no request for examination | ||
| WITN | Application deemed withdrawn, e.g. because no request for examination was filed or no examination fee was paid |