Merge lp:~laurynas-biveinis/percona-server/memory-valgrind-annotations into lp:percona-server/5.5

Proposed by Laurynas Biveinis on 2012-03-23
Status: Work in progress
Proposed branch: lp:~laurynas-biveinis/percona-server/memory-valgrind-annotations
Merge into: lp:percona-server/5.5
Diff against target: 116 lines (+25/-5)
5 files modified
Percona-Server/storage/heap/heapdef.h (+6/-0)
Percona-Server/storage/heap/hp_block.c (+1/-1)
Percona-Server/storage/heap/hp_create.c (+2/-2)
Percona-Server/storage/heap/hp_dspace.c (+15/-1)
Percona-Server/storage/heap/hp_write.c (+1/-1)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/memory-valgrind-annotations
Reviewer Review Type Date Requested Status
Percona core 2012-03-23 Pending
Review via email: mp+99019@code.launchpad.net

Description of the change

Annotate the MEMORY engine block allocator for Valgrind.

- Add 10-byte-long redzones before and after each block when compiled
  with Valgrind support. Mark them as inaccessible on block
  allocation.
- Mark block contents as undefined on block deallocation and
  allocation that recycles blocks from the free list.
- Bump block offset link from 1 << 22 to 1 << 31 for fixed-length
  blocks in order to make errorneous accesses crash sooner when
  fixed-length blocks are treated as variable-length.

To post a comment you must log in.
227. By Hrvoje Matijakovic on 2012-03-27

* merged lp:~hrvojem/percona-server/new-theme-5.5

228. By Ignacio Nin on 2012-03-27

Merge from release branch 5.5.21-25.0

229. By Hrvoje Matijakovic on 2012-03-27

* merged lp:~hrvojem/percona-server/bug955266-5.5

230. By Laurynas Biveinis on 2012-03-28

Automerge lp:~laurynas-biveinis/percona-server/staging-5.5

231. By Laurynas Biveinis on 2012-03-28

Automerge lp:~stewart/percona-server/bug966844

232. By Hrvoje Matijakovic on 2012-03-28

* merged lp:~hrvojem/percona-server/rn-25.1

233. By Hrvoje Matijakovic on 2012-03-29

* merged lp:~hrvojem/percona-server/theme-update.5.5

234. By Hrvoje Matijakovic on 2012-04-12

* merged lp:~hrvojem/percona-server/theme-fix-5.5

235. By Stewart Smith on 2012-04-22

merge 5.5.22 as bzr branch

236. By Hrvoje Matijakovic on 2012-04-24

* merged lp:~hrvojem/percona-server/rn-5.5.22-25.2

237. By Laurynas Biveinis on 2012-05-11

Annotate the MEMORY engine block allocator for Valgrind.

- Add 10-byte-long redzones before and after each block when compiled
  with Valgrind support. Mark them as inaccessible on block
  allocation.
- Mark block contents as undefined on block deallocation and
  allocation that recycles blocks from the free list.
- Bump block offset link from 1 << 22 to 1 << 31 for fixed-length
  blocks in order to make errorneous accesses crash sooner when
  fixed-length blocks are treated as variable-length.

Clean Valgrind on Jenkins testing results:
http://jenkins.percona.com/job/percona-server-5.5-valgrind-param/5/

Regular Jenkins test still in progress.

Unmerged revisions

237. By Laurynas Biveinis on 2012-05-11

Annotate the MEMORY engine block allocator for Valgrind.

- Add 10-byte-long redzones before and after each block when compiled
  with Valgrind support. Mark them as inaccessible on block
  allocation.
- Mark block contents as undefined on block deallocation and
  allocation that recycles blocks from the free list.
- Bump block offset link from 1 << 22 to 1 << 31 for fixed-length
  blocks in order to make errorneous accesses crash sooner when
  fixed-length blocks are treated as variable-length.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Percona-Server/storage/heap/heapdef.h'
