|
| 1 | +--source include/have_debug.inc |
| 2 | +--source include/have_debug_sync.inc |
| 3 | +--source include/not_embedded.inc |
| 4 | + |
| 5 | +--echo # |
| 6 | +--echo # MDEV-39146 Fix stack-use-after-return in PROCESSLIST for event threads |
| 7 | +--echo # |
| 8 | + |
| 9 | +CREATE USER definer@localhost; |
| 10 | +GRANT EVENT ON *.* TO definer@localhost; |
| 11 | +GRANT SUPER ON *.* TO definer@localhost; |
| 12 | + |
| 13 | +SET DEBUG_SYNC= 'RESET'; |
| 14 | + |
| 15 | +--echo # Per-session DEBUG_SYNC: must arm from inside the event body (its own |
| 16 | +--echo # thd), not from another connection. |
| 17 | +--delimiter | |
| 18 | +CREATE DEFINER=definer@localhost EVENT ev |
| 19 | +ON SCHEDULE AT CURRENT_TIMESTAMP |
| 20 | +DO |
| 21 | +BEGIN |
| 22 | + SET DEBUG_SYNC= 'event_worker_thread_after_execute_returned SIGNAL event_execute_returned'; |
| 23 | + SET DEBUG_SYNC= 'now SIGNAL definer_ctx_active WAIT_FOR event_may_finish'; |
| 24 | +END| |
| 25 | +--delimiter ; |
| 26 | + |
| 27 | +SET GLOBAL event_scheduler= ON; |
| 28 | + |
| 29 | +--echo # Connect 'waiter' now: iterate() holds server_threads' rwlock for the |
| 30 | +--echo # whole scan; connecting after would deadlock (needs that lock's |
| 31 | +--echo # write side). |
| 32 | +connect (waiter, localhost, root,,); |
| 33 | +connection default; |
| 34 | + |
| 35 | +SET DEBUG_SYNC= 'now WAIT_FOR definer_ctx_active'; |
| 36 | + |
| 37 | +--echo # Pause right after processlist_callback() captures the |
| 38 | +--echo # DEFINER-switched security_ctx, before USER/HOST are read. |
| 39 | +SET @saved_dbug= @@SESSION.debug_dbug; |
| 40 | +SET SESSION debug_dbug= '+d,processlist_callback_pause_after_sctx_capture'; |
| 41 | +SET DEBUG_SYNC= 'processlist_callback_captured_sctx SIGNAL scanner_captured WAIT_FOR let_scanner_continue'; |
| 42 | + |
| 43 | +--echo # Filter by name: checks the value read through the captured pointer. |
| 44 | +--send SELECT user, host FROM information_schema.processlist WHERE user = 'definer' |
| 45 | + |
| 46 | +connection waiter; |
| 47 | +SET DEBUG_SYNC= 'now WAIT_FOR scanner_captured'; |
| 48 | + |
| 49 | +--echo # Let the event finish and execute() return. |
| 50 | +SET DEBUG_SYNC= 'now SIGNAL event_may_finish WAIT_FOR event_execute_returned TIMEOUT 60'; |
| 51 | + |
| 52 | +--echo # Release the scanner to dereference the pointer it captured. |
| 53 | +SET DEBUG_SYNC= 'now SIGNAL let_scanner_continue'; |
| 54 | + |
| 55 | +--disconnect waiter |
| 56 | +--connection default |
| 57 | +--reap |
| 58 | + |
| 59 | +SET SESSION debug_dbug= @saved_dbug; |
| 60 | +SET DEBUG_SYNC= 'RESET'; |
| 61 | + |
| 62 | +SET GLOBAL event_scheduler= OFF; |
| 63 | +--source include/check_events_off.inc |
| 64 | +let $count_sessions= 1; |
| 65 | +--source include/wait_until_count_sessions.inc |
| 66 | +DROP USER definer@localhost; |
| 67 | + |
| 68 | +--echo # End of 10.11 tests |
0 commit comments