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

Proposed by Laurynas Biveinis
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 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

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

228. By Ignacio Nin

Merge from release branch 5.5.21-25.0

229. By Hrvoje Matijakovic

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

230. By Laurynas Biveinis

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

231. By Laurynas Biveinis

Automerge lp:~stewart/percona-server/bug966844

232. By Hrvoje Matijakovic

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

233. By Hrvoje Matijakovic

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

234. By Hrvoje Matijakovic

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

235. By Stewart Smith

merge 5.5.22 as bzr branch

236. By Hrvoje Matijakovic

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

237. By Laurynas Biveinis

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.

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

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

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
=== modified file 'Percona-Server/storage/heap/heapdef.h'
--- Percona-Server/storage/heap/heapdef.h 2012-04-18 23:26:28 +0000
+++ Percona-Server/storage/heap/heapdef.h 2012-05-11 10:40:25 +0000
@@ -39,6 +39,12 @@
39/* this chunk is a continuation from another chunk (part of chunkset) */39/* this chunk is a continuation from another chunk (part of chunkset) */
40#define CHUNK_STATUS_LINKED 240#define CHUNK_STATUS_LINKED 2
4141
42#ifdef HAVE_VALGRIND
43#define RED_ZONE_LEN 10
44#else
45#define RED_ZONE_LEN 0
46#endif
47
42 /* Some extern variables */48 /* Some extern variables */
4349
44extern LIST *heap_open_list,*heap_share_list;50extern LIST *heap_open_list,*heap_share_list;
4551
=== modified file 'Percona-Server/storage/heap/hp_block.c'
--- Percona-Server/storage/heap/hp_block.c 2011-06-30 15:46:53 +0000
+++ Percona-Server/storage/heap/hp_block.c 2012-05-11 10:40:25 +0000
@@ -36,7 +36,7 @@
36 ptr=(HP_PTRS*)ptr->blocks[pos/block->level_info[i].records_under_level];36 ptr=(HP_PTRS*)ptr->blocks[pos/block->level_info[i].records_under_level];
37 pos%=block->level_info[i].records_under_level;37 pos%=block->level_info[i].records_under_level;
38 }38 }
39 return (uchar*) ptr+ pos*block->recbuffer;39 return (uchar*) ptr+ pos*(block->recbuffer) + RED_ZONE_LEN;
40}40}
4141
4242
4343
=== modified file 'Percona-Server/storage/heap/hp_create.c'
--- Percona-Server/storage/heap/hp_create.c 2012-04-19 16:51:34 +0000
+++ Percona-Server/storage/heap/hp_create.c 2012-05-11 10:40:25 +0000
@@ -336,7 +336,7 @@
336 sizeof(uchar **);336 sizeof(uchar **);
337 } else {337 } else {
338 /* Make it likely to fail if anyone uses this offset */338 /* Make it likely to fail if anyone uses this offset */
339 share->recordspace.offset_link= 1 << 22;339 share->recordspace.offset_link= 1 << 31;
340 share->recordspace.offset_status= chunk_dataspace_length;340 share->recordspace.offset_status= chunk_dataspace_length;
341 }341 }
342342
@@ -403,7 +403,7 @@
403 records_in_block= (my_default_record_cache_size - sizeof(HP_PTRS) *403 records_in_block= (my_default_record_cache_size - sizeof(HP_PTRS) *
404 HP_MAX_LEVELS) / recbuffer + 1;404 HP_MAX_LEVELS) / recbuffer + 1;
405 block->records_in_block= records_in_block;405 block->records_in_block= records_in_block;
406 block->recbuffer= recbuffer;406 block->recbuffer= recbuffer + 2 * RED_ZONE_LEN;
407 block->last_allocated= 0L;407 block->last_allocated= 0L;
408408
409 for (i= 0; i <= HP_MAX_LEVELS; i++)409 for (i= 0; i <= HP_MAX_LEVELS; i++)
410410
=== modified file 'Percona-Server/storage/heap/hp_dspace.c'
--- Percona-Server/storage/heap/hp_dspace.c 2012-04-18 23:26:28 +0000
+++ Percona-Server/storage/heap/hp_dspace.c 2012-05-11 10:40:25 +0000
@@ -379,6 +379,8 @@
379379
380 DBUG_PRINT("hp_allocate_one_chunk",380 DBUG_PRINT("hp_allocate_one_chunk",
381 ("Used old position: 0x%lx",(long) curr_chunk));381 ("Used old position: 0x%lx",(long) curr_chunk));
382
383 MEM_UNDEFINED(curr_chunk, info->chunk_length);
382 return curr_chunk;384 return curr_chunk;
383 }385 }
384386
@@ -397,6 +399,10 @@
397 info->chunk_count++;399 info->chunk_count++;
398 curr_chunk= ((uchar *) info->block.level_info[0].last_blocks +400 curr_chunk= ((uchar *) info->block.level_info[0].last_blocks +
399 block_pos * info->block.recbuffer);401 block_pos * info->block.recbuffer);
402 MEM_NOACCESS(curr_chunk, RED_ZONE_LEN);
403 curr_chunk+= RED_ZONE_LEN;
404 MEM_UNDEFINED(curr_chunk, info->chunk_length);
405 MEM_NOACCESS(curr_chunk + info->chunk_length, RED_ZONE_LEN);
400406
401 DBUG_PRINT("hp_allocate_one_chunk",407 DBUG_PRINT("hp_allocate_one_chunk",
402 ("Used new position: 0x%lx", (long) curr_chunk));408 ("Used new position: 0x%lx", (long) curr_chunk));
@@ -418,6 +424,7 @@
418void hp_free_chunks(HP_DATASPACE *info, uchar *pos)424void hp_free_chunks(HP_DATASPACE *info, uchar *pos)
419{425{
420 uchar *curr_chunk= pos;426 uchar *curr_chunk= pos;
427 uchar *next_chunk= NULL;
421428
422 while (curr_chunk)429 while (curr_chunk)
423 {430 {
@@ -425,6 +432,13 @@
425 *((uchar **) curr_chunk)= info->del_link;432 *((uchar **) curr_chunk)= info->del_link;
426 info->del_link= curr_chunk;433 info->del_link= curr_chunk;
427434
435 if (info->is_variable_size)
436 next_chunk= *((uchar **)(curr_chunk + info->offset_link));
437
438 MEM_NOACCESS(curr_chunk + sizeof(uchar *),
439 info->chunk_length - sizeof(uchar *));
440
441 MEM_UNDEFINED(curr_chunk + info->offset_status, 1);
428 curr_chunk[info->offset_status]= CHUNK_STATUS_DELETED;442 curr_chunk[info->offset_status]= CHUNK_STATUS_DELETED;
429443
430 DBUG_PRINT("hp_free_chunks",("Freed position: 0x%lx", (long) curr_chunk));444 DBUG_PRINT("hp_free_chunks",("Freed position: 0x%lx", (long) curr_chunk));
@@ -435,6 +449,6 @@
435 }449 }
436450
437 /* Delete next chunk in this chunkset */451 /* Delete next chunk in this chunkset */
438 curr_chunk= *((uchar **)(curr_chunk + info->offset_link));452 curr_chunk= next_chunk;
439 }453 }
440}454}
441455
=== modified file 'Percona-Server/storage/heap/hp_write.c'
--- Percona-Server/storage/heap/hp_write.c 2012-04-18 23:26:28 +0000
+++ Percona-Server/storage/heap/hp_write.c 2012-05-11 10:40:25 +0000
@@ -374,5 +374,5 @@
374 }374 }
375 block->last_allocated=records+1;375 block->last_allocated=records+1;
376 return((HASH_INFO*) ((uchar*) block->level_info[0].last_blocks+376 return((HASH_INFO*) ((uchar*) block->level_info[0].last_blocks+
377 block_pos*block->recbuffer));377 block_pos * block->recbuffer + RED_ZONE_LEN));
378}378}

Subscribers

People subscribed via source and target branches