Skip to content

Commit e85a5e6

Browse files
committed
Bug#25492129 --PERFORMANCE-SCHEMA-DIGESTS-SIZE=1 LEADS TO SIGSEGV
Before this fix, starting a server with --performance-schema-digests-size=1 would cause a crash. The root cause is in function fund_or_create_digest(). When scanning the digest array, the code skip entry [0] which is reserved for the "NULL" digest, and proceeds directly to entry [1]. When --performance-schema-digests-size is 2 or more, the record at index [1] exists, but for a size of exactly 1, using this record causes a failure. The fix is ignore record 0 instead of adjusting to record 1, and let the while loop operate normally, as it accesses records safely already.
1 parent dd861f7 commit e85a5e6

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
SELECT "Digest table has a size 1 and is full already." as use_case;
2+
use_case
3+
Digest table has a size 1 and is full already.
4+
select SCHEMA_NAME, DIGEST, DIGEST_TEXT
5+
from performance_schema.events_statements_summary_by_digest;
6+
SCHEMA_NAME DIGEST DIGEST_TEXT
7+
NULL NULL NULL
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--performance-schema-digests-size=1
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# -----------------------------------------------------------------------
2+
# Tests for the performance schema statement Digests.
3+
# -----------------------------------------------------------------------
4+
5+
--source include/not_embedded.inc
6+
--source include/have_perfschema.inc
7+
--source include/no_protocol.inc
8+
9+
SELECT "Digest table has a size 1 and is full already." as use_case;
10+
11+
select SCHEMA_NAME, DIGEST, DIGEST_TEXT
12+
from performance_schema.events_statements_summary_by_digest;
13+
14+
15+

storage/perfschema/pfs_digest.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -255,10 +255,11 @@ find_or_create_digest(PFS_thread *thread,
255255
if (safe_index == 0)
256256
{
257257
/* Record [0] is reserved. */
258-
safe_index= 1;
258+
continue;
259259
}
260260

261261
/* Add a new record in digest stat array. */
262+
DBUG_ASSERT(safe_index < digest_max);
262263
pfs= &statements_digest_stat_array[safe_index];
263264

264265
if (pfs->m_lock.is_free())

0 commit comments

Comments
 (0)