Skip to content

Commit

Permalink
Onpy put stack checker in OS3 code
Browse files Browse the repository at this point in the history
  • Loading branch information
sacredbanana committed Mar 4, 2024
1 parent 701c9e8 commit df444d4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
- Adjust screen colours to enhance visibility
- Improved error handling for connection errors
- Use a stack cookie to set minimum stack size to 32768 bytes (AmigaOS 3.1.4 or higher required)
- Shows a warning if the stack size is smaller than 32768 bytes
- Shows a warning if the stack size is smaller than 32768 bytes (AmigaOS 3 only)
- TODO - Fix send button in corner of screen on image mode in 3.X
- TODO - Fix colour of text cursor in OS4

## 1.4.2 (2024-01-31)

Expand Down
35 changes: 17 additions & 18 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ LONG main(int argc, char **argv) {
if (cli == NULL) {
wbStartupMessage = (struct WBStartup*)GetMsg(&currentTask->pr_MsgPort);
}

ULONG *upper, *lower, total;

// For CLI tasks, stack bounds are determined differently
if (currentTask->pr_CLI) {
upper = (ULONG *)currentTask->pr_ReturnAddr + sizeof(ULONG);
total = *(ULONG *)currentTask->pr_ReturnAddr;
lower = upper - total;
} else {
upper = (ULONG *)currentTask->pr_Task.tc_SPUpper;
lower = (ULONG *)currentTask->pr_Task.tc_SPLower;
total = upper - lower;
}

if (total < 327668) {
printf("Warning: The stack size of %ld bytes is too small. The minimum recommended stack size is 32768 bytes to avoid crashes.\n", total);
}
#else
if (argc == 0) {
wbStartupMessage = (struct WBStartup *)argv;
Expand All @@ -72,24 +89,6 @@ LONG main(int argc, char **argv) {
#endif
readConfig();

ULONG *upper, *lower, total;
struct Task *task = FindTask(NULL);

// For CLI tasks, stack bounds are determined differently
if (((struct Process *)task)->pr_CLI) {
upper = (ULONG *)((struct Process *)task)->pr_ReturnAddr + sizeof(ULONG);
total = *(ULONG *)((struct Process *)task)->pr_ReturnAddr;
lower = upper - total;
} else {
upper = (ULONG *)((struct Process *)task)->pr_Task.tc_SPUpper;
lower = (ULONG *)((struct Process *)task)->pr_Task.tc_SPLower;
total = upper - lower;
}

if (total < 32768) {
printf("Warning: The stack size is too small. Please increase it to at least 32768 bytes to avoid crashes.\n");
}

if (initVideo() == RETURN_ERROR) {
printf("Failed to initialize video\n");
cleanExit(RETURN_ERROR);
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define APP_VERSION "1.4.3"
#define BUILD_NUMBER "2730"
#define BUILD_NUMBER "2734"
#define APP_NAME "AmigaGPT"

0 comments on commit df444d4

Please sign in to comment.