Skip to content

Commit ad3b185

Browse files
committed
Bug #20085672: CRYPTIC ERROR WHEN FAILING TO UNLOAD A DYNAMIC LIBRARY
When the server loads a plugin it searches for globals of the plugin services the plugin may be using. If found it expects a version in these globals, checks the version and if it matches replaces it with a pointer to the server function implementing the service. It does not save these versions and thus does not restore them when unloading the plugin, as it expects that the dynamic library will go away. However if the same shared library also exports UDF functions the reference count to it may not be zero and UNINSTALL PLUGIN will not actually unload the shared library. So the next INSTALL PLUGIN will find the shared library, but will fail when checking the service versions since these are already replaced by the server function pointers. Fixed by accepting the relevant server function pointer as a valid value for the version in addition to the actual version as checked currently. Test case added.
1 parent cd67429 commit ad3b185

File tree

18 files changed

+198
-15
lines changed

18 files changed

+198
-15
lines changed

mysql-test/include/plugin.defs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ libmemcached plugin/innodb_memcached/daemon_memcached DAEMON_MEMCACHED dae
4646
innodb_engine plugin/innodb_memcached/innodb_memcache INNODB_ENGINE
4747
validate_password plugin/password_validation VALIDATE_PASSWORD validate_password
4848
mysql_no_login plugin/mysql_no_login MYSQL_NO_LOGIN mysql_no_login
49+
test_udf_services plugin/udf_services TESTUDFSERVICES

mysql-test/r/udf_services.result

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#
2+
# Bug #20085672: CRYPTIC ERROR WHEN FAILING TO UNLOAD A DYNAMIC LIBRARY
3+
#
4+
# Install the plugin
5+
INSTALL PLUGIN test_udf_services SONAME 'TESTUDFSERVICES';
6+
# Define the function
7+
CREATE FUNCTION test_udf_services_udf RETURNS INT
8+
SONAME "TESTUDFSERVICES";
9+
# Uninstall the plugin
10+
UNINSTALL PLUGIN test_udf_services;
11+
# Install the plugin again. Should not fail
12+
INSTALL PLUGIN test_udf_services SONAME 'TESTUDFSERVICES';
13+
# Cleanup
14+
DROP FUNCTION test_udf_services_udf;
15+
UNINSTALL PLUGIN test_udf_services;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$TESTUDFSERVICES_OPT

mysql-test/t/udf_services.test

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--source include/not_embedded.inc
2+
3+
--echo #
4+
--echo # Bug #20085672: CRYPTIC ERROR WHEN FAILING TO UNLOAD A DYNAMIC LIBRARY
5+
--echo #
6+
7+
--echo # Install the plugin
8+
--replace_result $TESTUDFSERVICES TESTUDFSERVICES
9+
eval INSTALL PLUGIN test_udf_services SONAME '$TESTUDFSERVICES';
10+
11+
--echo # Define the function
12+
--replace_result $TESTUDFSERVICES TESTUDFSERVICES
13+
eval CREATE FUNCTION test_udf_services_udf RETURNS INT
14+
SONAME "$TESTUDFSERVICES";
15+
16+
--echo # Uninstall the plugin
17+
UNINSTALL PLUGIN test_udf_services;
18+
19+
--echo # Install the plugin again. Should not fail
20+
--replace_result $TESTUDFSERVICES TESTUDFSERVICES
21+
eval INSTALL PLUGIN test_udf_services SONAME '$TESTUDFSERVICES';
22+
23+
--echo # Cleanup
24+
DROP FUNCTION test_udf_services_udf;
25+
UNINSTALL PLUGIN test_udf_services;

packaging/deb-jessie/source/include-binaries

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2014, 2016, 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
@@ -30,4 +30,5 @@ debian/extra/qa_auth_interface-plugin
3030
debian/extra/qa_auth_server-plugin
3131
debian/extra/semisync_master-plugin
3232
debian/extra/semisync_slave-plugin
33+
debian/extra/test_udf_services-plugin
3334
debian/extra/validate_password-plugin

packaging/deb-precise/source/include-binaries

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2014, 2016, 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
@@ -30,4 +30,5 @@ debian/extra/qa_auth_interface-plugin
3030
debian/extra/qa_auth_server-plugin
3131
debian/extra/semisync_master-plugin
3232
debian/extra/semisync_slave-plugin
33+
debian/extra/test_udf_services-plugin
3334
debian/extra/validate_password-plugin

packaging/deb-trusty/source/include-binaries

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2014, 2016, 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
@@ -30,4 +30,5 @@ debian/extra/qa_auth_interface-plugin
3030
debian/extra/qa_auth_server-plugin
3131
debian/extra/semisync_master-plugin
3232
debian/extra/semisync_slave-plugin
33+
debian/extra/test_udf_services-plugin
3334
debian/extra/validate_password-plugin

packaging/deb-utopic/source/include-binaries

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2015, 2016, 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
@@ -30,4 +30,5 @@ debian/extra/qa_auth_interface-plugin
3030
debian/extra/qa_auth_server-plugin
3131
debian/extra/semisync_master-plugin
3232
debian/extra/semisync_slave-plugin
33+
debian/extra/test_udf_services-plugin
3334
debian/extra/validate_password-plugin

packaging/deb-vivid/source/include-binaries

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2015, 2016, 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
@@ -30,4 +30,5 @@ debian/extra/qa_auth_interface-plugin
3030
debian/extra/qa_auth_server-plugin
3131
debian/extra/semisync_master-plugin
3232
debian/extra/semisync_slave-plugin
33+
debian/extra/test_udf_services-plugin
3334
debian/extra/validate_password-plugin

packaging/deb-wheezy/source/include-binaries

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2014, 2016, 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
@@ -30,4 +30,5 @@ debian/extra/qa_auth_interface-plugin
3030
debian/extra/qa_auth_server-plugin
3131
debian/extra/semisync_master-plugin
3232
debian/extra/semisync_slave-plugin
33+
debian/extra/test_udf_services-plugin
3334
debian/extra/validate_password-plugin

0 commit comments

Comments
 (0)