Skip to content

Commit

Permalink
SCP: sprint_val comma bug, GH: Remnant symlinks
Browse files Browse the repository at this point in the history
- Fix comma separator code segmentation fault: "ndigit - 3" can become a
  very large unsigned number for ndigit < 3.

- dir_cmd: Allocate WildName from heap to reduce stack pressure.

- Github CI/CD: Remnant symlink issue reappeared, afflicting the
  makefile-based build. For better or worse, the workaround is now
  dependent on specific Python versions that must be removed, unlinked
  and any remnant symlinks that HomeBrew decided it needed to install in
  /usr/local/bin. The Python upgrade is triggered by the sdl2_ttf
  package.

  According to the Github image maintainers, this is an old, known issue
  in macOS images that originates inside of Homebrew.
  • Loading branch information
bscottm committed Mar 12, 2024
1 parent c47e933 commit ae9e57f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 19 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,26 @@ jobs:
- scelbi 3b2 i701 i704 i7010 i7070 i7080 i7090 sigma uc15 i650 sel32 intel-mds ibm1130
steps:
- uses: actions/checkout@v3
- name: Install dependencies
## Workaround for remnant symlinks in /usr/local pointing back to
## macOS frameworks.
##
## Future: Will have to keep an eye on SDL_ttf's Python dependency
## so that the correct/appropriate Python version is removed.
- name: Remnant symlink cleanup (macOS)
if: ${{runner.os == 'macOS'}}
run: |
brew unlink python@3 || true
brew uninstall --ignore-dependencies python@3 || true
brew unlink [email protected] || true
brew uninstall --ignore-dependencies [email protected] || true
for f in $(find /usr/local/bin -type l -print); do \
(readlink $f | grep -q -s "/Library") && echo Removing "$f" && rm -f "$f"; \
done || exit 0
## Install our regular dependencies.
- name: Install dependencies (macOS)
if: ${{runner.os == 'macOS'}}
run: sh -ex .travis/deps.sh osx
- name: Install dependencies
- name: Install dependencies (Linux)
if: ${{runner.os == 'Linux'}}
run: sh -ex .travis/deps.sh linux
- name: makefile build
Expand Down
21 changes: 14 additions & 7 deletions .github/workflows/cmake-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,22 @@ jobs:
os: [macos-12, macos-11]
steps:
- uses: actions/checkout@v3
## For some reason, the macos-11 image has symlinks to /Library in /usr/local/bin
- name: Clean /usr/local/bin symlinks
run: |
## Workaround for remnant symlinks in /usr/local pointing back to
## macOS frameworks.
##
## Future: Will have to keep an eye on SDL_ttf's Python dependency
## so that the correct/appropriate Python version is removed.
- name: Remnant symlink cleanup
run: |
brew unlink python@3 || true
brew uninstall --ignore-dependencies python@3 || true
brew unlink [email protected] || true
brew uninstall --ignore-dependencies [email protected] || true
for f in $(find /usr/local/bin -type l -print); do \
(readlink $f | grep -q -s "/Library") && echo Removing "$f" && rm -f "$f"; \
done || exit 0
(readlink $f | grep -q -s "/Library") && echo Removing "$f" && rm -f "$f"; \
done || exit 0
- name: Install dependencies
run: |
sh -ex .travis/deps.sh osx
run: sh -ex .travis/deps.sh osx
- name: cmake-builder.sh
run: |
cmake/cmake-builder.sh --config Release --flavor xcode --lto --notest --cpack_suffix x86_64.${{matrix.os}}
Expand Down
7 changes: 2 additions & 5 deletions .travis/deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

install_osx() {
brew update
brew install pkg-config
brew install pcre libpng libedit
brew install sdl2 freetype2 sdl2_ttf
brew install vde
brew install cmake gnu-getopt coreutils
brew install pkg-config pcre libpng libedit sdl2 freetype2 sdl2_ttf \
vde cmake gnu-getopt coreutils
}

install_linux() {
Expand Down
14 changes: 9 additions & 5 deletions scp.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
#define MIN(a,b) (((a) <= (b)) ? (a) : (b))
#endif
/* Max width of a value expressed as a formatted string */
#define MAX_WIDTH ((int) ((CHAR_BIT * sizeof (t_value) * 4 + 3)/3))
#define MAX_WIDTH ((CHAR_BIT * sizeof (t_value) * 4 + 3) / 3)


/* search logical and boolean ops */
Expand Down Expand Up @@ -7406,9 +7406,12 @@ t_stat dir_cmd (int32 flg, CONST char *cptr)
{
DIR_CTX dir_state;
t_stat r;
char WildName[PATH_MAX + 1];
char *WildName;
struct stat filestat;

if ((WildName = (char *) calloc(PATH_MAX + 1, sizeof(char))) == NULL)
return SCPE_MEM;

GET_SWITCHES (cptr); /* get switches */
memset (&dir_state, 0, sizeof (dir_state));
strlcpy (WildName, cptr, sizeof(WildName));
Expand All @@ -7431,8 +7434,9 @@ if (r != SCPE_OK) {
sim_printf ("\n Directory of %s\n\n", cp);
sim_printf ("File Not Found\n\n");
free (cp);
return SCPE_OK;
r = SCPE_OK;
}
free(WildName);
return r;
}

Expand Down Expand Up @@ -11688,7 +11692,7 @@ dbuf[MAX_WIDTH] = 0;
d = MAX_WIDTH;
do {
d = d - 1;
digit = (int32) (val % radix);
digit = val % radix;
val = val / radix;
dbuf[d] = (char)((digit <= 9)? '0' + digit: 'A' + (digit - 10));
} while ((d > 0) && (val != 0));
Expand All @@ -11706,7 +11710,7 @@ switch (format) {
break;
ndigits = MAX_WIDTH - digit;
commas = (ndigits - 1)/3;
for (digit=0; digit<ndigits-3; digit++)
for (digit=0; digit + 3 < ndigits; digit++)
dbuf[MAX_WIDTH + (digit - ndigits) - (ndigits - digit - 1)/3] = dbuf[MAX_WIDTH + (digit - ndigits)];
for (digit=1; digit<=commas; digit++)
dbuf[MAX_WIDTH - (digit * 4)] = ',';
Expand Down

0 comments on commit ae9e57f

Please sign in to comment.