2--- Percona-Server/storage/heap/heapdef.h 2012-04-18 23:26:28 +0000
3+++ Percona-Server/storage/heap/heapdef.h 2012-05-11 10:40:25 +0000
4@@ -39,6 +39,12 @@
5 /* this chunk is a continuation from another chunk (part of chunkset) */
6 #define CHUNK_STATUS_LINKED 2
7
8+#ifdef HAVE_VALGRIND
9+#define RED_ZONE_LEN 10
10+#else
11+#define RED_ZONE_LEN 0
12+#endif
13+
14 /* Some extern variables */
15
16 extern LIST *heap_open_list,*heap_share_list;
17
18=== modified file 'Percona-Server/storage/heap/hp_block.c'
19--- Percona-Server/storage/heap/hp_block.c 2011-06-30 15:46:53 +0000
20+++ Percona-Server/storage/heap/hp_block.c 2012-05-11 10:40:25 +0000
21@@ -36,7 +36,7 @@
22 ptr=(HP_PTRS*)ptr->blocks[pos/block->level_info[i].records_under_level];
23 pos%=block->level_info[i].records_under_level;
24 }
25- return (uchar*) ptr+ pos*block->recbuffer;
26+ return (uchar*) ptr+ pos*(block->recbuffer) + RED_ZONE_LEN;
27 }
28
29
30
31=== modified file 'Percona-Server/storage/heap/hp_create.c'
32--- Percona-Server/storage/heap/hp_create.c 2012-04-19 16:51:34 +0000
33+++ Percona-Server/storage/heap/hp_create.c 2012-05-11 10:40:25 +0000
34@@ -336,7 +336,7 @@
35 sizeof(uchar **);
36 } else {
37 /* Make it likely to fail if anyone uses this offset */
38- share->recordspace.offset_link= 1 << 22;
39+ share->recordspace.offset_link= 1 << 31;
40 share->recordspace.offset_status= chunk_dataspace_length;
41 }
42
43@@ -403,7 +403,7 @@
44 records_in_block= (my_default_record_cache_size - sizeof(HP_PTRS) *
45 HP_MAX_LEVELS) / recbuffer + 1;
46 block->records_in_block= records_in_block;
47- block->recbuffer= recbuffer;
48+ block->recbuffer= recbuffer + 2 * RED_ZONE_LEN;
49 block->last_allocated= 0L;
50
51 for (i= 0; i <= HP_MAX_LEVELS; i++)
52
53=== modified file 'Percona-Server/storage/heap/hp_dspace.c'
54--- Percona-Server/storage/heap/hp_dspace.c 2012-04-18 23:26:28 +0000
55+++ Percona-Server/storage/heap/hp_dspace.c 2012-05-11 10:40:25 +0000
56@@ -379,6 +379,8 @@
57
58 DBUG_PRINT("hp_allocate_one_chunk",
59 ("Used old position: 0x%lx",(long) curr_chunk));
60+
61+ MEM_UNDEFINED(curr_chunk, info->chunk_length);
62 return curr_chunk;
63 }
64
65@@ -397,6 +399,10 @@
66 info->chunk_count++;
67 curr_chunk= ((uchar *) info->block.level_info[0].last_blocks +
68 block_pos * info->block.recbuffer);
69+ MEM_NOACCESS(curr_chunk, RED_ZONE_LEN);
70+ curr_chunk+= RED_ZONE_LEN;
71+ MEM_UNDEFINED(curr_chunk, info->chunk_length);
72+ MEM_NOACCESS(curr_chunk + info->chunk_length, RED_ZONE_LEN);
73
74 DBUG_PRINT("hp_allocate_one_chunk",
75 ("Used new position: 0x%lx", (long) curr_chunk));
76@@ -418,6 +424,7 @@
77 void hp_free_chunks(HP_DATASPACE *info, uchar *pos)
78 {
79 uchar *curr_chunk= pos;
80+ uchar *next_chunk= NULL;
81
82 while (curr_chunk)
83 {
84@@ -425,6 +432,13 @@
85 *((uchar **) curr_chunk)= info->del_link;
86 info->del_link= curr_chunk;
87
88+ if (info->is_variable_size)
89+ next_chunk= *((uchar **)(curr_chunk + info->offset_link));
90+
91+ MEM_NOACCESS(curr_chunk + sizeof(uchar *),
92+ info->chunk_length - sizeof(uchar *));
93+
94+ MEM_UNDEFINED(curr_chunk + info->offset_status, 1);
95 curr_chunk[info->offset_status]= CHUNK_STATUS_DELETED;
96
97 DBUG_PRINT("hp_free_chunks",("Freed position: 0x%lx", (long) curr_chunk));
98@@ -435,6 +449,6 @@
99 }
100
101 /* Delete next chunk in this chunkset */
102- curr_chunk= *((uchar **)(curr_chunk + info->offset_link));
103+ curr_chunk= next_chunk;
104 }
105 }
106
107=== modified file 'Percona-Server/storage/heap/hp_write.c'
108--- Percona-Server/storage/heap/hp_write.c 2012-04-18 23:26:28 +0000
109+++ Percona-Server/storage/heap/hp_write.c 2012-05-11 10:40:25 +0000
110@@ -374,5 +374,5 @@
111 }
112 block->last_allocated=records+1;
113 return((HASH_INFO*) ((uchar*) block->level_info[0].last_blocks+
114- block_pos*block->recbuffer));
115+ block_pos * block->recbuffer + RED_ZONE_LEN));
116 }

Subscribers

People subscribed via source and target branches