Skip to content

Conversation

@tueda
Copy link
Collaborator

@tueda tueda commented May 4, 2024

This PR consists of 3 patches to improve the building binaries on Windows:

  • FORM source
  • test cases
  • others, including the testing framework and CI workflow

Though to some extent this is ready for a merge, there are still some remaining issues:

Concerning the 2 test failures, both are caused by segfaults (Sta_Fill_1 leads to a segfault also on Linux). The unexpected failures might be related to the fact that MSYS2 GCC is currently version 13.2.0, the buggy version (MSYS2 has no way to install a specific version like gcc 12).

@coveralls
Copy link

coveralls commented May 4, 2024

Coverage Status

coverage: 50.007% (+0.008%) from 49.999%
when pulling c571f77 on tueda:test-check-on-windows
into 83e3d41 on vermaseren:master.

@tueda tueda force-pushed the test-check-on-windows branch from 85adfc8 to c571f77 Compare May 27, 2024 05:23
@tueda
Copy link
Collaborator Author

tueda commented May 27, 2024

Rebased onto master.

The failure of Issue135_3 seems to have resolved itself, likely because of an update of the gcc version in the upstream (MSYS2).

The failure of Sta_Fill_1 may not be the fault of the compiler or Windows. It seems to contain intrinsically undefined behaviour. Actually, Valgrind (on Linux) shows stack overflows:

FORM 5.0.0-beta.1 (May 27 2024, v5.0.0-beta.1-69-gc571f77)  Run: Mon May 27 14:48:08 2024
        Table B(1:1);
        Local dummy = 1;
        .sort

Time =       0.04 sec    Generated terms =          1
           dummy         Terms in output =          1
                         Bytes used      =         20
        Fill B(1) = dummy;
1.frm Line 4 --> Warning: Use of expressions and/or $variables in Fill statemen
ts is potentially very dangerous.
        Drop dummy;
        .sort
        Local F = B(1);
        Print;
        .end
==73714== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==73714== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==73714== Can't extend stack to 0x1ffe801078 during signal delivery for thread 1:
==73714==   no stack segment
==73714==
==73714== Process terminating with default action of signal 11 (SIGSEGV)
==73714==  Access not within mapped region at address 0x1FFE801078
==73714== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==73714==    at 0x1DF3F1: Generator (proces.c:3246)
==73714==  If you believe this happened as a result of a stack
==73714==  overflow in your program's main thread (unlikely but
==73714==  possible), you can try to increase the size of the
==73714==  main thread stack using the --main-stacksize= flag.
==73714==  The main thread stack size used in this run was 8388608.

@tueda
Copy link
Collaborator Author

tueda commented May 28, 2024

FYI, here is an experimental branch working with MSVC: https://github.com/tueda/form/tree/ci-msvc

@jodavies
Copy link
Collaborator

jodavies commented Jun 7, 2024

Sta_Fill_1 results in an infinite loop of DoOnePow, Generator, Generator, Generator. I suppose the table entry references the expression "dummy", but in DoOnePow we are using nexp=0 which at this point refers to F. Hence the loop? FORM at least prints the warning.

So this one is nothing to do with windows, anyway.

@tueda tueda force-pushed the test-check-on-windows branch from c571f77 to b34fa20 Compare November 6, 2024 08:02
@coveralls
Copy link

coveralls commented Nov 6, 2024

Coverage Status

coverage: 50.72% (-0.002%) from 50.722%
when pulling d49daaa on tueda:test-check-on-windows
into 8abec49 on vermaseren:master.

@tueda
Copy link
Collaborator Author

tueda commented Nov 6, 2024

Rebased.

@tueda
Copy link
Collaborator Author

tueda commented Nov 19, 2024

Rebased.

@tueda tueda mentioned this pull request Nov 22, 2024
@tueda tueda force-pushed the test-check-on-windows branch from fbcf859 to 45fbdba Compare December 20, 2024 07:28
@tueda
Copy link
Collaborator Author

tueda commented Dec 20, 2024

Rebased.

- Remove Unix-dependent code to enhance portability.
- Replace guess_term_width() with io/console/size available in Ruby 1.9.
- Use File::PATH_SEPARATOR.
- Replace RUBY_PLATFORM with RbConfig::CONFIG["host_os"].
- On Windows, convert CR+LF to LF in output to align with test cases.
- Add windows? method.
- Add --show-newlines option to show CR/LF.
- Append $(EXEEXT) to TEST_BINS.
- Always enclose $SHELL in quotes to accommodate spaces.
- Now the workflow creates the Windows distribution that is included in
  the release.
- Use "mingw-w64-x86_64-ruby" instead of "ruby". The former gives
  "mingw32" for RbConfig::CONFIG["host_os"] but the latter gives
  "cygwin".
- Refactor preparation of distributions.
On Windows, the standard output is opened with text mode. This patch
sets the mode to binary mode, which partially resolves form-dev#418.
- "ExtComm_1" requires Unix.
- "Sta_Fill_1" is pending on Windows.
- "AppendPath" and "TempSortDir" are divided into Unix and Windows cases
  because off the different path separators.
Restrict the sort file creation check at startup to the main thread in
TFORM. This change prevents unnecessary checks and potential race
conditions caused by multiple threads.

Close form-dev#602.
@tueda tueda force-pushed the test-check-on-windows branch from 45fbdba to a4df532 Compare December 28, 2024 07:03
@tueda
Copy link
Collaborator Author

tueda commented Dec 28, 2024

Now there are no test failures on native Windows (except for the occasional random failures in TFORM).

Avoid null pointer dereferences during early termination before sort
buffer allocation.

Close form-dev#605.
@tueda tueda force-pushed the test-check-on-windows branch from a4df532 to d49daaa Compare December 28, 2024 07:23
@tueda tueda merged commit 42de574 into form-dev:master Jan 24, 2025
70 checks passed
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.

TFORM crashes in CleanUpSort when TempSortDir is unavailable Simultaneous sort file creation by all worker threads

3 participants