Skip to content

Commit 5dc46ad

Browse files
var-constwilhuff
authored andcommitted
Fix accessing a destroyed object (#3721) (#3725)
This was caused by running under Asan with XCode 11. Apparently, previous versions of XCode cannot catch it (which is why Travis is passing, apparently). Also: * enable "Detect use of stack after return" option for Asan. AFAIU, it can only be enabled in the scheme. It's already enabled for unit tests, this PR additionally enables it for integration tests; * make Asan failures fail Travis build. They were originally not considered blocking due to some sporadic failures. I haven't seen those for some time, and worst case scenario, we can revert this change.
1 parent ad6c48a commit 5dc46ad

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

.travis.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,8 @@ jobs:
447447
# need to make them fatal for the purposes of the test run.
448448

449449
# TODO(varconst): disallow sanitizers to fail once we fix all existing issues.
450-
- env:
451-
- PROJECT=Firestore PLATFORM=macOS METHOD=cmake SANITIZERS=asan
452450
- env:
453451
- PROJECT=Firestore PLATFORM=macOS METHOD=cmake SANITIZERS=tsan
454-
- env:
455-
- PROJECT=Firestore PLATFORM=iOS METHOD=xcodebuild SANITIZERS=asan
456452
- env:
457453
- PROJECT=Firestore PLATFORM=iOS METHOD=xcodebuild SANITIZERS=tsan
458454
- env:

Firestore/Example/Firestore.xcodeproj/xcshareddata/xcschemes/Firestore_IntegrationTests_iOS.xcscheme

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,17 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
shouldUseLaunchSchemeArgsEnv = "YES">
29+
shouldUseLaunchSchemeArgsEnv = "YES"
30+
enableASanStackUseAfterReturn = "YES">
31+
<MacroExpansion>
32+
<BuildableReference
33+
BuildableIdentifier = "primary"
34+
BlueprintIdentifier = "DE03B2941F2149D600A30B9C"
35+
BuildableName = "Firestore_IntegrationTests_iOS.xctest"
36+
BlueprintName = "Firestore_IntegrationTests_iOS"
37+
ReferencedContainer = "container:Firestore.xcodeproj">
38+
</BuildableReference>
39+
</MacroExpansion>
3040
<Testables>
3141
<TestableReference
3242
skipped = "NO">
@@ -39,17 +49,6 @@
3949
</BuildableReference>
4050
</TestableReference>
4151
</Testables>
42-
<MacroExpansion>
43-
<BuildableReference
44-
BuildableIdentifier = "primary"
45-
BlueprintIdentifier = "DE03B2941F2149D600A30B9C"
46-
BuildableName = "Firestore_IntegrationTests_iOS.xctest"
47-
BlueprintName = "Firestore_IntegrationTests_iOS"
48-
ReferencedContainer = "container:Firestore.xcodeproj">
49-
</BuildableReference>
50-
</MacroExpansion>
51-
<AdditionalOptions>
52-
</AdditionalOptions>
5352
</TestAction>
5453
<LaunchAction
5554
buildConfiguration = "Debug"
@@ -70,8 +69,6 @@
7069
ReferencedContainer = "container:Firestore.xcodeproj">
7170
</BuildableReference>
7271
</MacroExpansion>
73-
<AdditionalOptions>
74-
</AdditionalOptions>
7572
</LaunchAction>
7673
<ProfileAction
7774
buildConfiguration = "Release"

Firestore/core/src/firebase/firestore/core/view.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ ViewDocumentChanges View::ComputeDocumentChanges(
212212
if (limit != Query::kNoLimit &&
213213
new_document_set.size() > static_cast<size_t>(limit)) {
214214
for (size_t i = new_document_set.size() - limit; i > 0; --i) {
215-
const Document& old_doc = *new_document_set.GetLastDocument();
215+
absl::optional<Document> found = new_document_set.GetLastDocument();
216+
const Document& old_doc = *found;
216217
new_document_set = new_document_set.erase(old_doc.key());
217218
new_mutated_keys = new_mutated_keys.erase(old_doc.key());
218219
change_set.AddChange(

0 commit comments

Comments
 (0)