Skip to content

Commit 066d949

Browse files
committed
Fix an assertion failure
`Id::operator-=(a,b)` throws when a == b, because you're not supposed to make an invalid Id from a valid Id. So instead we use `uint64_t` to represent the page offsets, because those are not necesarily valid Ids. This assertion triggered when I tried to add units to the Haskell indexer, I'm not sure why it hasn't triggered before.
1 parent 8080606 commit 066d949

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

glean/rts/ownership.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -359,15 +359,20 @@ FOLLY_NOINLINE void completeOwnership(
359359
auto executor = folly::getGlobalCPUExecutor();
360360

361361
folly::Future<folly::Unit> fetcher = folly::via(executor, [&]() {
362-
auto pageOf = [](Id id) {
363-
return Id::fromWord((id.toWord() / pageSize) * pageSize);
362+
auto pageOf = [](Id id) -> uint64_t {
363+
return (id.toWord() / pageSize) * pageSize;
364364
};
365-
Id last = pageOf(lookup.firstFreeId() - 1);
366-
Id first = pageOf(lookup.startingId());
367-
for (Id id = last;; id -= pageSize) {
368-
VLOG(1) << folly::sformat("fetching page: {}", id.toWord());
369-
queue.blockingWrite(fetchPage(id, id + pageSize));
370-
if (id == first) {
365+
Id start = lookup.startingId();
366+
Id last = lookup.firstFreeId() - 1;
367+
uint64_t first = pageOf(start);
368+
for (uint64_t page = pageOf(last);; page -= pageSize) {
369+
VLOG(1) << folly::sformat("fetching page: {}", page);
370+
queue.blockingWrite(
371+
fetchPage(
372+
(page == first) ? start : Id::fromWord(page),
373+
Id::fromWord(page + pageSize))
374+
);
375+
if (page == first) {
371376
break;
372377
}
373378
}

0 commit comments

Comments
 (0)