The test appears to hang when the `SET sql_log_bin = 0` statement is executed. Removing this seems to fix it and is OK as that's not what the test aims to check.
The test now more precisely exercises the code where the crash happened.
The test case attempts to simulate the environment where the crash appears to have happened. Local testing does not point out any problems.