31 March 2024, 16:34 | #21 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,509
|
Quote:
Code:
ULONG upper, lower, total; // For CLI tasks, stack bounds are determined differently if (currentTask->pr_CLI) { .. } else { upper = (ULONG)currentTask->pr_Task.tc_SPUpper; lower = (ULONG)currentTask->pr_Task.tc_SPLower; total = upper - lower; } Code:
/* WARNING: APTR was redefined for the V36 Includes! APTR is a */ /* 32-Bit Absolute Memory Pointer. C pointer math will not */ /* operate on APTR -- use "ULONG *" instead. */ ... typedef void * APTR; /* 32-bit untyped pointer */ ... typedef unsigned long ULONG; /* unsigned 32-bit quantity */ |
|
01 April 2024, 11:11 | #22 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,366
|
To make it short, subtracting two ULONG pointers in C will give result in number of ULONGs, not in number of bytes.
|
01 April 2024, 13:23 | #23 |
Registered User
Join Date: Apr 2016
Location: Perth, Australia
Posts: 423
|
Thanks for the feedback. I’ll rework it on the weekend. Sorry about this bug
|
01 April 2024, 19:24 | #24 |
Registered User
Join Date: Feb 2016
Location: Homeless
Posts: 67
|
Why is the amiga os requiring users to specify stack sizes in icons or command line?
I mean, if I would write a program that needs 32Kbyte stack, then I would allocate that memory, or pre-allocate it in bss segment, and then redirect the stack pointer to that memory area... or is there something in the os that prevents doing that? |
01 April 2024, 20:04 | #25 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,372
|
Quote:
Code:
UBYTE stack[]="$STACK:32768"; |
|
01 April 2024, 22:24 | #26 |
Registered User
Join Date: Sep 2017
Location: Kansas, USA
Posts: 329
|
|
04 April 2024, 07:51 | #27 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,372
|
Not really. The 68K does not have a MMU, and thus cannot detect if the stack overruns. Thus, unlike in unix operating systems, the Os cannot assist in automatically extending the stack when necessary. You find similar constructions in MacOs, sometimes even weirder ones where you even need to specify the maximum heap a program takes - in the icon of the program.
|
06 April 2024, 12:23 | #28 |
Registered User
Join Date: Apr 2016
Location: Perth, Australia
Posts: 423
|
The stack size calculation bug is now fixed in version 1.4.5 which I just released.
Thanks for your assistance everyone. I'll be more careful with pointer arithmetic from now on! And yep AmigaGPT does use the stack cookie "$STACK:32768" to increase the stack if required but as mentioned, it requires AmigaOS 3.1.4 for that to work. If anyone is using an older version of AmigaOS, they will get a warning if the stack is too small. This would most likely happen if launched from CLI, since the AmigaGPT icon has 32768 set as stack so if launched from Workbench the stack should be automatically set. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Custom stack size for own application | neoman | Coders. System | 14 | 14 October 2022 17:47 |
Supervisor stack size? | alpine9000 | Coders. System | 71 | 09 June 2019 01:36 |
Stack position and size | hop | Coders. Asm / Hardware | 2 | 26 May 2019 18:20 |
Get Icon size? | volvo_0ne | Coders. AMOS | 2 | 13 November 2018 19:56 |
Icon size | mritter0 | support.Other | 1 | 23 May 2014 08:46 |
|
|