Commit 889a66a
committed
BUG#36297142 - mysqld crash at vector::get_dot for ASAN
Problem
=======
- At udf_handler::get_and_convert_string, we get a String*
result pointer, which might be the address of Item::str_value.
We then call c_ptr_safe() on this, so the buffer of
Item::str_value gets reallocated.
- Queries which have UDFs consuming the same argument more
than once, the Item_ref has the same ref_item, with the same
underlying str_value.
Example: SELECT UDF(col1, col1) FROM view_t1;
- In such cases, when setting the m_ptr of Item::str_value
directly (while processing the second argument), we free the
buffer that we had allocated at c_ptr_safe(), at the time of
processing the first argument.
- As a result, the UDF will try to read a buffer that has
been freed, causing the ASAN issue.
Solution
========
- The root cause is that the udf_handler changes contents
of Item::str_value directly. Instead of doing that, assign
the contents of Item::str_value to udf_handler local buffers.
Note that this is not a deep string copy.
- Any further calls to c_ptr_safe() will not modify
Item::str_value object, avoiding the issue.
Change-Id: Ib3d6e1d52825dafbc1e495f5f45f8fac75bc90f11 parent 0fc1164 commit 889a66a
1 file changed
+14
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4980 | 4980 | | |
4981 | 4981 | | |
4982 | 4982 | | |
4983 | | - | |
4984 | | - | |
4985 | | - | |
| 4983 | + | |
| 4984 | + | |
| 4985 | + | |
| 4986 | + | |
4986 | 4987 | | |
4987 | 4988 | | |
4988 | 4989 | | |
4989 | 4990 | | |
4990 | 4991 | | |
4991 | 4992 | | |
4992 | 4993 | | |
| 4994 | + | |
| 4995 | + | |
| 4996 | + | |
| 4997 | + | |
| 4998 | + | |
| 4999 | + | |
| 5000 | + | |
| 5001 | + | |
| 5002 | + | |
| 5003 | + | |
4993 | 5004 | | |
4994 | | - | |
4995 | | - | |
4996 | 5005 | | |
4997 | 5006 | | |
4998 | 5007 | | |
| |||
0 commit comments