Commit 76d3b46
committed
[LocalStorage] Fix NetworkProcess crash on sqlite database corruption
1) Corrupted database is handled inside handleDatabaseCorruptionIfNeeded(),
that closes database connection and clears all cached statements (m_cachedStatements).
The second destroys all SQLiteStatement(s) objects. But a pointer to such object
may be still kept inside SQLiteStatementAutoResetScope created inside SQLiteStorageArea.cpp:
auto statement = cachedStatement(StatementType::SetItem);
This will call m_statement->reset() at scope exit (from ~SQLiteStatementAutoResetScope)
on already deleted object that results with crash.
The solution is to use WeakPtr to make sure object is still alive
before calling statement->reset()
2) Special case happens when corruption is detected on setting new item (setItem).
If there are no cached entries, handleDatabaseCorruptionIfNeeded() will not create
new database (m_database == nullptr) that will lead to another crash
when re-trying to create cachedStatement again.
Solution here is to replace direct statement execution with full setItem() call
that will prepareDatabase() again if needed.1 parent 3fc6679 commit 76d3b46
4 files changed
Lines changed: 14 additions & 8 deletions
File tree
- Source
- WebCore/platform/sql
- WebKit/NetworkProcess/storage
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | | - | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
57 | 60 | | |
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | | - | |
46 | | - | |
| 46 | + | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | | - | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
359 | | - | |
360 | | - | |
361 | | - | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
362 | 363 | | |
363 | 364 | | |
364 | 365 | | |
| |||
0 commit comments