Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
2f3d4bd5
Commit
2f3d4bd5
authored
7 years ago
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-12416 OOM in create_virtual_tmp_table() makes the server crash
parent
a0c79bcf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
2 deletions
+38
-2
mysql-test/r/error_simulation.result
mysql-test/r/error_simulation.result
+9
-0
mysql-test/t/error_simulation.test
mysql-test/t/error_simulation.test
+14
-0
sql/sql_select.h
sql/sql_select.h
+15
-2
No files found.
mysql-test/r/error_simulation.result
View file @
2f3d4bd5
...
@@ -121,3 +121,12 @@ a
...
@@ -121,3 +121,12 @@ a
2
2
#cleanup
#cleanup
DROP TABLE t1, pid_table;
DROP TABLE t1, pid_table;
#
# MDEV-12416 OOM in create_virtual_tmp_table() makes the server crash
#
CREATE FUNCTION f1(a INT) RETURNS INT RETURN a;
SET SESSION debug_dbug="+d,simulate_create_virtual_tmp_table_out_of_memory";
SELECT f1(1);
Got one of the listed errors
DROP FUNCTION f1;
SET SESSION debug_dbug=DEFAULT;
This diff is collapsed.
Click to expand it.
mysql-test/t/error_simulation.test
View file @
2f3d4bd5
...
@@ -148,3 +148,17 @@ SELECT a FROM t1 ORDER BY rand(1);
...
@@ -148,3 +148,17 @@ SELECT a FROM t1 ORDER BY rand(1);
--
echo
#cleanup
--
echo
#cleanup
DROP
TABLE
t1
,
pid_table
;
DROP
TABLE
t1
,
pid_table
;
--
echo
#
--
echo
# MDEV-12416 OOM in create_virtual_tmp_table() makes the server crash
--
echo
#
CREATE
FUNCTION
f1
(
a
INT
)
RETURNS
INT
RETURN
a
;
SET
SESSION
debug_dbug
=
"+d,simulate_create_virtual_tmp_table_out_of_memory"
;
# May fail with either ER_OUT_OF_RESOURCES or EE_OUTOFMEMORY
--
error
ER_OUT_OF_RESOURCES
,
5
SELECT
f1
(
1
);
DROP
FUNCTION
f1
;
SET
SESSION
debug_dbug
=
DEFAULT
;
This diff is collapsed.
Click to expand it.
sql/sql_select.h
View file @
2f3d4bd5
...
@@ -1993,7 +1993,7 @@ class Virtual_tmp_table: public TABLE
...
@@ -1993,7 +1993,7 @@ class Virtual_tmp_table: public TABLE
This is needed to avoid memory leaks, as some fields can be BLOB
This is needed to avoid memory leaks, as some fields can be BLOB
variants and thus can have String onboard. Strings must be destructed
variants and thus can have String onboard. Strings must be destructed
as they store data
not
the heap (not on MEM_ROOT).
as they store data
on
the heap (not on MEM_ROOT).
*/
*/
void
destruct_fields
()
void
destruct_fields
()
{
{
...
@@ -2025,6 +2025,7 @@ class Virtual_tmp_table: public TABLE
...
@@ -2025,6 +2025,7 @@ class Virtual_tmp_table: public TABLE
@param thd - Current thread.
@param thd - Current thread.
*/
*/
static
void
*
operator
new
(
size_t
size
,
THD
*
thd
)
throw
();
static
void
*
operator
new
(
size_t
size
,
THD
*
thd
)
throw
();
static
void
operator
delete
(
void
*
ptr
,
size_t
size
)
{
TRASH
(
ptr
,
size
);
}
Virtual_tmp_table
(
THD
*
thd
)
Virtual_tmp_table
(
THD
*
thd
)
{
{
...
@@ -2035,7 +2036,8 @@ class Virtual_tmp_table: public TABLE
...
@@ -2035,7 +2036,8 @@ class Virtual_tmp_table: public TABLE
~
Virtual_tmp_table
()
~
Virtual_tmp_table
()
{
{
destruct_fields
();
if
(
s
)
destruct_fields
();
}
}
/**
/**
...
@@ -2120,6 +2122,17 @@ create_virtual_tmp_table(THD *thd, List<Column_definition> &field_list)
...
@@ -2120,6 +2122,17 @@ create_virtual_tmp_table(THD *thd, List<Column_definition> &field_list)
Virtual_tmp_table
*
table
;
Virtual_tmp_table
*
table
;
if
(
!
(
table
=
new
(
thd
)
Virtual_tmp_table
(
thd
)))
if
(
!
(
table
=
new
(
thd
)
Virtual_tmp_table
(
thd
)))
return
NULL
;
return
NULL
;
/*
If "simulate_create_virtual_tmp_table_out_of_memory" debug option
is enabled, we now enable "simulate_out_of_memory". This effectively
makes table->init() fail on OOM inside multi_alloc_root().
This is done to test that ~Virtual_tmp_table() called from the "delete"
below correcly handles OOM.
*/
DBUG_EXECUTE_IF
(
"simulate_create_virtual_tmp_table_out_of_memory"
,
DBUG_SET
(
"+d,simulate_out_of_memory"
););
if
(
table
->
init
(
field_list
.
elements
)
||
if
(
table
->
init
(
field_list
.
elements
)
||
table
->
add
(
field_list
)
||
table
->
add
(
field_list
)
||
table
->
open
())
table
->
open
())
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment