The tag service kept a pointer to a vector element 'for speed'. The vector grew, moved to new memory, and the pointer stayed loyal to the old address. The crash, naturally, fired three modules away from the bug. Stop caching addresses into someone else's storage — the vector has no sentimentality about it.
sumOfFirst caches a pointer to a vector's first element, then keeps push_back-ing into the same vector. When the vector reallocates, that pointer dangles — reading it is a heap use-after-free. Fix the function so it stays correct (and ASan-clean).
v[0] added once per appended element — i.e. v[0] * count using the original first valuepush_back may have invalidated (ASan must stay clean)count values 0..count-1 to v as a side effectpush_backstd::vector?reserve help, and when is it still not enough?Read the value once before the loop: int firstVal = v[0]; — a copy can never dangle.
If you truly need the live first element, index it fresh each time (v[0]) instead of caching its address.
Hit Submit (or ⌘/Ctrl + ↵) — test results will show up here.