[MXS-876] MaxScale crash inside qc_sqlite Created: 2016-09-22 Updated: 2016-09-30 Resolved: 2016-09-30 |
|
| Status: | Closed |
| Project: | MariaDB MaxScale |
| Component/s: | qc_sqlite |
| Affects Version/s: | 2.0.0 |
| Fix Version/s: | 2.0.1 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Kurt Pastore (Inactive) | Assignee: | Johan Wikman |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
VMWare |
||
| Description |
|
2016-09-22 11:09:50 error : Write to dcb 0x7f238c044b60 in state DCB_STATE_POLLING fd 651 failed due errno 104, Connection reset by peer |
| Comments |
| Comment by markus makela [ 2016-09-22 ] | |||||||||||||||||||||||||||||||
|
Interpreted stacktrace:
| |||||||||||||||||||||||||||||||
| Comment by markus makela [ 2016-09-22 ] | |||||||||||||||||||||||||||||||
|
The crash happened inside the SQLite3 library in sqlite3DbMallocRawNN. | |||||||||||||||||||||||||||||||
| Comment by Johan Wikman [ 2016-09-23 ] | |||||||||||||||||||||||||||||||
|
From #maxscale Client mentions these crashes occur every 4 hours ... strangely it happens at 4pm then again at 8 then again at midnight.... Client definately sees this pattern | |||||||||||||||||||||||||||||||
| Comment by Johan Wikman [ 2016-09-23 ] | |||||||||||||||||||||||||||||||
|
In the query classifier there's a leak that is exposed by e.g. a query like
| |||||||||||||||||||||||||||||||
| Comment by Johan Wikman [ 2016-09-29 ] | |||||||||||||||||||||||||||||||
|
Another similar
The crash is in the same location as in the previous case. | |||||||||||||||||||||||||||||||
| Comment by Johan Wikman [ 2016-09-29 ] | |||||||||||||||||||||||||||||||
|
The code in question is
Information about the lookaside allocator can be found here: https://www.sqlite.org/malloc.html#lookaside The effect of not using appeared not to be dramatic. So, we'll try by removing it and using the normal allocator instead. | |||||||||||||||||||||||||||||||
| Comment by Johan Wikman [ 2016-09-30 ] | |||||||||||||||||||||||||||||||
|
The problem was not in the allocator. Instead, the underlying reason was: "C-style escapes using the backslash character are not supported because they are not standard SQL" (from https://www.sqlite.org/lang_expr.html). In most cases that did not cause any problems, but e.g. a statement like
would cause a buffer overrun since the sqlite string dequoter assumed that the last two trailing '' were an encoded ' and not the end of the string. So it would happily overwrite memory until it finally by chance encountered another '. That broke the lookaside allocator but also regular malloc. The fix was simply to add support for using backslash as an escape character. |