JP2014052753A - Memory management device, and memory management method - Google Patents
Memory management device, and memory management method Download PDFInfo
- Publication number
- JP2014052753A JP2014052753A JP2012195634A JP2012195634A JP2014052753A JP 2014052753 A JP2014052753 A JP 2014052753A JP 2012195634 A JP2012195634 A JP 2012195634A JP 2012195634 A JP2012195634 A JP 2012195634A JP 2014052753 A JP2014052753 A JP 2014052753A
- Authority
- JP
- Japan
- Prior art keywords
- pointer area
- memory
- notification
- heap memory
- unit
- 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
Links
Images
Landscapes
- Debugging And Monitoring (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
Description
本発明は、メモリ管理装置に関し、特に、動的に確保する記憶領域の管理に関する。 The present invention relates to a memory management device, and more particularly to management of a storage area that is dynamically secured.
中央処理装置(CPU:Central Processing Unit)を含む情報処理装置は、プログラムを実行するときに、メモリなどの記憶領域を動的に確保する。このように動的に確保する記憶領域は、ヒープメモリ又はヒープ領域と言う。 An information processing device including a central processing unit (CPU) dynamically secures a storage area such as a memory when executing a program. Such a storage area that is dynamically secured is called a heap memory or a heap area.
ヒープメモリは、静的なメモリと異なり、メモリの用途の自由度を高くし、高度なプログラムやオブジェクト指向プログラムなどで欠かすことのできない重要な機能である。 The heap memory is an important function that is indispensable for advanced programs and object-oriented programs, unlike the static memory, which increases the degree of freedom of memory usage.
一般的な情報処理装置では、情報処理装置で動作するオペレーティングシステム(OS:Operation System)が、ヒープメモリをプログラムに提供する。しかし、OSは、提供後のヒープメモリを管理しない。プログラム開発者が開発したプログラムが、プログラム内で使用するヒープメモリを管理する必要がある。 In a general information processing apparatus, an operating system (OS) that operates on the information processing apparatus provides heap memory to a program. However, the OS does not manage the heap memory after provision. A program developed by a program developer needs to manage heap memory used in the program.
プログラムが実施するヒープメモリの管理は、使用中のヒープメモリの管理(一般的にポインタを用いる)に加え、不要となったヒープメモリの解放が必要である。 The management of the heap memory implemented by the program requires the heap memory that is no longer needed to be released in addition to the management of the heap memory in use (generally using a pointer).
なお、ヒープメモリは、予約済みのメモリプールとして実現されていることが多い。また、一度確保されたヒープメモリは、プログラムでの解放後、OS側が未使用領域として管理する。そして、プログラムからヒープメモリの確保が要求された場合、OSは、解放後に未使用とした領域を、新なヒープメモリとして提供する。 The heap memory is often realized as a reserved memory pool. The heap memory once secured is managed as an unused area by the OS side after being released by the program. When the heap memory is requested from the program, the OS provides an unused area after the release as a new heap memory.
このように、ヒープメモリは、同じアドレスでも、プログラムの処理の流れに従い、異なる用途のメモリとなる場合が生じる。 As described above, the heap memory may be used for different purposes according to the processing flow of the program even at the same address.
そのため、解放したヒープメモリのアドレスを誤って参照すると、プログラムは、動作不正やメモリのデータ破壊を起こす。 For this reason, if the address of the released heap memory is erroneously referred to, the program will cause an operation error or memory data corruption.
また、ヒープメモリの容量は、上限がある。プログラムが、使用しなくなったヒープメモリを適切に解放しないと、OSは、提供するヒープメモリがなくなってしまう。そのため、長時間動作するプログラムは、ヒープメモリ不足を発生させないために、適切にヒープメモリを解放する必要がある。 In addition, the heap memory capacity has an upper limit. If the program does not properly release heap memory that is no longer used, the OS will run out of heap memory to provide. Therefore, a program that operates for a long time needs to release the heap memory appropriately in order not to cause a shortage of heap memory.
解放したヒープメモリを処理する機能として、ガベージコレクション(GC:Garbage Collection)がある。近年、GCを備えたヒープメモリが用いられている。しかし、GCを備えたヒープメモリは、高価であり、特定の用途に限定されている。また、プログラムにCG機能を実装することは、難易度が高いため、一般的には実施されていない。 As a function of processing the released heap memory, there is a garbage collection (GC). In recent years, heap memory equipped with GC has been used. However, heap memories with GC are expensive and limited to specific applications. Moreover, since it is difficult to implement a CG function in a program, it is not generally performed.
そのため、プログラム開発者は、ヒープメモリの管理について、プログラム開発の各段階で、確認作業を実施している。 For this reason, the program developer performs confirmation work on heap memory management at each stage of program development.
例えば、開発者は、プログラムの仕様検討時やソースのコーディング段階での机上デバッグ、プログラムのテスト及びデバッグ作業を繰り返して、ヒープメモリの管理のエラーを除去している。 For example, the developer eliminates heap memory management errors by repeating desktop debugging, program testing, and debugging work at the time of program specification review and source coding stage.
このように、ヒープメモリの管理は、プログラムの開発者にとって、大きな負担となっている。特に、不正なポインタのアクセスが原因となる動作不正やメモリ破壊が発生した場合、その原因の特定及びプログラムの正しい修正は、開発者の大きな負担となっている。 Thus, heap memory management is a heavy burden for program developers. In particular, when an illegal operation or memory corruption occurs due to an illegal pointer access, the identification of the cause and correct correction of the program are a heavy burden on the developer.
近年、プログラムの不正動作を検出する装置が、幾つか提案された。しかし、このような装置は、高価である。また、このような装置を使用するためには、専門的な知識が必要である。そのため、一般的な開発現場は、まだ、簡単には導入できない。 In recent years, several devices for detecting an illegal operation of a program have been proposed. However, such a device is expensive. Moreover, in order to use such a device, specialized knowledge is required. For this reason, general development sites cannot be easily introduced yet.
そこで、ヒープメモリの動作を検証するプログラムが、提案されている(例えば、特許文献1を参照)。 Therefore, a program for verifying the operation of the heap memory has been proposed (see, for example, Patent Document 1).
特許文献1に記載の検出方法は、ヒープメモリに関するポインタの不正を検出するものである。不正検出のため、特許文献1に記載の検出方法は、プログラムソースコードに、ポインタの内容を確認するAPI関数を組み込む。
The detection method described in
つまり、特許文献1に記載の検出方法は、ポインタの参照を用いて不正を検出する発明である。
In other words, the detection method described in
しかし、前述のとおり、ヒープメモリは、プログラムの動作に基づき、解放される。そして、ヒープメモリを解放した場合、プログラムは、プログラムが解放したヒープメモリに対するポイントを使用すると、エラーを発生する。したがって、ヒープメモリを解放した場合、プログラムは、解放したヒープメモリに対するポインタを処理する必要がある。 However, as described above, the heap memory is released based on the operation of the program. When the heap memory is released, the program generates an error when using the point for the heap memory released by the program. Therefore, when the heap memory is released, the program needs to process a pointer to the released heap memory.
つまり、特許文献1に記載の検出方法は、ヒープメモリを解放した場合のポインタを処理できないという問題点があった。
That is, the detection method described in
本発明の目的は、上記問題点を解決し、ヒープメモリを解放した場合に、ポインタを適切に処理できるメモリ管理装置、及び、メモリ管理方法を提供することにある。 An object of the present invention is to solve the above problems and provide a memory management device and a memory management method capable of appropriately processing pointers when heap memory is released.
本発明のメモリ管理装置は、アプリケーションプログラムの処理におけるヒープメモリに関連するポインタ領域の操作を通知する通知処理を前記アプリケーションプログラムに追加する翻訳手段と、前記通知処理からの通知を受け取り、前記通知を基に、ヒープメモリの解放に伴うポインタ領域の操作を記録し、解放されたヒープメモリに対応するポインタ領域を無効とするメモリ管理手段とを含む。 The memory management device according to the present invention receives a notification from the notification process, a translation unit that adds a notification process for notifying an operation of a pointer area related to a heap memory in the process of the application program, and receives the notification from the notification process. And a memory management unit that records the operation of the pointer area associated with the release of the heap memory and invalidates the pointer area corresponding to the released heap memory.
本発明のメモリ管理方法は、アプリケーションプログラムの処理におけるヒープメモリに関連するポインタ領域の操作を通知する通知処理を前記アプリケーションプログラムに追加し、前記通知処理からの通知を受け取り、前記通知を基に、ヒープメモリの解放に伴うポインタ領域の操作を記録し、解放されたヒープメモリに対応するポインタ領域を無効とする。 The memory management method of the present invention adds a notification process for notifying an operation of a pointer area related to a heap memory in the process of an application program to the application program, receives a notification from the notification process, and based on the notification, The operation of the pointer area associated with the release of the heap memory is recorded, and the pointer area corresponding to the released heap memory is invalidated.
本発明のプログラムは、アプリケーションプログラムの処理におけるヒープメモリに関連するポインタ領域の操作を通知する通知処理を前記アプリケーションプログラムに追加する処理と、前記通知処理からの通知を受け取り、前記通知を基に、ヒープメモリの解放に伴うポインタ領域の操作を記録する処理と、解放されたヒープメモリに対応するポインタ領域を無効とする処理とをコンピュータに実行させる。 The program of the present invention receives a notification from the notification process, a process for adding a notification process for notifying an operation of a pointer area related to the heap memory in the process of the application program, and a notification from the notification process. A computer is caused to execute a process for recording a pointer area operation associated with the release of the heap memory and a process for invalidating the pointer area corresponding to the released heap memory.
本発明によれば、ヒープメモリを解放した場合に、ポインタを適切に処理できる。 According to the present invention, the pointer can be appropriately processed when the heap memory is released.
次に、本発明の実施形態について図面を参照して説明する。 Next, embodiments of the present invention will be described with reference to the drawings.
なお、各図面は、本発明の実施形態を説明するものである。そのため、本発明は、各図面の記載に限られるわけではない。また、各図面の同様の構成には、同じ番号を付し、その繰り返しの説明は、省略する場合がある。 Each drawing explains an embodiment of the present invention. Therefore, the present invention is not limited to the description of each drawing. Moreover, the same number is attached | subjected to the same structure of each drawing, and the repeated description may be abbreviate | omitted.
(第1の実施形態)
図1は、本発明における第1の実施形態に係るメモリ管理装置20を含む情報処理システム60の構成の一例を示すブロック図である。
(First embodiment)
FIG. 1 is a block diagram showing an example of the configuration of an information processing system 60 including a
情報処理システム60は、CPU10と、メモリ管理装置20と、メモリ部30と、ROM(Read Only Memory)40と、内部記憶装置50とを含む。
The information processing system 60 includes a
ROM40は、情報処理システム60で用いる固定データや初期化プログラム(IPL:Initial Program Loader)を含む。
The
メモリ部30は、CPU10が使用するメモリである。
The
内部記憶装置50は、情報処理システム60の長期的に保存するデータやプログラムを保存する。
The
CPU10は、情報処理システム60の処理を実施する。
The
例えば、CPU10は、ROM40のIPLに基づき、内部記憶装置50からOS310を読み出し、メモリ部30に保存し、OS310に基づく動作を開始する(起動する)。
For example, the
OS310での動作を起動後、CPU10は、利用者の指示などを基に、アプリケーションプログラム320を内部記憶装置50からメモリ部30に読み出し、実行する。
After starting the operation in the
CPU10は、アプリケーションプログラム320を実行の際に、必要に応じて、メモリ部30上に、静的メモリ330と、スタックメモリ340と、ヒープメモリ350とを確保して使用する。
When executing the
本実施形態のメモリ管理装置20は、ヒープメモリ350を含むメモリ部30を管理し、動的に確保されたメモリに関する動作を管理する。特に、メモリ管理装置20は、ヒープメモリ350の解放に伴うポインタの管理を実施する。
The
なお、ポインタは、1つとは限らず、一般的に複数宣言される。複数宣言された場合、ポインタは、記憶領域の所定の範囲(ポインタ領域)を占有する。そのため、以下、1つ場合を含め「ポインタ領域」として説明する。 Note that the number of pointers is not limited to one, and a plurality of pointers are generally declared. When multiple declarations are made, the pointer occupies a predetermined range (pointer area) of the storage area. Therefore, the following description will be given as a “pointer area” including one case.
メモリ管理装置20ついて、図面を参照して、更に説明する。
The
図2は、本実施形態のメモリ管理装置20の構成の一例を示すブロック図である。
FIG. 2 is a block diagram illustrating an example of the configuration of the
メモリ管理装置20は、翻訳部210と、メモリ管理部220と、不正アクセス特定部230とを含む。
The
まず、翻訳部210について説明する。
First, the
翻訳部210は、図示しないコンパイラが、ソース原文(ソースコードやソースファイル)を基にアプリケーションプログラム320を作成(コンパイル)する際に、アプリケーションプログラム320に、メモリ管理部220へ通知する仕組みを組み込む。より具体的には、翻訳部210は、アプリケーションプログラム320に、ポインタ領域の操作に対する通知処理を追加する。
The
そのため、翻訳部210は、ポインタ領域登録部211と、ポインタ領域変更記録部212と、ヒープアドレス通知部213と、スタック領域通知部214とを含む。
Therefore, the
ポインタ領域登録部211は、アプリケーションプログラム320のポインタ領域を宣言する部分に、使用開始するポインタ領域の情報をメモリ管理部220に登録(通知)する処理(以下、「ポインタ領域登録処理」と言う)を追加する。なお、ポインタ領域の宣言は、ポインタ領域の確保と言われる場合もある。
The pointer
アプリケーションプログラム320で用いられるポインタ領域は、一般的に、次のような種類がある。
The pointer area used in the
(1)静的メモリ330に宣言されたポインタ領域:アプリケーションプログラム320の開始時に宣言されることが多い。
(1) Pointer area declared in the static memory 330: It is often declared at the start of the
(2)スタックメモリ340に宣言されたポインタ領域:一般的に、関数を呼び出すときに、ローカル変数や引数として宣言されることが多い。 (2) Pointer area declared in the stack memory 340: Generally, when calling a function, it is often declared as a local variable or an argument.
(3)ヒープメモリ350に宣言されたポインタ領域:ヒープメモリ350確保時に宣言される。
(3) Pointer area declared in the heap memory 350: Declared when the
ポインタ領域登録部211は、アプリケーションプログラム320のポインタ領域を登録する処理に、ポインタ領域登録処理を追加する。ただし、ポインタ領域登録部211は、上記の3種類の全てにポインタ領域登録処理を追加する必要はない。例えば、静的メモリ330は、アプリケーションプログラム320の動作中に解放されることがない。そのため、ポインタ領域登録部211は、静的メモリ330で用いられるポインタ領域にポインタ領域登録処理を追加しなくても良い。
The pointer
図3は、メモリ管理部220に通知するポインタ領域の情報の一例を表形式で示した図である。
FIG. 3 is a diagram showing an example of pointer area information notified to the
図3に一例として示すポインタ領域の情報は、ポインタ名と、ソース原文名と、行番号と、アドレス情報と、状態とを含む。 The pointer area information shown as an example in FIG. 3 includes a pointer name, a source text name, a line number, address information, and a status.
ポインタ名は、宣言されたポインタ領域の名称である。 The pointer name is the name of the declared pointer area.
ソース原文名は、コンパイラがコンパイルしているソース原文の名称である。 The source text name is the name of the source text compiled by the compiler.
行番号は、ソース原文でポインタ領域が宣言された行番号である。 The line number is the line number where the pointer area is declared in the source text.
アドレス情報は、ポインタ領域が参照するメモリのアドレス情報である。 The address information is address information of the memory referred to by the pointer area.
状態は、宣言されたポインタ領域の状態を示す情報である。例えば、ポインタが宣言された場合、状態は、「生成」となる。 The state is information indicating the state of the declared pointer area. For example, when a pointer is declared, the state is “generated”.
図2を用いた説明に戻る。 Returning to the description using FIG.
ポインタ領域変更記録部212は、アプリケーションプログラム320のポインタ領域の内容を変更する処理に、ポインタ領域の変更に関する情報をメモリ管理部220に通知する処理(以下、「ポインタ領域変更通知処理」と言う)を追加する。
The pointer area
なお、ポインタ領域変更記録部212は、ポインタ領域登録部211が登録するポインタ領域に対応して動作する。そのため、例えば、ポインタ領域登録部211が、静的メモリ330に処理を追加しない場合、ポインタ領域変更記録部212は、静的メモリ330における変更に、処理を追加しない。
The pointer area
図4は、メモリ管理部220に通知するポインタ領域の変更に関する情報の一例を表形式で示した図である。
FIG. 4 is a table showing an example of information related to the pointer area change notified to the
図4に一例として示すポインタ領域の変更に関する情報は、例えば、ソース原文名と、行番号と、スレッドの識別子(ID:Identifier)と、状態とを含む。 The information regarding the change of the pointer area shown as an example in FIG. 4 includes, for example, a source text name, a line number, a thread identifier (ID: Identifier), and a state.
ソース原文名と行番号は、図3と同様である。 The source text name and line number are the same as in FIG.
スレッドIDは、アプリケーションプログラム320において、ポインタ領域を変更(操作)したスレッドのIDである。
The thread ID is an ID of a thread that has changed (operated) the pointer area in the
状態は、図3の状態を同様である。例えば、ポインタ領域に値を設定した場合、状態は、「設定」となる。 The state is the same as the state of FIG. For example, when a value is set in the pointer area, the state is “set”.
図2を用いた説明に戻る。 Returning to the description using FIG.
ヒープアドレス通知部213は、アプリケーションプログラム320のヒープメモリ350の解放する処理に、ヒープメモリ350の解放をメモリ管理部220に通知する処理(以下、「ヒープメモリ解放通知処理」と言う)を追加する。さらに、ヒープアドレス通知部213は、アプリケーションプログラム320のヒープメモリ350の領域の大きさを変更する処理に、ヒープメモリ350の領域の大きさの変更に関する情報をメモリ管理部220に通知する処理(以下、「ヒープメモリ範囲変更通知処理」と言う)を追加する。
The heap
以下、「ヒープメモリ解放通知処理」と「ヒープメモリ範囲変更通知処理」とを合わせて「ヒープメモリ変更通知処理」と言う。 Hereinafter, “heap memory release notification processing” and “heap memory range change notification processing” are collectively referred to as “heap memory change notification processing”.
なお、ヒープメモリ350の解放は、ヒープメモリ350の範囲を「0」に変更することと同様である。そのため、ヒープアドレス通知部213は、「ヒープメモリ解放通知処理」と「ヒープメモリ範囲変更通知処理」とを区別せず、「ヒープメモリ変更通知処理」として実施しても良い。
Note that releasing the
スタック領域通知部214は、アプリケーションプログラム320のスタックメモリ340を操作する処理に、スタックメモリ340の操作に関する情報をメモリ管理部220に通知する処理(以下、「スタック操作通知処理」と言う)を追加する。
The stack
なお、既に説明したとおり、本実施形態の翻訳部210は、スタックメモリ340を確保する場合、及び、ヒープメモリ350を確保する場合、ポインタ領域登録部211がポインタ領域に関する情報を通知する処理を追加する。
As described above, the
そのため、ヒープアドレス通知部213は、ヒープメモリ350の解放時及び変更時に、メモリ管理部220に通知する処理を追加すればよい。
For this reason, the heap
同様に、スタック領域通知部214は、スタックメモリ340を解放する処理(例えば、呼び出された関数から読み出し元に戻る場合)に「スタック操作通知処理」を追加すれば良い。
Similarly, the stack
ただし、翻訳部210の構成は、これに限る必要はない。翻訳部210は、各メモリに対する構成を備えても良い。例えば、翻訳部210は、ヒープメモリ350を処理する処理部を備えてもよい。そして、そのヒープメモリ350を処理する処理部が、ヒープメモリ350にポインタ領域を宣言する処理にポインタ領域の登録の通知処理を追加し、ヒープメモリ350の解放の処理にヒープメモリ解放通知処理を追加しても良い。
However, the configuration of the
次にメモリ管理部220について説明する。
Next, the
メモリ管理部220は、翻訳部210がアプリケーションプログラム320に組み込んだ仕組み(通知処理)からの通知を基に、ポインタ領域を管理する。
The
そのため、メモリ管理部220は、ポインタ領域管理部221と、ポインタ領域初期化部222と、ポインタ領域操作記録部223とを含む。
Therefore, the
ポインタ領域管理部221は、翻訳部210が組み込んだ各処理からの通知を基に、ポインタ領域の情報を管理する。
The pointer
ポインタ領域初期化部222は、ポインタ領域管理部221の指示を基に、ポインタ領域を初期化する。
The pointer
ポインタ領域操作記録部223は、ポインタ領域管理部221の指示を基に、ポインタ領域の操作(状態の変更)を記憶する。
The pointer area
このように、本実施形態のメモリ管理部220は、ポインタ領域管理部221が、中心となって、ポインタ領域に関する処理を実行する。
As described above, in the
そのため、ポインタ領域管理部221の動作を中心にメモリ管理部220について更に詳細に説明する。
Therefore, the
ポインタ領域管理部221は、翻訳部210が組み込んだ各処理からの通知を受け取り、ポインタ領域を管理する。これらの処理を、翻訳部210が組み込んだ各処理に対応して説明する。
The pointer
まず、「ポインタ領域登録処理」に対応する動作を説明する。 First, an operation corresponding to the “pointer area registration process” will be described.
「ポインタ領域登録処理」からの通知を受け取ると、ポインタ領域管理部221は、受け取ったポインタ領域の情報をポインタ領域操作記録部223に記録(登録)する。さらに、ポインタ領域管理部221は、ポインタ領域初期化部222に指示を出し、登録したポインタ領域を初期化する。ポインタ領域管理部221は、初期化後、初期化済みであることを、ポインタ領域操作記録部223に記録しても良い。
When the notification from the “pointer area registration process” is received, the pointer
次に、「ポインタ領域変更通知処理」に対応する動作を説明する。 Next, an operation corresponding to the “pointer area change notification process” will be described.
「ポインタ領域変更通知処理」からポインタ領域の変更に関する通知を受けと、ポインタ領域管理部221は、この通知を基に、ポインタ領域操作記録部223に変更(操作)を記録する。
Upon receiving a notification regarding the change of the pointer area from the “pointer area change notification process”, the pointer
次に、「ヒープメモリ変更通知処理」に対応する動作を説明する。 Next, an operation corresponding to the “heap memory change notification process” will be described.
なお、「ヒープメモリ変更通知処理」は、「ヒープメモリ解放通知処理」及び「ヒープメモリ範囲変更通知処理」である。 The “heap memory change notification process” is a “heap memory release notification process” and a “heap memory range change notification process”.
「ヒープメモリ解放通知処理」からの通知の場合、ポインタ領域管理部221は、解放されたヒープメモリ350の範囲に含まれるポインタ領域を管理対象外(無効)として、ポインタ領域操作記録部223に記録する。さらに、ポインタ領域管理部221は、ポインタ領域初期化部222を用いて、対象外としてポインタ領域を初期化する。
In the case of notification from the “heap memory release notification process”, the pointer
この処理に基づき、メモリ管理装置20は、解放されたヒープメモリ350に対応するポインタ領域を無効とする。その結果、アプリケーションプログラム320は、解放されたヒープメモリ350に対応するポインタ領域を適切に処理できる。
Based on this processing, the
「ヒープメモリ範囲変更通知処理」からの通知の場合、ポインタ領域管理部221は、解放されたヒープメモリ350の範囲と、追加されたヒープメモリ350の範囲とを算出する。
In the case of notification from the “heap memory range change notification process”, the pointer
そして、ポインタ領域管理部221は、解放されたヒープメモリ350の範囲に対応するポインタ領域を、「ヒープメモリ解放通知処理」からの通知の場合と同様に、対象外(無効)とし、さらに、ポインタ領域を初期化する。
Then, the pointer
なお、ポインタ領域管理部221は、追加されたヒープメモリ350の範囲に対応するポインタ領域がある場合、ポインタ領域の情報をポインタ領域操作記録部223に記録し、ポインタ領域初期化部222を用いてポインタ領域を初期化する。
If there is a pointer area corresponding to the range of the added
この処理に基づき、メモリ管理装置20は、解放されたヒープメモリ350に対応するポインタ領域を無効とする。その結果、アプリケーションプログラム320は、解放されたヒープメモリ350に対応するポインタ領域を適切に処理できる。
Based on this processing, the
次に、「スタック操作通知処理」に対応する動作を説明する。 Next, an operation corresponding to the “stack operation notification process” will be described.
「スタック操作通知処理」から通知の場合、ポインタ領域管理部221は、解放されたスタックメモリ340に対応するポインタ領域を対象外(無効)として、ポインタ領域操作記録部223に記録する。さらに、ポインタ領域管理部221は、ポインタ領域初期化部222を用いて、対象外としてポインタ領域を初期化する。
In the case of notification from the “stack operation notification process”, the pointer
この処理に基づき、メモリ管理装置20は、解放されたスタックメモリ340に対応するポインタ領域を無効とする。その結果、アプリケーションプログラム320は、解放されたヒープメモリ350に対応するポインタ領域を適切に処理できる。
Based on this processing, the
次に、不正アクセス特定部230について説明する。
Next, the unauthorized
不正アクセス特定部230は、不正アクセスなどポインタ領域の不正な処理が発生した場合、メモリ管理部220を参照して、ポインタ領域の不正な処理となった箇所を特定する。より具体的には、ポインタ領域の不正が発生した場合、不正アクセス特定部230は、不正となったポインタ領域に関する情報を、ポインタ領域操作記録部223から取り出し、不正な処理を特定する。
When unauthorized processing such as unauthorized access occurs in the pointer area, the unauthorized
例えば、ポインタ領域を参照してヒープメモリ350にアクセスする場合の不正な処理は、次のような処理が想定される。
For example, the following process is assumed as an illegal process when the
(1)初期化されていない内容が原因の不正なアクセス
(2)不正なポインタ値の設定に基づく不正なアクセス
不正なアクセスが発生した場合、不正アクセス特定部230は、ポインタ領域操作記録部223の記録を確認する。例えば、不正アクセス特定部230は、図3に示すポインタ領域の情報を参照し、ポインタ領域を宣言したソース原文と行数を特定する。また、不正アクセス特定部230は、図4に示すポインタ領域の変更に関する情報を基にポインタ領域の状態や、その状態に変更したスレッドやソース原文の位置を特定する。
(1) Unauthorized access due to uninitialized contents (2) Unauthorized access based on unauthorized pointer value setting When unauthorized access occurs, the unauthorized
開発者は、不正アクセス特定部230が特定した情報を参照し、不正を分析できる。
The developer can analyze fraud by referring to the information identified by the unauthorized
そのため、不正アクセス特定部230は、開発者などへ通知する機能を含んでも良い。
Therefore, the unauthorized
このように、本実施形態のメモリ管理装置20は、ヒープメモリ350を解放した場合にポインタ領域を適切に処理できる。
As described above, the
その理由は、次のとおりである。 The reason is as follows.
本実施形態の翻訳部210は、アプリケーションプログラム320のヒープメモリ350の確保(宣言)、変更及び解放の処理に、メモリ管理部220への通知の処理を追加する。
The
そして、メモリ管理部220は、通知を基に、解放されたヒープメモリ350に対応するポインタ領域を対象外(無効)とすることができるためである。
This is because the
さらに、メモリ管理装置20は、スタックメモリ340に対応するポインタ領域も適切に管理できる。
Furthermore, the
その理由は、次のとおりである。 The reason is as follows.
本実施形態の翻訳部210は、アプリケーションプログラム320のスタックメモリ340の確保、変更及び解放の処理に、メモリ管理部220への通知の処理を追加する。
The
そして、メモリ管理部220は、通知を基に、解放されたスタックメモリ340に対応するポインタ領域を対象外(無効)とすることができるためである。
This is because the
また、本実施形態のメモリ管理装置20は、不正アクセスの特定を容易とする効果を得ることができる。
In addition, the
その理由は、次のとおりである。 The reason is as follows.
本実施形態のメモリ管理部220は、翻訳部210が追加した通知を基にポインタ領域の操作を記録する。そして、その記録を基に、不正アクセス特定部230が、ポインタ領域の不正アクセスを特定できるためである。
The
<変形例>
なお、本実施形態のメモリ管理装置20の構成は、これまで説明した構成に限る必要はない。
<Modification>
Note that the configuration of the
例えば、スタックメモリ340は、ヒープメモリ350と同様に動的に確保されるため、スタックメモリ340を含めて説明した。
For example, since the
しかし、本実施形態のメモリ管理装置20は、ヒープメモリ350とスタックメモリ340とを別装置として管理しても良い。
However, the
また、不正アクセス特定部230は、メモリ管理装置20と別装置でも良い。
The unauthorized
図5は、変形例の一例であるメモリ管理装置25の構成の一例のブロック図である。
FIG. 5 is a block diagram of an example of the configuration of the
メモリ管理装置25は、不正アクセス特定部230とスタック領域通知部214とを含まない点を除き、メモリ管理装置20と同様の構成を含む。
The
このように構成されたメモリ管理装置25は、メモリ管理装置20と同様に、ヒープメモリ350を解放した場合にポインタ領域を適切に処理できる。
Similarly to the
その理由は、次のとおりである。 The reason is as follows.
本実施形態の翻訳部215は、アプリケーションプログラム320のヒープメモリ350の確保、変更及び解放の処理に、メモリ管理部220への通知の処理を追加する。
The translation unit 215 of this embodiment adds a process of notifying the
そして、メモリ管理部220は、通知を基に、解放されたヒープメモリ350に対応するポインタ領域を対象外とし、さらに操作を記録するためである。
Then, based on the notification, the
さらに、本実施形態のメモリ管理装置25は、1台の装置に翻訳部215と、メモリ管理部220とを含んでいるが、これに限る必要はない。例えば、メモリ管理装置25は、図6に示すように、翻訳部215とメモリ管理部220とを、バスを介して接続した別のボード、又は、ネットワーク介して接続する別の装置として構成しても良い。なお、図6に示す構成は、本実施形態の最小構成である。
Furthermore, although the
また、本実施形態の説明では、メモリ管理装置20をCPU10とは異なる装置として説明したが、メモリ管理装置20の実現は、これに限る必要はない。
In the description of the present embodiment, the
例えば、メモリ管理装置20の機能をプログラムで実現し、CPU10が実行するOS310に組み込んでも良い。あるいは、メモリ管理装置20は、独立した管理プログラムとして実現しても良い。
For example, the function of the
また、メモリ管理装置20は、図示しないコンピュータで読み込み可能が記録媒体にメモリ管理装置20の機能を実現するプログラムとして保存されても良い。その場合、CPU10が、図示しない記録媒体読み取り装置を用いて、メモリ管理装置20の相当するプログラムとして読み込んで、実行しても良い。
The
あるいは、本実施形態のメモリ管理装置20は、CPU10とは異なるCPUと、ROMと、RAM(Random Access Memory)と、IO(Input/Output)インターフェース(以下、IOと言う)と、NIC(Network Interface Card)とを含むコンピュータとして実現しても良い。
Alternatively, the
図7は、CPU710を用いた本実施形態のメモリ管理装置70を構成の一例を示す図である。
FIG. 7 is a diagram showing an example of the configuration of the
メモリ管理装置70は、CPU710と、ROM720と、RAM730と、内部記憶装置740と、IO750と、NIC780とを含み、コンピュータを構成している。
The
CPU710は、ROM720又は内部記憶装置740からプログラムを読み込む。そして、CPU710は、読み込んだプログラムに基づいて、メモリ管理装置20の翻訳部210と、メモリ管理部220と、不正アクセス特定部230としての各機能を実現する。CPU710は、各機能を実現する際に、RAM730及び内部記憶装置740を一時記憶として使用する。また、CPU710は、NIC780を介して、CPU10などの他の構成と接続する。
The
なお、CPU710は、コンピュータで読み取り可能にプログラムを記憶した記憶媒体790が含むプログラムを、図示しない記憶媒体読み取り装置を用いて読み込んでも良い。あるいは、CPU710は、図示しないネットワークを介して、外部の装置からプログラムを受け取っても良い。
Note that the
ROM720は、CPU710が実行するプログラム、及び、固定的なデータを記憶する。ROM720は、例えば、P−ROM(Programmable-ROM)やフラッシュROMである。
The
RAM730は、CPU710が実行するプログラムやデータを一時的に記憶する。RAM730は、例えば、D−RAM(Dynamic-RAM)である。
The
内部記憶装置740は、メモリ管理装置70の長期的に保存するデータやプログラムを保存する。また、内部記憶装置740は、ポインタ領域操作記録部223として動作しても良い。さらに、内部記憶装置740は、CPU710の一時記憶装置として動作しても良い。内部記憶装置740は、例えば、ハードディスク装置、光磁気ディスク装置、SSD(Solid State Drive)又はディスクアレイ装置である。
The
IO750は、CPU710と、入力機器760及び表示機器770とを接続する。IO750は、例えば、IOインターフェースカードである。
The
入力機器760は、メモリ管理装置70の操作者からの入力指示を受信する入力部である。入力機器760は、例えば、キーボード、マウス又はタッチパネルである。
The
表示機器770は、メモリ管理装置70の表示部である。表示機器770は、例えば、液晶ディスプレイである。
The
NIC780は、メモリ管理装置70とCPU10など他の構成とのデータをやり取りする仲介する。NIC780は、例えば、PCI(Peripheral Component Interface)カードである。
The
このように構成されたメモリ管理装置70は、メモリ管理装置20と同様の効果を得ることができる。
The
その理由は、メモリ管理装置70のCPU710が、プログラムに基づいてメモリ管理装置20と同様の動作を実現できるためである。
This is because the
以上、実施形態を参照して本願発明を説明したが、本願発明は上記実施形態に限定されるものではない。本願発明の構成や詳細には、本願発明のスコープ内で当業者が理解し得る様々な変更をすることができる。 While the present invention has been described with reference to the embodiments, the present invention is not limited to the above embodiments. Various changes that can be understood by those skilled in the art can be made to the configuration and details of the present invention within the scope of the present invention.
10 CPU
20 メモリ管理装置
25 メモリ管理装置
30 メモリ部
40 ROM
50 内部記憶装置
60 情報処理システム
70 メモリ管理装置
210 翻訳部
211 ポインタ領域登録部
212 ポインタ領域変更記録部
213 ヒープアドレス通知部
214 スタック領域通知部
215 翻訳部
220 メモリ管理部
221 ポインタ領域管理部
222 ポインタ領域初期化部
223 ポインタ領域操作記録部
230 不正アクセス特定部
310 OS
320 アプリケーションプログラム
330 静的メモリ
340 スタックメモリ
350 ヒープメモリ
710 CPU
720 ROM
730 RAM
740 内部記憶装置
750 IO
760 入力機器
770 表示機器
780 NIC
790 記憶媒体
10 CPU
20
DESCRIPTION OF
320
720 ROM
730 RAM
740
760
790 storage media
Claims (8)
前記通知処理からの通知を受け取り、前記通知を基に、ヒープメモリの解放に伴うポインタ領域の操作を記録し、解放されたヒープメモリに対応するポインタ領域を無効とするメモリ管理手段とを
含むメモリ管理装置。 Translation means for adding notification processing to the application program for notifying operation of a pointer area related to heap memory in processing of the application program;
A memory management unit that receives a notification from the notification process, records a pointer area operation associated with the release of the heap memory based on the notification, and invalidates the pointer area corresponding to the released heap memory. Management device.
ポインタ領域を初期化するポインタ領域初期化手段と、
ポインタ領域の操作に関する情報を記録するポインタ操作記録手段と、
前記通知を基に、ポインタ領域の操作を前記ポインタ操作記録手段に記録し、
前記通知がヒープメモリの宣言に関する場合、前記ポインタ領域初期化手段を基に前記対応するポインタ領域を初期化し、
前記通知がヒープメモリの解放に関する場合、前記ポインタ操作記録手段に解放されたヒープメモリに対応するポインタ領域の無効を記録し、前記ポインタ領域初期化手段を基に前記対応するポインタ領域を初期化するポインタ領域管理手段とを
含む請求項1に記載のメモリ管理装置。 The memory management unit
Pointer area initialization means for initializing the pointer area;
Pointer operation recording means for recording information on the operation of the pointer area;
Based on the notification, the operation of the pointer area is recorded in the pointer operation recording means,
If the notification relates to the declaration of heap memory, the corresponding pointer area is initialized based on the pointer area initializing means,
When the notification relates to the release of the heap memory, the pointer operation recording unit records the invalidity of the pointer area corresponding to the released heap memory, and initializes the corresponding pointer area based on the pointer area initialization unit. The memory management device according to claim 1, further comprising pointer area management means.
ポインタ領域を宣言する処理に前記通知処理を追加するポインタ領域登録手段と、
ポインタ領域を変更する処理に前記通知処理を追加するポインタ領域変更記録手段と、
ヒープメモリを解放する処理とヒープメモリの範囲を変更する処理に前記通知処理を追加するヒープアドレス通知手段とを
含む請求項1又は請求項2に記載のメモリ管理装置。 The translation unit
Pointer area registration means for adding the notification process to the process of declaring a pointer area;
Pointer area change recording means for adding the notification process to the process of changing the pointer area;
The memory management device according to claim 1, further comprising: a heap address notifying unit that adds the notification process to a process of releasing heap memory and a process of changing a range of the heap memory.
スタックメモリを解放する処理に前記通知処理を追加するスタック領域通知手段
をさらに含む請求項3に記載のメモリ管理装置。 The translation unit
The memory management device according to claim 3, further comprising: a stack area notifying unit that adds the notification process to a process of releasing the stack memory.
をさらに含む請求項1乃至請求項4のいずれか1項に記載のメモリ管理装置。 The memory management device according to any one of claims 1 to 4, further comprising unauthorized access specifying means for specifying unauthorized access in the operation of the pointer area based on information recorded by the memory management means.
前記通知処理からの通知を受け取り、前記通知を基に、ヒープメモリの解放に伴うポインタ領域の操作を記録し、解放されたヒープメモリに対応するポインタ領域を無効とする
メモリ管理方法。 A notification process for notifying the operation of the pointer area related to the heap memory in the process of the application program is added to the application program;
A memory management method for receiving a notification from the notification processing, recording an operation of a pointer area accompanying release of a heap memory based on the notification, and invalidating a pointer area corresponding to the released heap memory.
ポインタ領域を変更する処理に前記通知処理を追加し、
ヒープメモリを解放する処理とヒープメモリの範囲を変更する処理とに前記通知処理を追加する
請求項6に記載のメモリ管理装置。 Add the notification process to the process of adding a pointer area,
Add the notification process to the process of changing the pointer area,
The memory management device according to claim 6, wherein the notification processing is added to processing for releasing heap memory and processing for changing a heap memory range.
前記通知処理からの通知を受け取り、前記通知を基に、ヒープメモリの解放に伴うポインタ領域の操作を記録する処理と、解放されたヒープメモリに対応するポインタ領域を無効とする処理と
をコンピュータに実行させるプログラム。 A process of adding a notification process to the application program to notify the operation of the pointer area related to the heap memory in the process of the application program;
A process of receiving a notification from the notification process and recording a pointer area operation associated with the release of the heap memory and a process of invalidating the pointer area corresponding to the released heap memory based on the notification. The program to be executed.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2012195634A JP2014052753A (en) | 2012-09-06 | 2012-09-06 | Memory management device, and memory management method |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2012195634A JP2014052753A (en) | 2012-09-06 | 2012-09-06 | Memory management device, and memory management method |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| JP2014052753A true JP2014052753A (en) | 2014-03-20 |
Family
ID=50611213
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2012195634A Pending JP2014052753A (en) | 2012-09-06 | 2012-09-06 | Memory management device, and memory management method |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP2014052753A (en) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110413521A (en) * | 2019-07-24 | 2019-11-05 | 杭州迪普信息技术有限公司 | A kind of the write-overflow detection method and device of heap memory |
| JP2022174757A (en) * | 2021-05-11 | 2022-11-24 | アペックス.エーアイ,インコーポレイテッド | Deterministic memory allocation for real-time application |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPH07225703A (en) * | 1994-02-04 | 1995-08-22 | At & T Corp | Software program error detection method |
| JP2003186700A (en) * | 2001-12-20 | 2003-07-04 | Ricoh Co Ltd | Application generating method for image forming apparatus and program causing computer to execute the method |
| JP2006172205A (en) * | 2004-12-16 | 2006-06-29 | Canon Inc | Information processing apparatus and control method therefor, computer program, and storage medium |
| JP2009020823A (en) * | 2007-07-13 | 2009-01-29 | Toshiba Corp | Order relation analysis apparatus, method and program |
| JP2010277302A (en) * | 2009-05-28 | 2010-12-09 | Nec Corp | Inspection program generation device, inspection program generation method and program |
-
2012
- 2012-09-06 JP JP2012195634A patent/JP2014052753A/en active Pending
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPH07225703A (en) * | 1994-02-04 | 1995-08-22 | At & T Corp | Software program error detection method |
| JP2003186700A (en) * | 2001-12-20 | 2003-07-04 | Ricoh Co Ltd | Application generating method for image forming apparatus and program causing computer to execute the method |
| JP2006172205A (en) * | 2004-12-16 | 2006-06-29 | Canon Inc | Information processing apparatus and control method therefor, computer program, and storage medium |
| JP2009020823A (en) * | 2007-07-13 | 2009-01-29 | Toshiba Corp | Order relation analysis apparatus, method and program |
| JP2010277302A (en) * | 2009-05-28 | 2010-12-09 | Nec Corp | Inspection program generation device, inspection program generation method and program |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110413521A (en) * | 2019-07-24 | 2019-11-05 | 杭州迪普信息技术有限公司 | A kind of the write-overflow detection method and device of heap memory |
| CN110413521B (en) * | 2019-07-24 | 2023-01-24 | 杭州迪普信息技术有限公司 | Write-crossing detection method and device for heap memory |
| JP2022174757A (en) * | 2021-05-11 | 2022-11-24 | アペックス.エーアイ,インコーポレイテッド | Deterministic memory allocation for real-time application |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US11301375B2 (en) | Reducing synchronization reliance in marking | |
| EP3788490B1 (en) | Execution control with cross-level trace mapping | |
| US8176480B1 (en) | Adaptive instrumentation through dynamic recompilation | |
| JP7586895B2 (en) | Data storage using memory aperture flash order | |
| CN108475217A (en) | System and method for virtual machine of auditing | |
| CN108369520B (en) | Protecting basic input/output (BIOS) code | |
| Emamdoost et al. | Detecting kernel memory leaks in specialized modules with ownership reasoning | |
| US20090178028A1 (en) | Method and system for invoking just-in-time debugger | |
| JP7672403B2 (en) | Integrated reference and secondary marking | |
| US8548966B2 (en) | Asynchronous assertions | |
| US7523446B2 (en) | User-space return probes | |
| JP2014052753A (en) | Memory management device, and memory management method | |
| CN109582542B (en) | Method for dumping core of embedded system | |
| CN114968702A (en) | Memory statistical method, memory statistical device and computer readable storage medium | |
| Gatla et al. | Understanding persistent-memory-related issues in the linux kernel | |
| CN117971646A (en) | A memory leak detection method for closed-source kernels under ARM architecture | |
| Hermann et al. | Getting to know you: Towards a capability model for java | |
| Chang et al. | Implementation of JVM tool interface on Dalvik virtual machine | |
| Liu et al. | Csod: context-sensitive overflow detection | |
| Cole et al. | Simplex: Repurposing Intel memory protection extensions for information hiding | |
| Dolz et al. | Enabling semantics to improve detection of data races and misuses of lock‐free data structures | |
| CN113220334B (en) | Program fault location method, terminal device and computer readable storage medium | |
| CN108845889A (en) | A kind of test method and system checked BIOS option and whether meet Intel demand | |
| Razeen et al. | Better performance through thread-local emulation | |
| Yang et al. | A RISC-V On-chip Operating System Based on Rust |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20150824 |
|
| A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20160428 |
|
| A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20160524 |
|
| A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20160712 |
|
| A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20161213 |
|
| A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20170208 |
|
| A02 | Decision of refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A02 Effective date: 20170523 |