Skip to content

Stabilize Windows builds and runtime - #63

Open
skywo1f wants to merge 1 commit into
afwbkbc:mainfrom
skywo1f:agent/windows-runtime-stability
Open

skywo1f wants to merge 1 commit into
afwbkbc:mainfrom
skywo1f:agent/windows-runtime-stability

Conversation

@skywo1f

@skywo1f skywo1f commented Jul 14, 2026

Copy link
Copy Markdown

Summary

  • restore reliable Visual Studio/Clang Debug and Release builds on Windows
  • harden map generation/loading, resource ownership, UI/input/audio, OpenGL setup, and shutdown/error paths
  • fix GSE timer cancellation and GC lifetime races, 64-bit numeric parsing, and full-range random integers
  • add validated custom even map-size controls and focused script regressions

Why

The Windows build and several launch paths were blocked by dependency and configuration issues. Runtime stress testing also exposed malformed-map crashes, unsafe cross-thread script callbacks, timer resurrection and GC lifetime races, integer overflow, invalid argument handling, and excessive huge-map working memory.

Impact

GLSMAC now builds in Debug and Release on Windows, loads original SMAC assets, handles malformed maps without an access violation, supports validated custom map sizes, and runs generated maps more reliably. In the tested huge-map configuration, working memory dropped to about 1.0 GB (about 1.5 GB private memory).

Validation

  • Windows Clang/Visual Studio Debug build
  • Windows Clang/Visual Studio Release build
  • full GSE suite: all tests passed, no stderr, and no detected memory/OpenGL leaks
  • repeated asynchronous timer regression passes
  • Release 40x20 map generation: map initialized, turn advanced, clean exit code 0, and all four threads stopped
  • malformed-map Debug and Release error-path smoke tests
  • git diff --check

The stabilization pass spans the build configuration and several runtime subsystems. It can be split by subsystem if that would make review easier.

@skywo1f
skywo1f marked this pull request as ready for review July 15, 2026 01:15
@Cartlord

Cartlord commented Aug 9, 2026

Copy link
Copy Markdown

I feel obligated to inform the user(s) in charge of this repository that this individual recently admitted to using Claude code, a plagiarism-powered slop engine, to code for this exact repository and does not appear to be disclosing as such within their Pull Requests.
Archive of the post where they admit as much: https://megalodon.jp/2026-0809-2229-42/https://old.reddit.com:443/r/alphacentauri/comments/1uzc1ri/lend_your_extra_tokens_to_glsmac/

@afwbkbc

afwbkbc commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Please address the mentioned issues to make this eligible for merge.
I'll do more testing on Windows and other environments later.

Comment on lines +7 to +9
SET( SDL2IMAGE_JXL OFF )
SET( SDL2IMAGE_TIF OFF )
SET( SDL2IMAGE_WEBP OFF )

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not fully sure there is a reason to disable those

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. If you would have actually tested the result you would see that OK and Cancel buttons are stuck together without space between them - fix this (make popup slightly wider?).
  2. No reason to have such wide inputs for width and height which will have 3 or 4 digits at most, maybe place them on single line?

Comment on lines +74 to +77
if (width * height > 180 * 90) {
i.popup.error('Custom map area cannot exceed Huge Planet (180x90).');
return true;
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reason for this limitation, let's allow people to have as large maps as their hardware can support

Comment thread src/audio/sdl2/SDL2.cpp
Comment on lines +54 to +55
free( m_buffer );
free( m_mix_buffer );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're freeing NULL pointer here.

This whole block is unnecessary because if malloc fails - it's all over anyway

Comment thread src/audio/sdl2/SDL2.cpp
free( m_mix_buffer );
m_buffer = nullptr;
m_mix_buffer = nullptr;
SDL_QuitSubSystem( SDL_INIT_AUDIO );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If SDL_OpenAudio failed we don't need to call SDL_QuitSubSystem

Comment on lines +25 to +27
if ( !width || !height || ( width & 1 ) || ( height & 1 ) ) {
THROW( "map dimensions must be positive even numbers" );
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace with ASSERT

Comment on lines +36 to +38
if ( tile_count > m_data.max_size() ) {
THROW( "map dimensions exceed tile storage capacity" );
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace with ASSERT

Comment thread src/util/Timer.cpp
Comment on lines +67 to +69
if ( static_cast< uint64_t >( ms ) > static_cast< uint64_t >( std::numeric_limits< std::chrono::milliseconds::rep >::max() ) ) {
THROW( "timer duration is too large" );
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace with ASSERT. for timers coming from scripts - validate them in GSE handler (and throw GSE_ERROR if something is wrong)

Comment thread src/util/Timer.cpp
Comment on lines +78 to +83
if ( ms == 0 ) {
THROW( "timer interval must be greater than zero" );
}
if ( static_cast< uint64_t >( ms ) > static_cast< uint64_t >( std::numeric_limits< std::chrono::milliseconds::rep >::max() ) ) {
THROW( "timer duration is too large" );
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment thread CMakeLists.txt
SET( CMAKE_CXX_FLAGS " -std=c++17 ${CMAKE_CXX_FLAGS} -Wno-pointer-arith " )
SET( CMAKE_CXX_STANDARD 17 )
SET( CMAKE_CXX_STANDARD_REQUIRED ON )
IF ( NOT MSVC )

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this compiler was not supported anyway, does it work with this changeset?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants