[MDEV-9991] main.mysql_client_test_nonblock stack corruption with HAVE_BACKTRACE Created: 2016-04-26 Updated: 2016-06-08 Resolved: 2016-06-08 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | OTHER |
| Affects Version/s: | 5.5, 10.0, 10.1, 10.2 |
| Fix Version/s: | 5.5.50, 10.0.26, 10.1.15 |
| Type: | Bug | Priority: | Major |
| Reporter: | Sergey Vojtovich | Assignee: | Sergey Vojtovich |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | foundation | ||
| Sprint: | 5.5.50 |
| Description |
|
Compile script:
Test output:
GDB session:
|
| Comments |
| Comment by Sergey Vojtovich [ 2016-04-26 ] | |||||||||||||
|
Note stack corruption happens somewhere in my_context_spawn() assembler. | |||||||||||||
| Comment by Kristian Nielsen [ 2016-04-26 ] | |||||||||||||
|
I do not think it is stack corruption, looks rather like a bug in _Unwind_Backtrace() that it is making assumptions on the layout of caller's stack frame and doing unchecked memory accesses. (my_context_spawn is creating a new co-routine and thus switching stacks). Maybe something can be done to appease Unwind_Backtrace, there is already something to do that in the code. After all, supposedly Unwind_Backtrace() is able to not crash if it reaches the bottom of a stack from a pthread-spawned thread. Here is what is currently done:
It does not crash for me... can you check if that dwarf directive is correctly emitted in the environment that experiences the failure? | |||||||||||||
| Comment by Sergey Vojtovich [ 2016-04-26 ] | |||||||||||||
|
It can be a bug in backtrace() indeed, but gdb seem to be affected as well (see debugging session above). Stack trace is definitely wrong and gdb issues a warning: "Backtrace stopped: previous frame inner to this frame (corrupt stack?)" Also note that it is failing for me since I joined back in 2013, it went through a few OS upgrades. Did you compile according to instructions? It won't crash for me either if I remove e.g. MYSQL_MAINTAINER_MODE or NOT_FOR_DISTRIBUTION. But you did a good catch, this ifdef doesn't cover my compiler version properly (5.2.1). This patch (though it is not completely right) fixes this issue:
| |||||||||||||
| Comment by Kristian Nielsen [ 2016-04-26 ] | |||||||||||||
|
Ah, you're right, the check is wrong and doesn't catch gcc 5.X! (I have gcc I think this should be the correct check, can you try it?
As you said, even if libunwind wouldn't crash on bad pointer, it is still | |||||||||||||
| Comment by Sergey Vojtovich [ 2016-04-26 ] | |||||||||||||
|
It worked, thanks! I believe we should fix i386 my_context_spawn() the very same way. | |||||||||||||
| Comment by Kristian Nielsen [ 2016-06-08 ] | |||||||||||||
|
Pushed to 5.5, 10.0, and 10.1. |