diff --git a/include/my_stacktrace.h b/include/my_stacktrace.h index cd7d77d841b7..ee0386789479 100644 --- a/include/my_stacktrace.h +++ b/include/my_stacktrace.h @@ -60,25 +60,6 @@ void my_write_core(int sig); #endif -/* print stack traces for all threads */ -void my_pstack(); - -/* print stack traces for all threads before assert failures */ -#define assert_with_stack_traces(expr) \ - do { if(!(expr)) { my_pstack(); assert(0); } } while(0) - -/* print stack traces for all threads before abort. Please note - that when using this with ; in the end, a null statement will - be generated in the end. It is fine as long as compilers don't - complain. - */ - -#define abort_with_stack_traces() \ - { my_pstack(); abort(); } - -#define assert_0_with_stack_traces() \ - { my_pstack(); assert(0); } - /** Async-signal-safe utility functions used by signal handler routines. diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c index 901254b93183..264dfba350ae 100644 --- a/mysys/stacktrace.c +++ b/mysys/stacktrace.c @@ -473,64 +473,6 @@ void my_write_core(int sig) #endif } - -/* print stack traces for all threads */ -void my_pstack() -{ -#ifndef __WIN__ - /* Print out the current stack trace */ - - static const int max_num_of_frames = 100; - void *stack_trace[max_num_of_frames]; - int num_of_frames = backtrace(stack_trace, max_num_of_frames); - char **frames = backtrace_symbols(stack_trace, num_of_frames); - if (!frames) - { - my_safe_printf_stderr("backtrace_symbols didn't return valid data."); - return; - } - - my_safe_printf_stderr("\nThe current stack traces:\n"); - for (int i = 0; i < num_of_frames; ++i) - { - my_safe_printf_stderr("%s\n", frames[i]); - } - free(frames); - - /* Print out all the stack traces */ - - char cmd[64]; - pid_t pid = getpid(); - sprintf(cmd, "pstack %d", pid); - - my_safe_printf_stderr("\nAll stack traces from %s:\n", cmd); - FILE *fp = popen(cmd, "r"); - if (!fp) - { - my_safe_printf_stderr("Couldn't run \"%s\" by popen.\n", cmd); - return; - } - - static const size_t max_line_length = 4095; - char line_buf[max_line_length + 1]; - uint output_lines = 0; - while (fgets(line_buf, max_line_length, fp)) - { - my_write_stderr(line_buf, strlen(line_buf)); - ++output_lines; - } - fclose(fp); - if (0 == output_lines) - { - my_safe_printf_stderr("No stack traces were printed out. " - "This probably was because mysqld didn't have " - "sufficient privileges, and/or some required system " - "settings (suid_dumpable, ulimit, etc...) were not " - "set correctly.\n"); - } -#endif /* not __WIN__ */ -} - #else /* __WIN__*/ #include diff --git a/sql/error_stats.cc b/sql/error_stats.cc index 158b4547a8a8..5fd6143baa2a 100644 --- a/sql/error_stats.cc +++ b/sql/error_stats.cc @@ -37,7 +37,7 @@ void init_global_error_stats(void) for (uint j = 0; j < (uint)errmsg_section_size[i]; j++) { if (k >= array_elements(error_names) || error_names[k].code != errmsg_section_start[i] + j) { - abort_with_stack_traces(); + abort(); } k++; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 4ff35c51a57a..ae8fbce45f4b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -44,7 +44,6 @@ #include "sql_join_buffer.h" // JOIN_CACHE #include "sql_optimizer.h" // JOIN #include "sql_tmp_table.h" // tmp tables -#include "my_stacktrace.h" // abort_with_stack_traces #ifdef TARGET_OS_LINUX #include @@ -2962,7 +2961,7 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) DBUG_PRINT("error",("Table type %d found",tab->type)); /* purecov: deadcode */ break; /* purecov: deadcode */ case JT_UNKNOWN: - abort_with_stack_traces(); /* purecov: deadcode */ + abort(); /* purecov: deadcode */ } // Materialize derived tables prior to accessing them. if (tab->table->pos_in_table_list->uses_materialization()) diff --git a/sql/srv_session.cc b/sql/srv_session.cc index 0eedcde3c3af..282d99428311 100644 --- a/sql/srv_session.cc +++ b/sql/srv_session.cc @@ -61,7 +61,7 @@ class Auto_rw_lock_read rw_lock = lock; else { my_safe_printf_stderr("Failed to initialize Auto_rw_lock_read"); - abort_with_stack_traces(); + abort(); } } @@ -87,7 +87,7 @@ class Auto_rw_lock_write rw_lock = lock; else { my_safe_printf_stderr("Failed to initialize Auto_rw_lock_write"); - abort_with_stack_traces(); + abort(); } } diff --git a/sql/table_stats.cc b/sql/table_stats.cc index cc167b0d2cf4..598924568f3c 100644 --- a/sql/table_stats.cc +++ b/sql/table_stats.cc @@ -1,7 +1,6 @@ #include "sql_base.h" #include "sql_show.h" #include "my_atomic.h" -#include "my_stacktrace.h" // abort_with_stack_traces HASH global_table_stats; @@ -256,7 +255,7 @@ void init_global_table_stats(void) 0, 0, (my_hash_get_key)get_key_table_stats, (my_hash_free_key)free_table_stats, 0)) { sql_print_error("Initializing global_table_stats failed."); - abort_with_stack_traces(); + abort(); } } diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index a0c9e2d1e85b..9b714a565a00 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -710,7 +710,7 @@ buf_page_is_corrupted( read_buf + FIL_PAGE_LSN), current_lsn); #ifdef XTRABACKUP - abort_with_stack_traces(); + abort(); #endif /* XTRABACKUP */ } } diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 9742f32e8647..7916e78f88c5 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -6315,7 +6315,7 @@ _fil_io( if (space->size > 0 && space->size <= block_offset) { ulint actual_size; - assert_with_stack_traces(block_offset < 512 * 1024 * 1024); + assert(block_offset < 512 * 1024 * 1024); mutex_exit(&fil_system->mutex); fil_extend_space_to_desired_size(&actual_size, space->id, diff --git a/storage/innobase/include/ut0dbg.h b/storage/innobase/include/ut0dbg.h index dd3dfd260517..3f5baef0a3c9 100644 --- a/storage/innobase/include/ut0dbg.h +++ b/storage/innobase/include/ut0dbg.h @@ -26,12 +26,10 @@ Created 1/30/1994 Heikki Tuuri #ifndef ut0dbg_h #define ut0dbg_h -#include "my_stacktrace.h" // assert_0_with_stack_traces - #ifdef UNIV_INNOCHECKSUM #define ut_a assert #define ut_ad assert -#define ut_error assert_0_with_stack_traces() +#define ut_error assert(0) #else /* !UNIV_INNOCHECKSUM */ #include "univ.i" @@ -64,7 +62,7 @@ ut_dbg_assertion_failed( UNIV_COLD MY_ATTRIBUTE((nonnull(2))); /** Abort the execution. */ -# define UT_DBG_PANIC abort_with_stack_traces() +# define UT_DBG_PANIC abort() /** Abort execution if EXPR does not evaluate to nonzero. @param EXPR assertion expression that should hold */ diff --git a/storage/innobase/include/ut0rbt.h b/storage/innobase/include/ut0rbt.h index e6130740327b..e0593e99bde1 100644 --- a/storage/innobase/include/ut0rbt.h +++ b/storage/innobase/include/ut0rbt.h @@ -33,13 +33,12 @@ Created 2007-03-20 Sunny Bains #include #include #include -#include "my_stacktrace.h" //assert_with_stack_traces,assert_0_with_stack_traces #define ut_malloc malloc #define ut_free free #define ulint unsigned long -#define ut_a(c) assert_with_stack_traces(c) -#define ut_error assert_0_with_stack_traces() +#define ut_a(c) assert(c) +#define ut_error assert(0) #define ibool unsigned int #define TRUE 1 #define FALSE 0 diff --git a/storage/rocksdb/event_listener.cc b/storage/rocksdb/event_listener.cc index 6ee6268fcf05..2da77a16f684 100644 --- a/storage/rocksdb/event_listener.cc +++ b/storage/rocksdb/event_listener.cc @@ -88,7 +88,7 @@ void Rdb_event_listener::OnBackgroundError( sql_print_error("RocksDB: BackgroundErrorReason: %d", (int)reason); if (status->IsCorruption()) { rdb_persist_corruption_marker(); - abort_with_stack_traces(); + abort(); } } } // namespace myrocks diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 68bedd015837..961ca5d1d17b 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -4710,7 +4710,7 @@ static ulonglong rdb_get_int_col_max_value(const Field *field) { max_value = 0x7FFFFFFFFFFFFFFFULL; break; default: - abort_with_stack_traces(); + abort(); } return max_value; @@ -10235,7 +10235,7 @@ void Rdb_drop_index_thread::run() { "from cf id %u. MyRocks data dictionary may " "get corrupted.", d.cf_id); - abort_with_stack_traces(); + abort(); } rocksdb::ColumnFamilyHandle *cfh = cf_manager.get_cf(d.cf_id); DBUG_ASSERT(cfh); @@ -12333,7 +12333,7 @@ void rdb_handle_io_error(const rocksdb::Status status, rdb_log_status_error(status, "failed to write to WAL"); /* NO_LINT_DEBUG */ sql_print_error("MyRocks: aborting on WAL write error."); - abort_with_stack_traces(); + abort(); break; } case RDB_IO_ERROR_BG_THREAD: { @@ -12344,7 +12344,7 @@ void rdb_handle_io_error(const rocksdb::Status status, rdb_log_status_error(status, "failed on I/O"); /* NO_LINT_DEBUG */ sql_print_error("MyRocks: aborting on I/O error."); - abort_with_stack_traces(); + abort(); break; } default: @@ -12356,14 +12356,14 @@ void rdb_handle_io_error(const rocksdb::Status status, rdb_persist_corruption_marker(); /* NO_LINT_DEBUG */ sql_print_error("MyRocks: aborting because of data corruption."); - abort_with_stack_traces(); + abort(); } else if (!status.ok()) { switch (err_type) { case RDB_IO_ERROR_DICT_COMMIT: { rdb_log_status_error(status, "Failed to write to WAL (dictionary)"); /* NO_LINT_DEBUG */ sql_print_error("MyRocks: aborting on WAL write error."); - abort_with_stack_traces(); + abort(); break; } default: diff --git a/storage/rocksdb/properties_collector.cc b/storage/rocksdb/properties_collector.cc index 41def140f8c5..a74c97c61d87 100644 --- a/storage/rocksdb/properties_collector.cc +++ b/storage/rocksdb/properties_collector.cc @@ -169,7 +169,7 @@ void Rdb_tbl_prop_coll::CollectStatsForRow(const rocksdb::Slice &key, sql_print_error("RocksDB: Unexpected entry type found: %u. " "This should not happen so aborting the system.", type); - abort_with_stack_traces(); + abort(); break; } @@ -362,7 +362,7 @@ int Rdb_index_stats::unmaterialize(const std::string &s, sql_print_error("Index stats version %d was outside of supported range. " "This should not happen so aborting the system.", version); - abort_with_stack_traces(); + abort(); } size_t needed = sizeof(stats.m_gl_index_id.cf_id) + diff --git a/storage/rocksdb/rdb_compact_filter.h b/storage/rocksdb/rdb_compact_filter.h index c457fba4af26..4b1c8c732240 100644 --- a/storage/rocksdb/rdb_compact_filter.h +++ b/storage/rocksdb/rdb_compact_filter.h @@ -166,7 +166,7 @@ class Rdb_compact_filter : public rocksdb::CompactionFilter { sql_print_error("Decoding ttl from PK value failed in compaction filter, " "for index (%u,%u), val: %s", m_prev_index.cf_id, m_prev_index.index_id, buf.c_str()); - abort_with_stack_traces(); + abort(); } /* diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc index 068eace701b6..1e5a61f75f09 100644 --- a/storage/rocksdb/rdb_datadic.cc +++ b/storage/rocksdb/rdb_datadic.cc @@ -3501,7 +3501,7 @@ GL_INDEX_ID Rdb_tbl_def::get_autoincr_gl_index_id() { } // Every table must have a primary key, even if it's hidden. - abort_with_stack_traces(); + abort(); return GL_INDEX_ID(); } @@ -4780,7 +4780,7 @@ bool Rdb_dict_manager::get_index_info( "and it may be a bug.", index_info->m_index_dict_version, index_info->m_index_type, index_info->m_kv_version, index_info->m_ttl_duration); - abort_with_stack_traces(); + abort(); } return found; @@ -5043,7 +5043,7 @@ void Rdb_dict_manager::resume_drop_indexes() const { "bug.", max_index_id_in_dict, gl_index_id.cf_id, gl_index_id.index_id); - abort_with_stack_traces(); + abort(); } } } @@ -5092,7 +5092,7 @@ void Rdb_dict_manager::log_start_drop_index(GL_INDEX_ID gl_index_id, "from index id (%u,%u). MyRocks data dictionary may " "get corrupted.", gl_index_id.cf_id, gl_index_id.index_id); - abort_with_stack_traces(); + abort(); } } } diff --git a/storage/rocksdb/rdb_datadic.h b/storage/rocksdb/rdb_datadic.h index d38e37e406c6..0a7d5e0f0a88 100644 --- a/storage/rocksdb/rdb_datadic.h +++ b/storage/rocksdb/rdb_datadic.h @@ -1419,7 +1419,7 @@ class Rdb_system_merge_op : public rocksdb::AssociativeMergeOperator { value.size() != RDB_SIZEOF_AUTO_INCREMENT_VERSION + ROCKSDB_SIZEOF_AUTOINC_VALUE || GetVersion(value) > Rdb_key_def::AUTO_INCREMENT_VERSION) { - abort_with_stack_traces(); + abort(); } uint64_t merged_value = Deserialize(value); @@ -1428,7 +1428,7 @@ class Rdb_system_merge_op : public rocksdb::AssociativeMergeOperator { if (existing_value->size() != RDB_SIZEOF_AUTO_INCREMENT_VERSION + ROCKSDB_SIZEOF_AUTOINC_VALUE || GetVersion(*existing_value) > Rdb_key_def::AUTO_INCREMENT_VERSION) { - abort_with_stack_traces(); + abort(); } merged_value = std::max(merged_value, Deserialize(*existing_value)); diff --git a/storage/rocksdb/rdb_i_s.cc b/storage/rocksdb/rdb_i_s.cc index a0b8d94ad078..8c097a5649f8 100644 --- a/storage/rocksdb/rdb_i_s.cc +++ b/storage/rocksdb/rdb_i_s.cc @@ -782,7 +782,7 @@ static int rdb_i_s_global_info_fill_table( "from CF with id = %u. MyRocks data dictionary may " "be corrupted.", cf_handle->GetID()); - abort_with_stack_traces(); + abort(); } snprintf(cf_id_buf, INT_BUF_LEN, "%u", cf_handle->GetID()); diff --git a/storage/rocksdb/rdb_io_watchdog.cc b/storage/rocksdb/rdb_io_watchdog.cc index 7b229eee47de..039ab05c2edc 100644 --- a/storage/rocksdb/rdb_io_watchdog.cc +++ b/storage/rocksdb/rdb_io_watchdog.cc @@ -42,7 +42,7 @@ void Rdb_io_watchdog::expire_io_callback(union sigval timer_data) { "Shutting the service down.", m_write_timeout); - abort_with_stack_traces(); + abort(); } void Rdb_io_watchdog::io_check_callback(union sigval timer_data) { diff --git a/storage/rocksdb/rdb_utils.h b/storage/rocksdb/rdb_utils.h index 34864c72cc66..8ec60a6813ce 100644 --- a/storage/rocksdb/rdb_utils.h +++ b/storage/rocksdb/rdb_utils.h @@ -82,7 +82,7 @@ namespace myrocks { do { \ if (!(expr)) { \ my_safe_printf_stderr("\nShip assert failure: \'%s\'\n", #expr); \ - abort_with_stack_traces(); \ + abort(); \ } \ } while (0) #endif // SHIP_ASSERT @@ -235,7 +235,7 @@ inline void rdb_check_mutex_call_result(const char *function_name, // This will hopefully result in a meaningful stack trace which we can use // to efficiently debug the root cause. - abort_with_stack_traces(); + abort(); } }