valgrind ã® shadow values ã®å®è£
ã«é¢ããè«æ How to Shadow Every Byte of Memory Used by a Program ãèªãã ã®ã§ãã¾ã¨ãã¦ããã
- memcheck
- shadow values ã表ç¾ããããã«ä»¥ä¸ã®ãã¼ã¿ãæã¤ã
- A (Addressability) bit
- ãã®ã¢ãã¬ã¹ãæå¹ã§ãããã©ããã示ãã1 ãã¤ãã«ã¤ã 1 ãããã§è¡¨ç¾ãããã
- V (Validity) bit
- ãã®ã¢ãã¬ã¹ã®åããããåæåæ¸ãã©ããã示ãã1 ãããã«ã¤ã 1 ãããã§è¡¨ç¾ãããã
- 確ä¿ãããããããã®ãã¼ãé åã¯ããã·ã¥ãã¼ãã«ã§ç®¡çããã¦ããã
- ãã¼ã¿æ§é
- ãã¼ã¸åä½ã§ç®¡çããã1 ãã¼ã¸ã«ã¯ 64KB åã® A/V bit ãä¿åãããã
- PM (Primary Map) ã¨å¼ã°ããé
åã¯åãã¼ã¸ã表ç¾ãã SM (Secondary Map) ã¸ã®ãªã³ã¯ãä¿æããã
- A bit ã 0 (ããªãã¡æå¹ã§ãªãã¢ãã¬ã¹) ã§ããå ´å㯠V bit ã¯æå³ãæããªãããããã®ãããªãã¼ã¸ã¯ PM ããã®ãªã³ã¯ãå
±æãããã
- A/V ã®æä½ã¯ãããæ¼ç®ã§ãããªãããã
- A bit ã 0 ã§ããå ´åã¯ã¨ã©ã¼ã«ããã
- shadow values
- 以ä¸ã®ç¶æ
ã®ããããã§ããã(A/V ãããã¨ã¯å¥ã«ä¸è¬çãªè©±)
ç¶æ
|
çºçãããé¢æ° |
NOACCESS |
free |
UNDEFINED |
malloc |
DEFINED |
calloc |
-
- ã·ã¹ãã ã³ã¼ã«ã«æ¸¡ãé åããã§ãã¯ããã
- ãã®ã¼ãªããã°ã©ã ã shadow values ãç ´å£ããå±éºæ§ãããã
- NOACCESS ãªé åã¨ãããã¨ã§å¯¾å¿ãã¦ããã
- x86 ã ã¨ã»ã°ã¡ã³ãã¬ã¸ã¹ã¿ã使ãããã©ã移æ¤æ§ã®åé¡ããåãé¤ããã
- ããã°ã©ã ãããé ãã®ã¢ãã¬ã¹ã«ç½®ããã¨ã§ç ´å£ã®å±éºæ§ãæ¸ããã
- 64 bit 対å¿
- ãã¼ãã«ã®æ®µæ°ãå¢ããã
- ãã«ãã¹ã¬ãã対å¿
- å®éã®ãã¼ã¿ã¨ shadow values ã®æ´æ°ã¯ atomic ã«ããã
- æ¹åæ¡
- 4 ãã¤ãã¢ã©ã¤ã³ããã¦ããå ´åã¯ãã¯ãã«åã
- 4 ãã¤ãã¢ã©ã¤ã³ããã¦ããªãå ´åã¯å¾æ¥ã¨å¤ãããªããããé
ããªããã¨ã¯ãªãã
- SP (Stack Pointer) ã®é«éãªæ´æ°
- åºå®ãã¤ãæ°ã§ãããã¨ãå¤ãããã«ã¢ã³ãã¼ã«æ¸ã® memset çãªé¢æ°ã使ãã
- VA bits ãå¾æ¥ã® A/V bits ã®ä»£ããã«ä½¿ç¨ããã1 ãã¤ãã«ã¤ã 2 ãããã§ä»¥ä¸ã®ç¶æ
ã表ç¾ããã
ç¶æ
|
æå³ |
NOACCESS |
ä¸æ£ãªã¢ãã¬ã¹ |
DEFINED |
ãã¹ã¦ã®ããããåæåæ¸ |
UNDEFINED |
ãã¹ã¦ã®ããããæªåæå |
PARTDEFINED |
ä¸é¨ã®ãããã®ã¿ãåæåæ¸ |
-
- PARTDEFINED ã®å ´åã®ã¿ V bit ãæã¤ããããã«ãããã¨ã§ã¡ã¢ãªä½¿ç¨éãåæ¸ããã
- V bit ã®ãã¼ãã«ã¯ AVL æ¨ã§ç®¡çããã
- æ´æ°ã«ãã£ã¦ããã¹ã¦ã® V bit ã DEFINED or UNDEFINED ã«ãªãã¨ãV bit ãã¼ãã«ã®åå¨ãåé·ã¨ãªããããGC ããã¹ãã§ããã
- ããããV bit ã®ãã¼ãã«ã¯è¿ãå°æ¥ã«å度æ´æ°ãããå¯è½æ§ãããã®ã§ãããã« GC ãã¹ãã§ã¯ãªãã¨ãèãããããã¨ããã3 å GC ãããéã«æ´æ°ããªãã£ãããGC ãããã®ã¨ããã
- PARTDEFINED ã®æã®å¦çã¯å¾æ¥ãããé
ããªãããå
¨ä½ã§ã¯é«éåã§ããã
- ROM ã¸ã®æ¸ãè¾¼ã¿ã¯æ¤åºããªãã
- ç¶æ
ãå¢ãã㨠VA bits ã 3 ãããã«ããªãã¨ãããªããªãã
- ã©ãã ROM ã¸ã®æ¸ãè¾¼ã¿ã¯ SIGSEGV çºçã¨ãªããããããããæ¤åºã§ãã¦ããããã»ã©ãããããªãã
- ä»ã®ãã¼ã«ã®ææ³
- shadow values ã決ãããããªãã»ããã ããããã¢ãã¬ã¹ã«ç½®ããã¨ã§ shadow values ã®è¨ç®ãç°¡ç¥åããã
- V bit ã 1 ãã¤ãã«ã¤ã 1 ãããã ãã«ããã