Commit e81cb6d
authored
fix(cloud_firestore): guard shared transactions map against concurrent access (#18421)
On iOS, the plugin's _transactions NSMutableDictionary is mutated from
Firestore's transaction worker queue (started:/ended: listeners) and read
from a global queue (transactionGetApp), with no synchronization. Running
many transactions in parallel corrupts the dictionary and aborts the
process with SIGABRT (malloc heap-corruption check).
Wrap all remaining accesses in @synchronized(self->_transactions), matching
the existing synchronization in cleanupEventListeners. The macOS sources
symlink to the iOS files, so this covers both platforms.
Android has the identical race (plain HashMap written from transaction
worker threads, read from the plugin's cached thread pool); switch it to
ConcurrentHashMap.
Adds an e2e regression test running 30 transactions concurrently.
Fixes #184171 parent 1df97bb commit e81cb6d
3 files changed
Lines changed: 49 additions & 4 deletions
File tree
- packages/cloud_firestore/cloud_firestore
- android/src/main/java/io/flutter/plugins/firebase/firestore
- example/integration_test
- ios/cloud_firestore/Sources/cloud_firestore
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| |||
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
86 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
| |||
Lines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
481 | 481 | | |
482 | 482 | | |
483 | 483 | | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
484 | 517 | | |
485 | 518 | | |
486 | 519 | | |
| |||
Lines changed: 12 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
662 | 662 | | |
663 | 663 | | |
664 | 664 | | |
665 | | - | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
666 | 669 | | |
667 | 670 | | |
668 | 671 | | |
| |||
782 | 785 | | |
783 | 786 | | |
784 | 787 | | |
785 | | - | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
786 | 793 | | |
787 | 794 | | |
788 | | - | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
789 | 798 | | |
790 | 799 | | |
791 | 800 | | |
| |||
0 commit comments