• src/sbbs3/filterfile.hpp findstr.c findstr.h

    From Rob Swindell (on Windows 11)@1:103/705 to Git commit to main/sbbs/master on Thu Jun 25 17:54:21 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/d3706726a898cea33d7e7842
    Modified Files:
    src/sbbs3/filterfile.hpp findstr.c findstr.h
    Log Message:
    Fix Win32 debug-heap assertion freeing cached filter lists (GitLab #1099)

    filterFile::listed() (and ~filterFile/reset()) freed its cached str_list
    with strListFree(), which links locally into each server module (xpdev is statically linked), but built it with findstr_list(), which is dllimport'd
    from sbbs.dll. So the list was allocated in sbbs.dll's CRT heap and freed
    in the server module's own /MTd CRT heap. Each statically-linked CRT keeps
    a per-module debug block list, so the freeing module's _free_dbg_nolock
    can't find the block and asserts at debug_heap.cpp:996.

    This is why the issue was debug/Windows-only and undetectable by App
    Verifier: in release the UCRT heap is GetProcessHeap() (shared across
    modules) so the cross-module free actually succeeds, and non-Windows
    shares one libc heap -- only the Win32 debug CRT's per-module accounting notices. It was also reproducible single-threaded (deterministic heap
    mismatch, not a race) and only via findstr_list() (the lone allocation
    crossing the DLL boundary). Affects every filter object (ip_can,
    ip_silent_can, host_can, host_exempt) in every server, since filterFile
    is a header-only class compiled into each module. Present since the class
    was introduced in cd30ec58a (press-5-filled).

    Pair findstr_list() with a findstr_list_free() exported from the same translation unit (sbbs.dll), and call it from all three filterFile free
    sites so allocation and deallocation share one heap. This also lets the strListFree() that #1099 had to comment out of reset() be restored (now
    under the object mutex, since reset() runs in the shutdown path where a
    late client thread may still be in listed()).

    Verified: rebuilt services.dll imports both findstr_list and
    findstr_list_free from sbbs.dll. Built clean on Win32/Release.

    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
    --- SBBSecho 3.37-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)