From: Tor Didriksen Date: October 1 2010 9:07am Subject: bzr commit into mysql-next-mr-bugfixing branch (tor.didriksen:3310) Bug#52002 List-Archive: http://lists.mysql.com/commits/119604 X-Bug: 52002 Message-Id: <20101001090711.71704372C@atum07.norway.sun.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6084346024674523118==" --===============6084346024674523118== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///export/home/didrik/repo/next-mr-bf-binlogcore/ based on revid:luis.soares@stripped 3310 Tor Didriksen 2010-10-01 Bug#52002 binlog_index may cause incorrect failure report on failing test that follows it For crash testing: kill the server without generating core file. @ include/my_dbug.h Use kill(getpid(), SIGKILL) which cannot be caught by signal handlers. All DBUG_XXX macros should be no-ops in optimized mode, do that for DBUG_ABORT as well. @ sql/binlog.cc Kill server without generating core. @ sql/handler.cc Kill server without generating core. @ unittest/gunit/CMakeLists.txt Add unit test. @ unittest/gunit/dbug-t.cc Add unit test. added: unittest/gunit/dbug-t.cc modified: include/my_dbug.h sql/binlog.cc sql/handler.cc unittest/gunit/CMakeLists.txt === modified file 'include/my_dbug.h' --- a/include/my_dbug.h 2010-07-15 11:16:06 +0000 +++ b/include/my_dbug.h 2010-10-01 09:07:06 +0000 @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -13,8 +13,15 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _dbug_h -#define _dbug_h +#ifndef MY_DBUG_INCLUDED +#define MY_DBUG_INCLUDED + +#ifndef __WIN__ +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#include +#endif /* not __WIN__ */ #ifdef __cplusplus extern "C" { @@ -111,6 +118,19 @@ extern const char* _db_get_func_(void); #define DBUG_CRASH_VOID_RETURN \ DBUG_CHECK_CRASH (_db_get_func_(), "_crash_return") +/* + Make the program fail, without creating a core file. + abort() will send SIGABRT which (most likely) generates core. + Use SIGKILL instead, which cannot be caught. + An alternative would be to use _exit(EXIT_FAILURE), + but then valgrind would report lots of memory leaks. + */ +#ifdef __WIN__ +#define DBUG_SUICIDE() DBUG_ABORT() +#else +#define DBUG_SUICIDE() (_db_flush_(), kill(getpid(), SIGKILL)) +#endif + #else /* No debugger */ #define DBUG_ENTER(a1) @@ -139,10 +159,11 @@ extern const char* _db_get_func_(void); #define DBUG_EXPLAIN_INITIAL(buf,len) #define DEBUGGER_OFF do { } while(0) #define DEBUGGER_ON do { } while(0) -#define DBUG_ABORT() abort() +#define DBUG_ABORT() do { } while(0) #define DBUG_CRASH_ENTER(func) #define DBUG_CRASH_RETURN(val) do { return(val); } while(0) #define DBUG_CRASH_VOID_RETURN do { return; } while(0) +#define DBUG_SUICIDE() do { } while(0) #endif @@ -164,4 +185,5 @@ void debug_sync_point(const char* lock_n #ifdef __cplusplus } #endif -#endif + +#endif /* MY_DBUG_INCLUDED */ === modified file 'sql/binlog.cc' --- a/sql/binlog.cc 2010-09-28 15:30:47 +0000 +++ b/sql/binlog.cc 2010-10-01 09:07:06 +0000 @@ -1572,7 +1572,7 @@ bool MYSQL_BIN_LOG::open(const char *log sql_print_error("MSYQL_BIN_LOG::open failed to sync the index file."); DBUG_RETURN(1); } - DBUG_EXECUTE_IF("crash_create_non_critical_before_update_index", DBUG_ABORT();); + DBUG_EXECUTE_IF("crash_create_non_critical_before_update_index", DBUG_SUICIDE();); #endif write_error= 0; @@ -1672,7 +1672,7 @@ bool MYSQL_BIN_LOG::open(const char *log if (write_file_name_to_index_file) { #ifdef HAVE_REPLICATION - DBUG_EXECUTE_IF("crash_create_critical_before_update_index", DBUG_ABORT();); + DBUG_EXECUTE_IF("crash_create_critical_before_update_index", DBUG_SUICIDE();); #endif DBUG_ASSERT(my_b_inited(&index_file) != 0); @@ -1691,7 +1691,7 @@ bool MYSQL_BIN_LOG::open(const char *log goto err; #ifdef HAVE_REPLICATION - DBUG_EXECUTE_IF("crash_create_after_update_index", DBUG_ABORT();); + DBUG_EXECUTE_IF("crash_create_after_update_index", DBUG_SUICIDE();); #endif } } @@ -2143,7 +2143,7 @@ int MYSQL_BIN_LOG::purge_first_log(Relay /* Store where we are in the new file for the execution thread */ flush_relay_log_info(rli); - DBUG_EXECUTE_IF("crash_before_purge_logs", DBUG_ABORT();); + DBUG_EXECUTE_IF("crash_before_purge_logs", DBUG_SUICIDE();); mysql_mutex_lock(&rli->log_space_lock); rli->relay_log.purge_logs(to_purge_if_included, included, @@ -2271,7 +2271,7 @@ int MYSQL_BIN_LOG::purge_logs(const char break; } - DBUG_EXECUTE_IF("crash_purge_before_update_index", DBUG_ABORT();); + DBUG_EXECUTE_IF("crash_purge_before_update_index", DBUG_SUICIDE();); if ((error= sync_purge_index_file())) { @@ -2286,7 +2286,7 @@ int MYSQL_BIN_LOG::purge_logs(const char goto err; } - DBUG_EXECUTE_IF("crash_purge_critical_after_update_index", DBUG_ABORT();); + DBUG_EXECUTE_IF("crash_purge_critical_after_update_index", DBUG_SUICIDE();); err: /* Read each entry from purge_index_file and delete the file. */ @@ -2296,7 +2296,7 @@ err: " that would be purged."); close_purge_index_file(); - DBUG_EXECUTE_IF("crash_purge_non_critical_after_update_index", DBUG_ABORT();); + DBUG_EXECUTE_IF("crash_purge_non_critical_after_update_index", DBUG_SUICIDE();); if (need_mutex) mysql_mutex_unlock(&LOCK_index); @@ -3461,7 +3461,7 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_C DBUG_PRINT("info", ("error writing binlog cache: %d", write_error)); DBUG_PRINT("info", ("crashing before writing xid")); - DBUG_ABORT(); + DBUG_SUICIDE(); }); if ((write_error= write_cache(cache, false, false))) @@ -3476,7 +3476,7 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_C bool synced= 0; if (flush_and_sync(&synced)) goto err; - DBUG_EXECUTE_IF("half_binlogged_transaction", DBUG_ABORT();); + DBUG_EXECUTE_IF("half_binlogged_transaction", DBUG_SUICIDE();); if (cache->error) // Error on read { sql_print_error(ER(ER_ERROR_ON_READ), cache->file_name, errno); === modified file 'sql/handler.cc' --- a/sql/handler.cc 2010-09-01 02:51:08 +0000 +++ b/sql/handler.cc 2010-10-01 09:07:06 +0000 @@ -1169,7 +1169,7 @@ int ha_commit_trans(THD *thd, bool all) uint rw_ha_count; bool rw_trans; - DBUG_EXECUTE_IF("crash_commit_before", DBUG_ABORT();); + DBUG_EXECUTE_IF("crash_commit_before", DBUG_SUICIDE();); /* Close all cursors that can not survive COMMIT */ if (is_real_trans) /* not a statement commit */ @@ -1221,7 +1221,7 @@ int ha_commit_trans(THD *thd, bool all) } status_var_increment(thd->status_var.ha_prepare_count); } - DBUG_EXECUTE_IF("crash_commit_after_prepare", DBUG_ABORT();); + DBUG_EXECUTE_IF("crash_commit_after_prepare", DBUG_SUICIDE();); if (error || (is_real_trans && xid && (error= !(cookie= tc_log->log_xid(thd, xid))))) { @@ -1229,13 +1229,13 @@ int ha_commit_trans(THD *thd, bool all) error= 1; goto end; } - DBUG_EXECUTE_IF("crash_commit_after_log", DBUG_ABORT();); + DBUG_EXECUTE_IF("crash_commit_after_log", DBUG_SUICIDE();); } error=ha_commit_one_phase(thd, all) ? (cookie ? 2 : 1) : 0; - DBUG_EXECUTE_IF("crash_commit_before_unlog", DBUG_ABORT();); + DBUG_EXECUTE_IF("crash_commit_before_unlog", DBUG_SUICIDE();); if (cookie) tc_log->unlog(cookie, xid); - DBUG_EXECUTE_IF("crash_commit_after", DBUG_ABORT();); + DBUG_EXECUTE_IF("crash_commit_after", DBUG_SUICIDE();); RUN_HOOK(transaction, after_commit, (thd, FALSE)); end: if (rw_trans) === modified file 'unittest/gunit/CMakeLists.txt' --- a/unittest/gunit/CMakeLists.txt 2010-07-30 08:34:23 +0000 +++ b/unittest/gunit/CMakeLists.txt 2010-10-01 09:07:06 +0000 @@ -207,7 +207,7 @@ IF (CMAKE_CXX_COMPILER_ID STREQUAL "SunP ENDIF() # Add tests (link them with sql library) -SET(TESTS sql_list mdl mdl_mytap my_regex thread_utils) +SET(TESTS dbug sql_list mdl mdl_mytap my_regex thread_utils) FOREACH(test ${TESTS}) ADD_EXECUTABLE(${test}-t ${test}-t.cc) TARGET_LINK_LIBRARIES(${test}-t gunit sqlgunitlib strings dbug regex) === added file 'unittest/gunit/dbug-t.cc' --- a/unittest/gunit/dbug-t.cc 1970-01-01 00:00:00 +0000 +++ b/unittest/gunit/dbug-t.cc 2010-10-01 09:07:06 +0000 @@ -0,0 +1,35 @@ +/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +// First include (the generated) my_config.h, to get correct platform defines, +// then gtest.h (before any other MySQL headers), to avoid min() macros etc ... +#include "my_config.h" +#include + +#include "my_global.h" +#include "my_dbug.h" + +#if defined(DBUG_OFF) +TEST(DebugTest, NoSuicide) +{ + DBUG_SUICIDE(); +} +#else +TEST(DebugDeathTest, Suicide) +{ + ::testing::FLAGS_gtest_death_test_style = "threadsafe"; + EXPECT_DEATH_IF_SUPPORTED(DBUG_SUICIDE(), ""); +} +#endif --===============6084346024674523118== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/tor.didriksen@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: tor.didriksen@stripped\ # 3kzqf0p9ixak7gne # target_branch: file:///export/home/didrik/repo/next-mr-bf-\ # binlogcore/ # testament_sha1: 1dc5d352d1501da0ddf96344a572bb5b1e0aa3e3 # timestamp: 2010-10-01 11:07:11 +0200 # base_revision_id: luis.soares@stripped\ # k04pqy3nk9xf8vht # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWSmsRHwABmF/gFARRABYd/// f+//4L////pgDgb7xj3XmaAkl1ssp68lN9d6p4HRrXrqjT573Chp0fez7CSSaNEaDRGU9ppT8VM1 Bieo0aZpPUaaHlGQDTQJKBBpqYNFMhlNGmI00eoANAAAANAyJkFMEwimniJ6mg0DagADQAAeoAMR TCnlTxUxp5TZITQ0B6jQADQAAAA2qgNKfoQTym0epNMmgNADQBoAAAAJIgmgCaEwINAE01MI01G0 TQaM1GgekUEF72R1UOben0278G/GeqW5BYLEZBlM5wnrsw/LsxERXbba9BGY76dX3Hfmgh2G15I0 ZDrp3v8zb5eI8njiuaHNR3ccro55mAKaGEbocjR1vAggS2c+q4QmnCtTREEZINdXKom8J9FIShOF dpuL0i82ugUwJDJGfrdBEqLC52SCQ3JnsaOLjG20K68q+6+3IhzqKISJSASBHHZ8QAboC4ZtgtKy Q31kmUFHKmchSIEp6GdKCaSgrcRCiCUkJhbU6rCMIqri2NsKaosnghKbW56jcno9OwPZxjflNyEK OQfs8E9fShEhPYdk9ZdXVqoUc7bpVn5q4koUZQA+PEtYWMvo/5CaXEUGnlgJizZMQb9cgoN31Ftq CWhNV++ktCRbFXJQJvrjDhc5Syw98tzHVsqdCRB2cMDzPvugXffoddO4sKf3tRLqUyvYzXLPpQlF ErKA1V7wJCwUGIc9ceDNWc9BD75DbMleRuw7aRz0lI/Ak6O+/Hg1V+Ei6b6rlZF75HiLlt6u3scz VCd/K5g/V5x2qhH7iLlWjwyGUy1KplR7BEgwdQJkM0wzMhmFLzJI3IVm5mJsrqzockpyLXAkacNI yylGXZ043EVxG72w9jtk4WdoJ2bcyF4IxDLGpvt0UQuY1QJD6Bzrysl9Pq82d/sOx4xotiqQy96Z MILvASs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