23 March 2024, 13:36 | #1 |
Registered User
Join Date: Oct 2017
Location: São Leopoldo / Brazil
Age: 46
Posts: 219
|
Stack size set on icon ignored on 3.2.2.1
Hi there,
Apparently, on my system, the stack size set on a program's .info is being ignored on launch. My specific test case: AmigaGPT warns if a stack size of at least 32768 isn't set. And despite such value being set on its icon, I get the warn every time I launch it. Now, if running from the Shell and typing stack 32768 before running the program, such warning doesn't appear. My system is an Amiga 1200 with TF1260, KS 47.111 and WB 47.4 with no performance patches whatsoever, except for MuFastRom, MuFastChip and MuFastZero. |
24 March 2024, 13:45 | #2 |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,393
|
I've tried out Scout yesterday, a system information tool. Scout also has a stack setting of 32768 in its tool icon, and that stack size really appears in the task list of Scout, too. So, I think that it's not OS 3.2.2 which is responsible for your stack problem.
I still remember that MUI 5 may have some problems in some special cases to get enough stack for some subtasks. If your AmigaGPT program uses MUI 5 then try to install StackAttack with a configuration for a larger stack. |
24 March 2024, 17:35 | #3 |
Registered User
Join Date: Oct 2017
Location: São Leopoldo / Brazil
Age: 46
Posts: 219
|
AmigaGPT doesn't use MUI, instead it relies completely on AmigaOS's GUI tools.
Maybe it's a bug on it, after all. Weird... |
24 March 2024, 18:17 | #4 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,372
|
Which type of an icon is that? A project icon or a tool icon?
|
24 March 2024, 18:36 | #5 |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,393
|
Sorry, it took a little longer to find that case in my old emails again where the stack problem occured.
In that case it was not MUI 5 directly, not the tool directly, but it was caused by the MagicASL patch, which was injecting MUI 5 with all the stack requirements when the user tried to open an ASL requester with his tool. Since my own tool MinStack didn't support this indirect stack demand, I removed it from Aminet. But if something similar happens with AmigaGPT, maybe not only loading MUI indirectly, then try StackAttack. |
24 March 2024, 19:38 | #6 |
Registered User
Join Date: Oct 2017
Location: São Leopoldo / Brazil
Age: 46
Posts: 219
|
|
25 March 2024, 07:37 | #7 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,366
|
Does it still happen if trying to setup a stack that's bigger than the minimum requirement ?
|
25 March 2024, 21:57 | #8 |
Registered User
Join Date: Oct 2017
Location: São Leopoldo / Brazil
Age: 46
Posts: 219
|
|
25 March 2024, 23:59 | #9 |
Registered User
Join Date: Oct 2007
Location: ManCave, Canada
Posts: 1,666
|
@ CCRider
try this as it helped me quite a bit over the years with stack issues http://aminet.net/package/util/boot/StackAttack2 |
27 March 2024, 19:35 | #10 |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,393
|
AmigaGPT seems indeed to have a bug. When reading the stack size from its tool icon it divides the size by 4 by mistake! So, for an entry of 32768 it just sees 8192 bytes of stack.
When I tried 140000 for the stack setting AmigaGPT didn't complain anymore, but 131072 should also work (not tested). |
27 March 2024, 20:51 | #11 | |
Registered User
Join Date: Oct 2017
Location: São Leopoldo / Brazil
Age: 46
Posts: 219
|
Quote:
|
|
29 March 2024, 13:04 | #12 | |
Registered User
Join Date: Oct 2017
Location: São Leopoldo / Brazil
Age: 46
Posts: 219
|
Quote:
Unfortunately, the author doesn't seem convinced that the bug is on his side. |
|
29 March 2024, 13:30 | #13 |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,393
|
It's not the problem that AmigaGPT won't get enough stack with a setting of 32768, it really gets what it needs (you can see that in Scout's tasklist or with other stack monitoring tools). AmigaGPT just seems to have a bug in code which checks the stack size, maybe a shift right by 2 bits accidentally?
And I did my test on OS 3.9 with Rom 3.1.4, not on OS 3.2.2.x. For a MinStack value of 50000 AmigaGPT complained about getting 12500 only. Thousands of programs would have crashed in the past if that was true and a bug of the OS. |
29 March 2024, 14:25 | #14 |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,393
|
Exactly as supposed: AmigaGPT divides the stack size by 4 with a shift right 2 bits:
Code:
... lab_b8: move.l $3e(a2),d0 ; 19d0 : 202a 003e sub.l $3a(a2),d0 ; 19d4 : 90aa 003a stack size asr.l #2,d0 ; 19d8 : e480 shift right by 2 !! cmpi.l #$7fff,d0 ; 19da : 0c80 0000 7fff compare with 32767 bhi.w lab_b0 ; 19e0 : 6200 fcf8 lab_b9: move.l d0,-(sp) ; 19e4 : 2f00 pea lab_6c(pc) ; 19e6 : 487a f4d9 stack warning bsr.l _printf ; 19ea : 61ff 0000 b658 addq.l #8,sp ; 19f0 : 508f ... |
29 March 2024, 14:33 | #15 |
Registered User
Join Date: Oct 2017
Location: São Leopoldo / Brazil
Age: 46
Posts: 219
|
Nice findings!
Informed the dev about them... Thanks a lot! |
31 March 2024, 13:22 | #16 |
Registered User
Join Date: Apr 2016
Location: Perth, Australia
Posts: 423
|
Hey, the dev here
I don't get why it would divide by 4. In my testing it does actually work for me. Here'e the code that does all the work: Code:
struct Process *currentTask = (struct Process*)FindTask(NULL); struct CommandLineInterface *cli = (struct CommandLineInterface *)BADDR(currentTask->pr_CLI); /* If we started from Workbench then we must retrieve the startup message before doing anything else. The startup message also contains a lock on the program directory. */ if (cli == NULL) { wbStartupMessage = (struct WBStartup*)GetMsg(¤tTask->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 < 32768) { printf("Warning: The stack size of %ld bytes is too small. The minimum recommended stack size is 32768 bytes to avoid crashes.\n", total); } |
31 March 2024, 13:28 | #17 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,077
|
Because those are ULONG pointers, not BYTE pointers.
|
31 March 2024, 14:01 | #18 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,372
|
[QUOTE=Nightfox;1677059]Hey, the dev here
I don't get why it would divide by 4. In my testing it does actually work for me. Here'e the code that does all the work: Code:
// For CLI tasks, stack bounds are determined differently |
31 March 2024, 15:08 | #19 | |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,393
|
Quote:
I'm not a C coder and have no experience with GCC, but maybe there is a bug in the compiler, because both tc_SPUpper and tc_SPLower are APTR pointers, so there is no reason to shift anything by 2 in any direction. Please check your includes for the correct declaration of both pointers. And the compiler also compares the stack size with 32767 in asm and not with 32768 as in your C code, maybe just an optimization, but if a compiler makes changes like that, then the resulting asm code gets unpredictable. I can send you the complete disassembler listing, but didn't want to publish it here without your permission. |
|
31 March 2024, 15:54 | #20 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,077
|
As I said, he is recasting upper and lower to ULONG*, so when a pointer subtraction happens the result is also normalized.
If you inc/dec (++/--) a ULONG pointer, it's increased/decreased by 4, not by 1. M68K asm works the same way (predec/postinc are the operand size, not 1). Use void*, char*, (un)signed byte* or similar instead of ULONG* (or multiply total by sizeof(ULONG) after subtraction) to get the size in bytes. |
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 |
|
|