Commit 99f83c66 authored by Marc Alff's avatar Marc Alff

Bug#16414644 ASSERTION FAILED: SIZE == PFS_ALLOCATED_MEMORY

Before this fix, the command
  SHOW ENGINE PERFORMANCE_SCHEMA STATUS
could report wrong amount of memory allocated,
when the amount of memory used exceeds 4GB.

The problem is that size computations are not done using size_t,
so that overflows do occur, truncating the results.

This fix compute memory sizes properly with size_t.

Tested manually.

No test script provided, as the script would need to allocate too much 
memory for the test.
parent 94b1b653
/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -512,7 +512,7 @@ bool pfs_show_status(handlerton *hton, THD *thd, ...@@ -512,7 +512,7 @@ bool pfs_show_status(handlerton *hton, THD *thd,
uint buflen; uint buflen;
const char *name; const char *name;
int i; int i;
uint size; size_t size;
DBUG_ENTER("pfs_show_status"); DBUG_ENTER("pfs_show_status");
...@@ -526,7 +526,7 @@ bool pfs_show_status(handlerton *hton, THD *thd, ...@@ -526,7 +526,7 @@ bool pfs_show_status(handlerton *hton, THD *thd,
if (stat != HA_ENGINE_STATUS) if (stat != HA_ENGINE_STATUS)
DBUG_RETURN(false); DBUG_RETURN(false);
uint total_memory= 0; size_t total_memory= 0;
for (i=0; /* empty */; i++) for (i=0; /* empty */; i++)
{ {
...@@ -763,7 +763,7 @@ bool pfs_show_status(handlerton *hton, THD *thd, ...@@ -763,7 +763,7 @@ bool pfs_show_status(handlerton *hton, THD *thd,
break; break;
} }
buflen= int10_to_str(size, buf, 10) - buf; buflen= longlong10_to_str(size, buf, 10) - buf;
if (print(thd, if (print(thd,
PERFORMANCE_SCHEMA_str.str, PERFORMANCE_SCHEMA_str.length, PERFORMANCE_SCHEMA_str.str, PERFORMANCE_SCHEMA_str.length,
name, strlen(name), name, strlen(name),
......
/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <string.h> #include <string.h>
bool pfs_initialized= false; bool pfs_initialized= false;
ulonglong pfs_allocated_memory= 0; size_t pfs_allocated_memory= 0;
/** /**
Memory allocation for the performance schema. Memory allocation for the performance schema.
......
/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
extern bool pfs_initialized; extern bool pfs_initialized;
extern ulonglong pfs_allocated_memory; extern size_t pfs_allocated_memory;
void *pfs_malloc(size_t size, myf flags); void *pfs_malloc(size_t size, myf flags);
#define PFS_MALLOC_ARRAY(n, T, f) \ #define PFS_MALLOC_ARRAY(n, T, f) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment