Commit graph

12 commits

Author SHA1 Message Date
Stephen Dennis
6f32bc7741 fix(build): relative IncludePath/LibraryPath in master vcxproj files (#2185)
Replace hardcoded C:\tinymux paths with MuxDir/Pcre2Dir derived from
MSBuildProjectDirectory so checkouts at tinymux-213 or elsewhere cannot
silently compile against another tree's PCRE2.  Covers netmux, libmux,
engine, comsys, mail, exp3, sqlproxy, sqlslave.  2.13 half was #2187.
2026-08-07 00:35:17 -06:00
Stephen Dennis
a70362ef63 build: remove the 11 UTF-8 BOMs, and stop editors re-adding them (#1499)
Every BOM in the tree, and an .editorconfig so Visual Studio does not put
them back.

All eleven carry no information: none of the files contains a single
non-ASCII byte, so the BOM was the only non-ASCII content in each.
Visual Studio wrote them when it generated or last touched those project
files.  Ten are .vcxproj.filters; two are the sqlproxy and sqlslave
.vcxproj, which is why the /utf-8 commit had to restore them mid-change.

The concern that makes this worth more than tidying: Visual Studio adds a
signature when it needs to represent a non-ASCII character in a file that
had none.  These files are pure ASCII, so removing the BOM should stick --
VS preserves the encoding it finds.  But #1499 step 2 converts source
prose from \xE2\x80\x99 escapes to characters, which is precisely the
condition that starts making VS write signatures, and on .cpp rather than
on project files.

.editorconfig is the lever for that.  charset = utf-8 means UTF-8 WITHOUT
a BOM (utf-8-bom is the spelling for with), and Visual Studio honours it,
as do VS Code, CLion and Sublime.  It is deliberately the only key set:
indentation, line endings and trailing whitespace are left to existing
practice and CLAUDE.md, so the file cannot reformat anything by surprise.

Git cannot do this job, which is worth recording because it is the
obvious place to look.  core.autocrlf is line endings only, and
.gitattributes' working-tree-encoding converts encodings rather than
stripping a signature -- pointing it at UTF-16 would ADD one.  Stripping
a BOM through git needs a custom clean filter that every clone has to
configure locally; an .editorconfig needs no setup and acts where the BOM
is actually introduced.

A BOM is harmless to MSVC and tolerated by gcc and clang, so this is not
a correctness fix for compiled sources.  It matters for files that are
executed rather than compiled -- a shell script or a .mux corpus file
with a BOM simply does not work -- and for keeping diffs free of churn
that depends on who last opened a file in an IDE.

Verified: full rebuild of all eleven projects clean, including the two
whose .vcxproj lost its BOM; smoke 316 dispatched, 1487 succeeded, 17
failed (the known build-configuration failures here); format, netaddr and
alarm harnesses pass; zero BOMs left in any tracked file.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 21:20:02 -06:00
Stephen Dennis
ee66b0083a build(win32): add /utf-8 to the MSVC projects (#1499)
Step 1 of #1499, the behaviour-neutral half.  Adds /utf-8 to all eleven
vcxproj files and to the two MSVC builder scripts, so source and
execution charset are both UTF-8 instead of the system code page.

Verified neutral rather than asserted.  Built the tree twice on the same
box, with and without the flag, and diffed the extracted string tables:

    netmux.exe   1 differing line
    engine.dll   1 differing line
    libmux.dll   0 differing lines

Every one of those is binary noise at a shifted address that happens to
match a UTF-8 lead-byte pattern; the only human-readable difference in
the whole comparison is engine.dll's __DATE__/__TIME__ stamp.  No string
literal changes, and the U+2019 counts are identical (netmux 5,
engine 175, libmux 1), as are the file sizes.

Also measured why the escapes exist, because it is not what I expected.
On this box the active code page is 1252, and raw UTF-8 in a narrow
literal survives WITHOUT the flag -- all six typographic characters from
the issue's table round-trip byte-for-byte, including U+201D, whose 0x9D
is undefined in CP1252.  So "it works here" would have been a misleading
result to report.

The flag matters on a DBCS locale.  Compiling the same file as a
Japanese-locale box would:

    cl /source-charset:.932 /execution-charset:.932
    warning C4819: The file contains a character that cannot be
                   represented in the current code page (932)
    error C2001: newline in string literal

It does not mangle quietly -- it fails to compile, because the UTF-8
bytes are read as Shift-JIS lead bytes and swallow the closing quote.
With /utf-8 on that same simulated locale, correct.  That is the real
constraint the hex escapes were working around, and this removes it.

Step 2 (converting escapes to characters) is deliberately not here.  It
should follow only once this is in and verified, exactly as the issue
sequences it.

Smoke: 316 dispatched, 1487 succeeded, 17 failed -- the known
build-configuration failures on this box.  format, netaddr and alarm
harnesses all pass.  No C4819 anywhere in the build.

Two vcxproj files (sqlproxy, sqlslave) carry a UTF-8 BOM; my first pass
stripped it and I put it back, so the diff is 22 insertions and no
deletions.

tests/dbt/build-msvc.sh needs the same flag and is not in this commit --
it is still in review as #1493.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 20:58:42 -06:00
Stephen Dennis
5eeecdcf03 sqlslave: surface connection/query failures instead of dropping them
Address the remaining medium/low SQLSlave issues:

- #749: add a dedicated QS_CONNECT_FAILED result code so softcode can tell
  "unreachable" from "connection refused/bad credentials". ConnectionHelper()
  now returns whether a live session was established; Query() maps a failed
  reconnect to QS_CONNECT_FAILED and a still-dead ping to QS_SQL_UNAVAILABLE.
  fun_rserror() renders it as "#-5 CONNECT_FAILED".
- #750: capture mysql_next_result() > 0 (error) while draining stored-procedure
  result sets and report QS_QUERY_ERROR rather than silently succeeding.
- #751: check the return value of every mysql_options() call.
- #752: remove the empty thread-id "detected reconnection" block (dead code);
  the charset option is reapplied by the client across auto-reconnect.
- #753: narrow the two component-allocation catch(...) blocks to
  catch(std::bad_alloc) so non-allocation exceptions are no longer masked.

Errors are logged via a best-effort ILog acquired in FinalConstruct(); when
the component runs in the slave process (no CID_Log there) logging is skipped
and the result codes still propagate to softcode.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 15:12:13 -06:00
Stephen Dennis
bad69fb9aa sqlslave: fix ref-count races, buffer ownership, and MySQL build break
Address the high-priority SQLSlave issues plus a latent compile error that
only surfaces once HAVE_MYSQL is enabled:

- #745: CQueryServer/CQueryServerFactory m_cRef -> std::atomic<uint32_t>
  with fetch_add(relaxed)/fetch_sub(acq_rel), matching comsys/mail. Closes
  the decrement/zero-check double-delete race.
- #746: g_cComponents/g_cServerLocks -> std::atomic<int32_t>.
- #747: Connect() rejects null server/database/user/password rather than
  letting mysql_real_connect() and ConnectionHelper() dereference them.
- #748: copy the connection parameters into module-owned std::strings
  instead of aliasing and delete[]-ing the caller's buffers. The old code
  delete[]'d mudconf-owned storage in-process and stack buffers across the
  proxy/stub boundary (lib/libmux.cpp CQueryControlStub::Invoke).
- #764: mysql_real_query() was called with a const-stripping
  reinterpret_cast<char *> on a const UTF8 *, a hard -std=c++17 error that
  broke the build whenever a MySQL client library is present. Cast to
  const char * (the parameter type) instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 15:00:16 -06:00
Stephen Dennis
6288c4da37 Retire ISSUES.md trackers; migrate open items to GitHub issues
The 22 per-tracker ISSUES.md files carried both their open items and a
full FIXED / FALSE ALARM / NOT A BUG audit history. The 57 still-open
items have been migrated to GitHub issues #706-#762 with a 2.14-aligned
label taxonomy (area:* / type:* / priority:* / topic:*), so open work
now lives in the issue tracker instead of in-tree Markdown.

The closed/audit history of every tracker is preserved here in git
history (this commit's parent); nothing is lost.

Open items migrated by tracker:
  mux/src/         (1)   -> #706
  mux/lib/         (10)  -> #707-#716
  mux/modules/engine/ (18) -> #717-#734
  mux/ganl/        (10)  -> #735-#744
  mux/modules/sqlslave/ (9) -> #745-#753
  testcases/       (4)   -> #754-#757
  client/tf/ + client/ (5) -> #758-#762

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 20:14:00 -05:00
Stephen Dennis
16bf20362c Refresh ISSUES.md trackers after project-wide review
- Root index: corrected open counts/summaries (core now shows 1 item;
  libmux/engine/GANL/SQLSlave/Test reflect current active work after
  the April 2026 safety/buffer/JIT audits). Updated last-refreshed date
  and notes.
- testcases/ISSUES.md: refreshed for Apple Silicon DBT JIT enablement
  (commit 2a1776e27); updated isjson({}) divergence probe table and
  cross-links (non-JIT vs JIT EV_STRIP_CURLY behavior remains open).
- Active sub-trackers (src, lib, ganl, engine, sqlslave): bumped
  Updated/Created dates; added two low-priority items from stray TODO
  comments (GANL CHARSET client-list parsing; engine HIR 9-digit int
  fast-path parity note) so they are tracked.
- Performed full sweep of all 23 ISSUES.md files, code TODOs/FIXMEs,
  recent git log, CHANGES, roadmap, and sub-directories. No new
  critical untracked bugs found; generated files (smoke.flat) left
  untouched.
- Pure documentation/index maintenance. No risk to parser/eval or
  runtime behavior.
2026-05-22 21:04:32 -06:00
Stephen Dennis
b495b513ca Audit ISSUES.md trackers for new bugs across driver, libmux, engine, GANL, and sqlslave
New trackers for libmux (`mux/lib/`) and the sqlslave module. Updated
`mux/src/`, `mux/modules/engine/`, and `mux/ganl/` with a new batch of
findings from a sweep of recently-modified and previously-unaudited
code. Headline bug: `netaddr.cpp` `DecodeN` decodes hex digits A-F as
nibbles 0-5 instead of 10-15, silently breaking every hex IPv4 literal
used in `@site`/`@admit` rules.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 19:16:23 -06:00
Stephen Dennis
53bcc37a1c Switch Windows build from /MT to /MD and add mux_fclose
The modular architecture (netmux.exe, libmux.dll, engine.dll, etc.)
with static CRT (/MT) gave each module its own CRT heap. FILE* handles
from mux_fopen (in libmux) crashed when used by stdio functions in
other modules — fclose in write_pidfile, fgets in cf_include, etc.

Switch all 11 vcxproj files to /MD (shared CRT DLL) so all modules
share one CRT instance. Ship msvcp140.dll, vcruntime140.dll, and
vcruntime140_1.dll in the binary distribution.

Also add mux_fclose to libmux as good hygiene (pairs with mux_fopen),
and replace all cross-module fclose calls. This change is safe on Unix
where everything links into one process.

Add Startmux.bat as a replacement for Startmux.wsf since Windows
Script Host is no longer associated by default on modern Windows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 06:07:24 -06:00
Stephen Dennis
1354bc9e64 Clean up all vcxproj and filters to match brazil branch file layout
- Remove all autoconf-win32.h from ClInclude (template, not a project header)
- Remove empty Resource Files filter groups from ganl, libmux, sqlproxy,
  sqlslave, netmux
- libmux.vcxproj.filters: update all paths to lib\ and include\ prefixes
  to match actual source layout
- netmux.vcxproj.filters: rewrite entirely — trim to the slim driver
  sources (src\) and headers (include\) that netmux actually compiles
- sqlproxy/sqlslave filters: fix header paths from stale ..\ to
  correct ..\..\include\

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 23:29:35 -06:00
Stephen Dennis
68acbd2eea Rework Windows build for component-based directory layout
Adapt all vcxproj files and solution to the new directory structure
(src/ driver, lib/ shared library, modules/engine/ game logic,
modules/{comsys,mail,exp3,sqlproxy,sqlslave}/ loadable modules).

Key changes:
- libmux.dll exports utility symbols via LIBMUX_API macro
  (__declspec(dllexport) when BUILDING_LIBMUX, dllimport otherwise)
- LIBMUX_API added to all shared headers: stringutil.h, timeutil.h,
  mathutil.h, utf8tables.h, svdhash.h, svdrand.h, sha1.h, alloc.h,
  dbutil.h, core.h
- Per-file PreprocessorDefinitions in libmux.vcxproj inherit from
  project-level via %(PreprocessorDefinitions)
- Driver factory declarations (CDriverControlFactory,
  CConnectionManagerFactory) guarded with BUILDING_DRIVER
- PCG-XSH-RR-64/32 (pcg32) for Windows (no __int128 needed);
  Unix PCG-XSL-RR-128/64 unchanged
- MSVC portability fixes: _strnicmp, _BitScanForward64, (std::min)(),
  HAVE_WORKING_FORK guards, WINDOWS_FILES/UNIX_FILES ModuleAdd paths
- Remove stubslave.cpp and slave.cpp from netmux.vcxproj (separate
  processes)
- Fix sqlproxy/sqlslave vcxproj relative paths for new layout
- Add ws2_32.lib to engine.vcxproj for socket functions
- Add strcasecmp/strtok_r/strndup compat shims for comsys/mail

Builds successfully: libmux.dll, engine.dll, netmux.exe, exp3.dll,
sqlproxy.dll, sqlslave.dll. Comsys/mail blocked on sqlite3 linking
architecture (need COM-mediated or independent sqlite3 linkage).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 09:38:57 -06:00
Stephen Dennis
4ff1398de1 Restructure mux/ directory: component-based layout with proper build root
Move from flat mux/src/ layout to clean component hierarchy:
- mux/ is now the autoconf/automake build root (configure.ac lives here)
- mux/include/ — shared headers used by multiple components
- mux/lib/ — libmux.so (core utilities, no game state)
- mux/src/ — netmux driver only (thin networking shell)
- mux/modules/engine/ — engine.so (game logic)
- mux/modules/{comsys,mail,exp3,sqlproxy,sqlslave}/ — external modules
- mux/ganl/ — GANL networking library
- mux/sqlite/ — SQLite amalgamation (builds libsqlite3.a)
- mux/announce/ — announce tool (was mux/src/tools/)

Build changes:
- SUBDIRS ordering: ganl sqlite lib src modules announce
- libmux.so gets -Wl,-soname,libmux.so; netmux links via -L -lmux
- engine.so links libsqlite3.a and libmux.so with -Wl,--no-undefined
- RPATH uses $ORIGIN for portable .so resolution
- Install hooks use absolute paths for game/bin symlinks

Bug fixes:
- engine.so mux_Register() now passes nullptr to mux_RegisterClassObjects
  (matches all other modules; libmux already has the factory via dlsym)
- DbConvert() now calls pcache_init() before db_write, fixing a latent
  crash (free(): invalid pointer) when exporting from SQLite databases

411/411 smoke tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 20:38:37 -06:00