Commit 035a9b8
sqlite: keep sessions alive across SQLite callbacks
Session objects are weak and nothing else holds a strong reference to
them, so a garbage collection can free one while SQLite is still using
it. SQLite runs "PRAGMA table_xinfo" from inside its pre-update hook,
which reaches JavaScript, so a GC during a callback invoked from there
can collect a session the hook is still walking.
Hold a strong reference to every attached session for the duration of
each callback SQLite invokes. The trace callback now enters that guard
before building its payload, since the allocation can itself trigger a
garbage collection.
Fixes: #65460
Signed-off-by: Trevor Burnham <trevorburnham@gmail.com>
PR-URL: #65465
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>1 parent 6ead515 commit 035a9b8
3 files changed
Lines changed: 70 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1024 | 1024 | | |
1025 | 1025 | | |
1026 | 1026 | | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
1027 | 1036 | | |
1028 | 1037 | | |
1029 | 1038 | | |
| |||
2832 | 2841 | | |
2833 | 2842 | | |
2834 | 2843 | | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
2835 | 2848 | | |
2836 | 2849 | | |
2837 | 2850 | | |
| |||
2870 | 2883 | | |
2871 | 2884 | | |
2872 | 2885 | | |
2873 | | - | |
2874 | 2886 | | |
2875 | 2887 | | |
2876 | 2888 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
292 | 299 | | |
293 | 300 | | |
294 | 301 | | |
| |||
505 | 512 | | |
506 | 513 | | |
507 | 514 | | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
508 | 518 | | |
509 | 519 | | |
510 | | - | |
| 520 | + | |
| 521 | + | |
511 | 522 | | |
512 | 523 | | |
513 | 524 | | |
| |||
516 | 527 | | |
517 | 528 | | |
518 | 529 | | |
| 530 | + | |
519 | 531 | | |
520 | 532 | | |
521 | 533 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
685 | 729 | | |
686 | 730 | | |
687 | 731 | | |
| |||
0 commit comments