Skip to content

Commit

Permalink
Bug#27108794 CLANG/ASAN: STACK-USE-AFTER-SCOPE TABLE_UPGRADE_GUARD::~…
Browse files Browse the repository at this point in the history
…TABLE_UPGRADE_GUARD

To repeat: cmake -DWITH_ASAN=1 -DWITH_ASAN_SCOPE=1
./mtr --mem --sanitize main.dd_upgrade_error

A few dd tests fail with:
==26861==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7000063bf5e8 at pc 0x00010d4dbe8b bp 0x7000063bda40 sp 0x7000063bda38
READ of size 8 at 0x7000063bf5e8 thread T2
    #0 0x10d4dbe8a in Prealloced_array<st_plugin_int**, 16ul>::empty() const prealloced_array.h:186
    #1 0x10d406a8b in lex_end(LEX*) sql_lex.cc:560
    percona#2 0x10dae4b6d in dd::upgrade::Table_upgrade_guard::~Table_upgrade_guard() (mysqld:x86_64+0x100f87b6d)
    percona#3 0x10dadc557 in dd::upgrade::migrate_table_to_dd(THD*, std::__1::basic_string<char, std::__1::char_traits<char>, Stateless_allocator<char, dd::String_type_alloc, My_free_functor> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, Stateless_allocator<char, dd::String_type_alloc, My_free_functor> > const&, bool) (mysqld:x86_64+0x100f7f557)
    percona#4 0x10dad7e85 in dd::upgrade::migrate_plugin_table_to_dd(THD*) (mysqld:x86_64+0x100f7ae85)
    percona#5 0x10daec6a1 in dd::upgrade::do_pre_checks_and_initialize_dd(THD*) upgrade.cc:1216
    percona#6 0x10cd0a5c0 in bootstrap::handle_bootstrap(void*) bootstrap.cc:336

Change-Id: I265ec6dd97ee8076aaf03763840c0cdf9e20325b
Fix: increase lifetime of 'LEX lex;' which is used by 'table_guard'
  • Loading branch information
Tor Didriksen committed Nov 13, 2017
1 parent 976fbc5 commit 9a055d9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sql/dd/upgrade/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,7 @@ static bool migrate_table_to_dd(THD *thd,
}

// Object to handle cleanup.
LEX lex;
Table_upgrade_guard table_guard(thd, table, &table->mem_root);

// Dont upgrade tables, we are fixing dependency for views.
Expand Down Expand Up @@ -1789,7 +1790,6 @@ static bool migrate_table_to_dd(THD *thd,
// open_table_from_share and partition expression parsing needs a
// valid SELECT_LEX to parse generated columns
LEX *lex_saved= thd->lex;
LEX lex;
thd->lex= &lex;
lex_start(thd);
table_guard.update_lex(lex_saved);
Expand Down

0 comments on commit 9a055d9

Please sign in to comment.