BBS:      TELESC.NET.BR
Assunto:  Win32 debug heap assertion after reading a cached filter filter while
De:       Rob Swindell
Data:     Thu, 12 Mar 2026 19:20:24 -0700
-----------------------------------------------------------
https://gitlab.synchro.net/main/sbbs/-/issues/1099#note_8573

Claude's 3rd analysis of the issue/cause was:
```
 ## Context
 Rounds 1-2 (committed as 2fb010d6c3, 61695ba1a6) fixed post-`thread_down()`
 access to shared resources. The crash persists: MSVC debug heap assertion fires
 in `strListFreeStrings` when `cleanup()` deletes `ip_can` in mailsrvr.cpp.
 The user's consistent observation: **"it only crashes when a new connection
 thread is initialized after the terminate_server flag is set."**
 ### Analysis
 The thread_count synchronization in `cleanup()` is correct  it atomically
 waits for all child threads to finish via `std::atomic_load` (Windows) before
 deleting filter objects. The actual heap corruption source is likely a buffer
 overflow somewhere in the SMTP/POP3 client thread code. It is only **detected**
 during `cleanup()` because that's when `ip_can`'s strings are freed and the
 debug heap guard bytes are checked.
 **Why only with a late connection?** In normal operation, the corruption (if
 present) is never detected because `ip_can` is never freed until shutdown. With
 a late connection during shutdown, the thread allocates memory near `ip_can`'s
 strings on the heap, and whatever overflow occurs corrupts the guard bytes of
 those adjacent allocations.
```
n
---
  mSynchronetn  hgVertrauen n hHome of Synchronet n gh[vert/cvs/bbs].synchro.net

-----------------------------------------------------------
[Voltar]