Category : address-sanitizer

Is it valid to call handle.destroy() from within the final suspension of a C++ coroutine? From my understanding, this should be fine because the coroutine is currently suspended and it won’t be resumed again. Still, AddressSanitizer reports a heap-use-after-free for the following code snippet: #include <experimental/coroutine> #include <iostream> using namespace std; struct final_awaitable { bool ..

Read more

When running my program with ASAN, I’m getting an error when using std::ostringstream. Something special with the program is that it’s overriding the new and delete operators. The following code is a simplified repro case: #include <sstream> char big_chunk[1000000]; char* alloc = big_chunk; void *operator new(std::size_t sz) { char* a = alloc; alloc += ((sz ..

Read more

The code below is for leetcode problem Reconstruct Itinerary : class Solution { public: vector<string> res; unordered_map<string,set<string>> g; vector<string> findItinerary(vector<vector<string>>& tickets) { for(vector<string> tkt: tickets){ g[tkt[0]].insert(tkt[1]); } res.push_back("JFK"); dfs("JFK"); return res; } void dfs(string u){ for(string v: g[u]){ res.push_back(v); g[u].erase(g[u].begin()); dfs(v); } } }; I am getting an error Address Sanitizer. Please help in resolving ..

Read more