English Amiga Board


Go Back   English Amiga Board > Main > Amiga scene

 
 
Thread Tools
Old 09 December 2023, 19:52   #61
Zener
Registered User
 
Zener's Avatar
 
Join Date: Jan 2009
Location: Barcelona / Spain
Posts: 432
Quote:
Originally Posted by TCH View Post
Zener reported that on a real Amiga the program crashes when he tries to convert an RGBA32 PNG. The cause was a SASC bug (?) which caused the program to crash right at the calling of the pixel renderer function. Neither the PNG_6_8 image renderer, nor the pixel renderer had any bugs, the crash was caused by the call itself, for reasons still unknown to me; none of the other PNG_T_D renderers did this, nor the other compilers on other platforms in that function. (The binary Bebbo's Amiga GCC had generated was working flawlessly too; only SASC did this.)

The "fix" was a very ugly hack: calling fprintf() (actually any function does it) right before the call. (Yes, WTF.) What is even more confusing, that executing the call is actually not necessary: if it is present in the code, but blocked, the code still works. (Yes, even bigger WTF.)
See for yourselves: http://oscomp.hu/depot/wtf_sasc.c

Fixed 1.1.3 versions are available at the download link above. (Only for Amiga, the other platforms were not affected.)

If anyone knows what is this and why it happens, feel free to enlighten me, because i hate being dumb.
Well done, thanks a lot for the swift fix!
Zener is offline  
Old 09 December 2023, 19:57   #62
TCH
Newbie Amiga programmer
 
TCH's Avatar
 
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
Thanks for reporting it.
TCH is offline  
Old 09 December 2023, 22:12   #63
kriz
Junior Member
 
kriz's Avatar
 
Join Date: Sep 2001
Location: No(R)Way
Age: 41
Posts: 3,200
Thanks alot @TCH got the Amiga version! Btw any upto date Morphos and Windows also available ?
kriz is offline  
Old 10 December 2023, 01:51   #64
TCH
Newbie Amiga programmer
 
TCH's Avatar
 
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
MorphOS support is not dropped, but currently my PowerMac G4 setup (which has MorphOS) is disassembled and my flat is a mess, so unfortunately i cannot release a newer MorphOS version right now.

windows however, was never supported and never will be.
TCH is offline  
Old 10 December 2023, 05:48   #65
kriz
Junior Member
 
kriz's Avatar
 
Join Date: Sep 2001
Location: No(R)Way
Age: 41
Posts: 3,200
Ok, well it seems it might come then a Mos version some time in the future.. Thanks for the Amiga exe for now TCH!
kriz is offline  
Old 10 December 2023, 09:26   #66
aros-sg
Registered User
 
Join Date: Nov 2015
Location: Italy
Posts: 191
Quote:
Originally Posted by TCH View Post
The "fix" was a very ugly hack: calling fprintf() (actually any function does it) right before the call. (Yes, WTF.) What is even more confusing, that executing the call is actually not necessary

Most likely stack too small -> overflow -> mem trash. Does the tool use recursion?
aros-sg is offline  
Old 10 December 2023, 10:16   #67
TCH
Newbie Amiga programmer
 
TCH's Avatar
 
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
Quote:
Originally Posted by kriz View Post
Ok, well it seems it might come then a Mos version some time in the future.. Thanks for the Amiga exe for now TCH!
Yes, in the future, the MorphOS version will be updated too. Until then, you should be able to use the Amiga binaries on MorphOS, as MorphOS has a very well made built-in Amiga emulator layer.
Quote:
Originally Posted by aros-sg View Post
Most likely stack too small -> overflow -> mem trash. Does the tool use recursion?
No, it does not use recursion at all. Render PNG -> render the image with the needed type/depth renderer -> render pixel. Three levels only. Also, if it is stack overflow, then how could it be "fixed" by injecting a fprintf() before the call? Also, the resulting GURU was $80000004, which means division by zero, IIRC.

Last edited by TCH; 10 December 2023 at 10:17. Reason: GURU
TCH is offline  
Old 10 December 2023, 13:33   #68
aros-sg
Registered User
 
Join Date: Nov 2015
Location: Italy
Posts: 191
Quote:
Originally Posted by TCH View Post
Also, if it is stack overflow, then how could it be "fixed" by injecting a fprintf() before the call? Also, the resulting GURU was $80000004, which means division by zero, IIRC.
80000004 is "illegal instruction". Stuff on the stack can have different layout/position on stack when changing code like adding calls (even if maybe call never actually happens). That can cause different behaviour. For example an uninitialized local variable may by luck be always 0 after adding the call, while before it may have random value or always be != 0. Also things like out of bounds accesses on local arrays can change behaviour.

What happens if the program is run with (much) more stack? Maybe something external is used (like sort() in c lib?) that needs lots of stack.

If it's not the stack and you suspect wrong code generation, what does the generated asm code look like? Is render_pixel() an inline function?
aros-sg is offline  
Old 10 December 2023, 21:31   #69
TCH
Newbie Amiga programmer
 
TCH's Avatar
 
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
Quote:
Originally Posted by aros-sg View Post
80000004 is "illegal instruction".
Whoops, you're right. $80000005 is division by zero.
Quote:
Originally Posted by aros-sg View Post
Stuff on the stack can have different layout/position on stack when changing code like adding calls (even if maybe call never actually happens). That can cause different behaviour. For example an uninitialized local variable may by luck be always 0 after adding the call, while before it may have random value or always be != 0. Also things like out of bounds accesses on local arrays can change behaviour.
No unitialized variables or arrays are there. (Unless you count the memory area being written there as an array.)
Quote:
Originally Posted by aros-sg View Post
What happens if the program is run with (much) more stack?
I've now tried to run the command 'stack 65536' before i try to convert the image with the previous (non-fixed) version, but it still crashed.
Quote:
Originally Posted by aros-sg View Post
Maybe something external is used (like sort() in c lib?) that needs lots of stack.
Nope, no external calls, aside from memory allocation and freeing calls and file I/O. PNG2ILBM has nearly zero external dependencies, that is why it is easily portable.
Quote:
Originally Posted by aros-sg View Post
If it's not the stack and you suspect wrong code generation, what does the generated asm code look like?
Is it possible to dump it? AFAIK SAS/C compiles the program internally to assembly and does not creates ASM files. I tried to disassemble it in IDA, but had no luck: the corresponding part was in a pure hexa-dump. So, i disassembled the subroutine of http://oscomp.hu/depot/wtf_sasc.c in WinUAE, without the fix, but with a 'if (cnt == 0xDEADDEAD) fprintf(stdout, "", 0);' at the beginning to be able to find it in the memory ('illegal' at 264614):
Code:
; disasm start at 002645a4:
002645a4 2f0d                     move.l a5,-(a7) [00200810]
002645a6 3a7c 0010                movea.w #$0010,a5
002645aa 4eb9 0026 bd68           jsr $0026bd68
002645b0 48e7 3f30                movem.l d2-d7/a2-a3,-(a7)
002645b4 246d 0010                movea.l (a5,$0010) == $0020a19a [06ff4000],a2
002645b8 266d 000c                movea.l (a5,$000c) == $0020a196 [09b80165],a3
002645bc 0cad dead dead 0014      cmp.l #$deaddead,(a5,$0014) == $0020a19e [00000000]
002645c4 6614                     bne.b #$14 == $002645da (T)
002645c6 42a7                     clr.l -(a7) [00200810]
002645c8 486c 0302                pea.l (a4,$0302) == $00f81902
002645cc 486c 2b56                pea.l (a4,$2b56) == $00f84156
002645d0 4eb9 0026 abc2           jsr $0026abc2
002645d6 4fef 000c                lea.l (a7,$000c) == $0020228c,a7
002645da 4a2d 0027                tst.b (a5,$0027) == $0020a1b1 [00]
002645de 56c0                     sne.b d0 (T)
002645e0 4400                     neg.b d0
002645e2 49c0                     extb.l d0
002645e4 5380                     subq.l #$01,d0
002645e6 206d 0008                movea.l (a5,$0008) == $0020a192 [00180020],a0
002645ea 43e8 0012                lea.l (a0,$0012) == $002009b8,a1
002645ee 3219                     move.w (a1)+ [0020],d1
002645f0 7400                     moveq #$00,d2
002645f2 1401                     move.b d1,d2
002645f4 3219                     move.w (a1)+ [0020],d1
002645f6 7600                     moveq #$00,d3
002645f8 1601                     move.b d1,d3
002645fa 3219                     move.w (a1)+ [0020],d1
002645fc 2f40 002c                move.l d0,(a7,$002c) == $002022ac [00000000]
00264600 7000                     moveq #$00,d0
00264602 1001                     move.b d1,d0
00264604 2f40 0020                move.l d0,(a7,$0020) == $002022a0 [f41a0e00]
00264608 2f42 0028                move.l d2,(a7,$0028) == $002022a8 [00000000]
0026460c 2f43 0024                move.l d3,(a7,$0024) == $002022a4 [002023f0]
00264610 6060                     bra.b #$60 == $00264672 (T)
00264612 7e00                     moveq #$00,d7
00264614 43db                     illegal 
00264616 1e19                     move.b (a1)+ [00],d7
00264618 7c00                     moveq #$00,d6
0026461a 1c19                     move.b (a1)+ [00],d6
0026461c 7a00                     moveq #$00,d5
0026461e 1a19                     move.b (a1)+ [00],d5
00264620 7000                     moveq #$00,d0
00264622 1019                     move.b (a1)+ [00],d0
00264624 80af 002c                or.l (a7,$002c) == $002022ac [00000000],d0
00264628 7800                     moveq #$00,d4
0026462a 3800                     move.w d0,d4
0026462c 4a2d 0027                tst.b (a5,$0027) == $0020a1b1 [00]
00264630 670a                     beq.b #$0a == $0026463c (F)
00264632 4a2d 001b                tst.b (a5,$001b) == $0020a1a5 [00]
00264636 6704                     beq.b #$04 == $0026463c (F)
00264638 7001                     moveq #$01,d0
0026463a 0c40 7000                cmp.w #$7000,d0
0026463e 49c0                     extb.l d0
00264640 122d 001f                move.b (a5,$001f) == $0020a1a9 [00],d1
00264644 49c1                     extb.l d1
00264646 7400                     moveq #$00,d2
00264648 142d 0023                move.b (a5,$0023) == $0020a1ad [00],d2
0026464c 2f0a                     move.l a2,-(a7) [00200810]
0026464e 2f02                     move.l d2,-(a7) [00200810]
00264650 2f01                     move.l d1,-(a7) [00200810]
00264652 2f00                     move.l d0,-(a7) [00200810]
00264654 2f2f 0030                move.l (a7,$0030) == $002022b0 [1c000020],-(a7) [00200810]
00264658 2f2f 0038                move.l (a7,$0038) == $002022b8 [f4360021],-(a7) [00200810]
0026465c 2f2f 0040                move.l (a7,$0040) == $002022c0 [002023f0],-(a7) [00200810]
00264660 2f04                     move.l d4,-(a7) [00200810]
00264662 2f05                     move.l d5,-(a7) [00200810]
00264664 2f06                     move.l d6,-(a7) [00200810]
00264666 2f07                     move.l d7,-(a7) [00200810]
00264668 6100 ec92                bsr.w #$ec92 == $002632fc
0026466c 4fef 002c                lea.l (a7,$002c) == $002022ac,a7
00264670 2440                     movea.l d0,a2
00264672 202d 0014                move.l (a5,$0014) == $0020a19e [00000000],d0
00264676 53ad 0014                subq.l #$01,(a5,$0014) == $0020a19e [00000000]
0026467a 4a80                     tst.l d0
0026467c 6694                     bne.b #$94 == $00264612 (T)
0026467e 7000                     moveq #$00,d0
00264680 4cdf 0cfc                movem.l (a7)+,d2-d7/a2-a3
00264684 307c 0010                movea.w #$0010,a0
00264688 dfc8                     adda.l a0,a7
0026468a 2a5f                     movea.l (a7)+ [200000f8],a5
0026468c 4e75                     rts  == $200000f8
And here it is with the applied "fix" (no 'illegal' here):
Code:
; disasm start at 002645a4:
002645a4 2f0d                     move.l a5,-(a7) [00208ef2]
002645a6 3a7c 0014                movea.w #$0014,a5
002645aa 4eb9 0026 bda0           jsr $0026bda0
002645b0 48e7 3f30                movem.l d2-d7/a2-a3,-(a7)
002645b4 2e2d 0014                move.l (a5,$0014) == $00f8d9e8 [00046704],d7
002645b8 246d 0010                movea.l (a5,$0010) == $00f8d9e4 [014e0800],a2
002645bc 266d 000c                movea.l (a5,$000c) == $00f8d9e0 [6122302e],a3
002645c0 0c87 dead dead           cmp.l #$deaddead,d7
002645c6 6614                     bne.b #$14 == $002645dc (F)
002645c8 42a7                     clr.l -(a7) [00208ef2]
002645ca 486c 0302                pea.l (a4,$0302) == $00f81902
002645ce 486c 2b5a                pea.l (a4,$2b5a) == $00f8415a
002645d2 4eb9 0026 abfa           jsr $0026abfa
002645d8 4fef 000c                lea.l (a7,$000c) == $00202244,a7
002645dc 206d 0008                movea.l (a5,$0008) == $00f8d9dc [41ee00b6],a0
002645e0 43e8 0012                lea.l (a0,$0012) == $00208cc6,a1
002645e4 3019                     move.w (a1)+ [0020],d0
002645e6 7200                     moveq #$00,d1
002645e8 1200                     move.b d0,d1
002645ea 3019                     move.w (a1)+ [0020],d0
002645ec 7400                     moveq #$00,d2
002645ee 1400                     move.b d0,d2
002645f0 3019                     move.w (a1)+ [0020],d0
002645f2 7600                     moveq #$00,d3
002645f4 1600                     move.b d0,d3
002645f6 2f41 0030                move.l d1,(a7,$0030) == $00202268 [00000000]
002645fa 2f42 002c                move.l d2,(a7,$002c) == $00202264 [00200810]
002645fe 2f43 0028                move.l d3,(a7,$0028) == $00202260 [002007ec]
00264602 4a2d 0027                tst.b (a5,$0027) == $00f8d9fb [ae]
00264606 56c0                     sne.b d0 (F)
00264608 4400                     neg.b d0
0026460a 49c0                     extb.l d0
0026460c 5380                     subq.l #$01,d0
0026460e 2f40 0024                move.l d0,(a7,$0024) == $0020225c [002557b4]
00264612 6000 0098                bra.w #$0098 == $002646ac (T)
00264616 204b                     movea.l a3,a0
00264618 43d0                     lea.l (a0),a1
0026461a 1019                     move.b (a1)+ [00],d0
0026461c 1219                     move.b (a1)+ [00],d1
0026461e 1419                     move.b (a1)+ [00],d2
00264620 588b                     addaq.l #$04,a3
00264622 1619                     move.b (a1)+ [00],d3
00264624 1f40 0022                move.b d0,(a7,$0022) == $0020225a [00]
00264628 1f41 0021                move.b d1,(a7,$0021) == $00202259 [20]
0026462c 2007                     move.l d7,d0
0026462e 5280                     addq.l #$01,d0
00264630 6614                     bne.b #$14 == $00264646 (F)
00264632 42a7                     clr.l -(a7) [00208ef2]
00264634 486c 0304                pea.l (a4,$0304) == $00f81904
00264638 486c 2b5a                pea.l (a4,$2b5a) == $00f8415a
0026463c 4eb9 0026 abfa           jsr $0026abfa
00264642 4fef 000c                lea.l (a7,$000c) == $00202244,a7
00264646 102f 0022                move.b (a7,$0022) == $0020225a [00],d0
0026464a 7c00                     moveq #$00,d6
0026464c 1c00                     move.b d0,d6
0026464e 102f 0021                move.b (a7,$0021) == $00202259 [20],d0
00264652 7a00                     moveq #$00,d5
00264654 1a00                     move.b d0,d5
00264656 7800                     moveq #$00,d4
00264658 1802                     move.b d2,d4
0026465a 4a2d 0027                tst.b (a5,$0027) == $00f8d9fb [ae]
0026465e 670a                     beq.b #$0a == $0026466a (T)
00264660 4a2d 001b                tst.b (a5,$001b) == $00f8d9ef [00]
00264664 6704                     beq.b #$04 == $0026466a (T)
00264666 7001                     moveq #$01,d0
00264668 0c40 7000                cmp.w #$7000,d0
0026466c 7200                     moveq #$00,d1
0026466e 1203                     move.b d3,d1
00264670 82af 0024                or.l (a7,$0024) == $0020225c [002557b4],d1
00264674 7400                     moveq #$00,d2
00264676 3401                     move.w d1,d2
00264678 49c0                     extb.l d0
0026467a 122d 001f                move.b (a5,$001f) == $00f8d9f3 [4c],d1
0026467e 49c1                     extb.l d1
00264680 7600                     moveq #$00,d3
00264682 162d 0023                move.b (a5,$0023) == $00f8d9f7 [6e],d3
00264686 2f0a                     move.l a2,-(a7) [00208ef2]
00264688 2f03                     move.l d3,-(a7) [00208ef2]
0026468a 2f01                     move.l d1,-(a7) [00208ef2]
0026468c 2f00                     move.l d0,-(a7) [00208ef2]
0026468e 2f2f 0038                move.l (a7,$0038) == $00202270 [002009a6],-(a7) [00208ef2]
00264692 2f2f 0040                move.l (a7,$0040) == $00202278 [002560da],-(a7) [00208ef2]
00264696 2f2f 0048                move.l (a7,$0048) == $00202280 [200000f8],-(a7) [00208ef2]
0026469a 2f02                     move.l d2,-(a7) [00208ef2]
0026469c 2f04                     move.l d4,-(a7) [00208ef2]
0026469e 2f05                     move.l d5,-(a7) [00208ef2]
002646a0 2f06                     move.l d6,-(a7) [00208ef2]
002646a2 6100 ec58                bsr.w #$ec58 == $002632fc
002646a6 4fef 002c                lea.l (a7,$002c) == $00202264,a7
002646aa 2440                     movea.l d0,a2
002646ac 2007                     move.l d7,d0
002646ae 5387                     subq.l #$01,d7
002646b0 4a80                     tst.l d0
002646b2 6600 ff62                bne.w #$ff62 == $00264616 (F)
002646b6 7000                     moveq #$00,d0
002646b8 4cdf 0cfc                movem.l (a7)+,d2-d7/a2-a3
002646bc 307c 0014                movea.w #$0014,a0
002646c0 dfc8                     adda.l a0,a7
002646c2 2a5f                     movea.l (a7)+ [ffffffff],a5
002646c4 4e75                     rts  == $ffffffff
So yes, it seems wrong code generation to me.
Quote:
Originally Posted by aros-sg View Post
Is render_pixel() an inline function?
No, it's not.
TCH is offline  
Old 11 December 2023, 14:32   #70
modrobert
old bearded fool
 
modrobert's Avatar
 
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 779
Perhaps you can use the SAS/C integrated 'cpr' (CodeProbe) debugger to disassemble (and single step through the code)?

The "fprintf()" problem/workaround seems more like some option is missing during compile/linking, code alignment related, check/set with 'scopts' on the Amiga side in compile directory.

I tried to convert a png image with the 68020+FPU version on my A1200 and got:
Code:
Error 0x00020017: Invalid filter type.
Will try another image, this one was a screen dump png.

EDIT:

Tried another PNG image, same error (Error 0x00020017: Invalid filter type.), image attached.

BTW:

The default is stack protection code injected when you compile with SAS/C, so it will warn with a requester window if not enough stack when launching the program.
Attached Thumbnails
Click image for larger version

Name:	walking_dead.png
Views:	19
Size:	430.3 KB
ID:	81012  

Last edited by modrobert; 11 December 2023 at 15:26. Reason: Attached image.
modrobert is offline  
Old 11 December 2023, 15:34   #71
TCH
Newbie Amiga programmer
 
TCH's Avatar
 
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
Quote:
Originally Posted by modrobert View Post
Perhaps you can use the SAS/C integrated 'cpr' (CodeProbe) debugger to disassemble (and single step through the code)?
Thanks, i will try soon.
Quote:
Originally Posted by modrobert View Post
The "fprintf()" workaround seems more like some option is missing during compile/linking, check/set with 'scopts' on the Amiga side in compile directory.
This is my SCOPTIONS file:
Code:
CODE=FAR
MATH=68881
CPU=68020
OPTIMIZE
LINK
VERBOSE
STRIPDEBUG
STACKEXTEND
NOICONS
Quote:
Originally Posted by modrobert View Post
I tried to convert a png image with the 68020+FPU version on my A1200 and got:
Code:
Error 0x00020017: Invalid filter type.
Will try another image, this one was a screen dump png.

EDIT:

Tried another PNG image, same error (Error 0x00020017: Invalid filter type.), image attached.
No errors here. Neither under Amiga (68020+68881), nor under Linux. I think the decompression fails at you due to not enough memory.

However, there is a bug in the Amiga versions of PNG2ILBM: error 0x00020017 is not the invalid filter type, but "TInfl inflate error: insufficient memory or corrupted data" (this is why i think you have insufficient memory); 0x00020018 is the invalid filter type. The error string list is erroneous (one place up) after error 2 (out of memory). Thanks for reporting, i'll check it soon.

Edit: Got it, just missed the comma after the string. 1.1.4 will be released soon.
Quote:
Originally Posted by modrobert View Post
The default is stack protection code injected when you compile with SAS/C, so it will warn with a requester window if not enough stack when launching the program.
It did not warn, also giving it bigger stack did nothing. Also, that 'illegal' in the disasm dump does not seem stack error to me, but bad asm code.
TCH is offline  
Old 11 December 2023, 15:56   #72
TCH
Newbie Amiga programmer
 
TCH's Avatar
 
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
The 1.1.4 binaries are up, please download and retry, now you should have the correct error message. (Only the Amiga version was affected.)
TCH is offline  
Old 11 December 2023, 16:08   #73
modrobert
old bearded fool
 
modrobert's Avatar
 
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 779
Quote:
Originally Posted by TCH View Post
Thanks, i will try soon.This is my SCOPTIONS file:
Code:
CODE=FAR
MATH=68881
CPU=68020
OPTIMIZE
LINK
VERBOSE
STRIPDEBUG
STACKEXTEND
 NOICONS
Try adding "DATA=FAR" as well regarding the "fprintf() needed" problem. The stack check warning option is disabled because you chose "STACKEXTEND".

Quote:
Originally Posted by TCH View Post
However, there is a bug in the Amiga versions of PNG2ILBM: error 0x00020017 is not the invalid filter type, but "TInfl inflate error: insufficient memory or corrupted data" (this is why i think you have insufficient memory); 0x00020018 is the invalid filter type. The error string list is erroneous (one place up) after error 2 (out of memory). Thanks for reporting, i'll check it soon.

Edit: Got it, just missed the comma after the string. 1.1.4 will be released soon.It did not warn, also giving it bigger stack did nothing. Also, that 'illegal' in the disasm dump does not seem stack error to me, but bad asm code.
OK, that makes sense, because I got it while having network and SMB loaded, so only like 3mb RAM left, and was doing the conversion with in/out files on the RAM: drive.

Thanks for fixing.
modrobert is offline  
Old 11 December 2023, 16:19   #74
TCH
Newbie Amiga programmer
 
TCH's Avatar
 
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
Quote:
Originally Posted by modrobert View Post
Try adding "DATA=FAR" as well regarding the "fprintf() needed" problem.
I tried to do that, but then the build is failed:
Code:
Error 502: ___cxexst symbol - Distance for Reloc16 > 32768

  First Reference in Unit png2ilbm.c at offset 00002510 in file `png2ilbm.o`
  To Unit _cxexst at offset 0000c3e8 in file `LIB:scnb.lib`
Edit: ignore this, i am an idiot and did
Code:
Echo "CODE=FAR" > SCOPTIONS
Echo "DATA=FAR" > SCOPTIONS
instead of
Code:
Echo "CODE=FAR" > SCOPTIONS
Echo "DATA=FAR" >> SCOPTIONS
No wonder it died...

Edit 2: 'DATA=FAR' did not helped with the 'fprintf' workarounded 'illegal' problem. (Is there any kind of non-block CODE tag in the forum?)
Quote:
Originally Posted by modrobert View Post
The stack check warning option is disabled because you chose "STACKEXTEND".
Thanks, i did not know that. But then again, it cannot fail because of stack, because it will automatically extend, right? (Also, i gave 65536 Bytes of stack to it and nothing changed. And the disasm contains one 'illegal' instruction.)

Last edited by TCH; 11 December 2023 at 16:25. Reason: My bad...
TCH is offline  
Old 11 December 2023, 16:32   #75
aros-sg
Registered User
 
Join Date: Nov 2015
Location: Italy
Posts: 191
Was the disasm done before the code was run/executed? To exclude the possibility that something trashed the code, after it was loaded into memory.


Never used sas c, but there seems to be an option "DISASM=file" to make it write the assembly code it generates to a file (or to console window, if file = "*"). How does that look like?
aros-sg is offline  
Old 11 December 2023, 16:40   #76
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,214
Many years ago I was going through some low-level code in a spacecraft control system and I found a line with just printf(), surrounded by "DO NOT REMOVE" comments. "Pah," thought I, knowing better, and removed it. The damned thing crashed almost immediately. I put the printf() back in and all was well, so I added another few rows of comments along the lines of "no, really, do not remove this!" and got on with things.

As far as I know this "feature" is present in all subsequent versions and has successfully sent probes to Mars, Venus, Mercury, the Sun and Jupiter. So all's well that end's well.
E-Penguin is offline  
Old 11 December 2023, 16:46   #77
modrobert
old bearded fool
 
modrobert's Avatar
 
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 779
Quote:
Originally Posted by TCH View Post
The 1.1.4 binaries are up, please download and retry, now you should have the correct error message. (Only the Amiga version was affected.)
Works, got the "insufficient memory or corrupted data" error, also managed to convert the images with 8mb fast RAM.

Last edited by modrobert; 11 December 2023 at 17:03.
modrobert is offline  
Old 11 December 2023, 17:57   #78
TCH
Newbie Amiga programmer
 
TCH's Avatar
 
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
Quote:
Originally Posted by aros-sg View Post
Was the disasm done before the code was run/executed? To exclude the possibility that something trashed the code, after it was loaded into memory.
It was WinUAE's debugger's memory disasm. But we can rule out corruption; see next:
Quote:
Originally Posted by aros-sg View Post
Never used sas c, but there seems to be an option "DISASM=file" to make it write the assembly code it generates to a file (or to console window, if file = "*"). How does that look like?
Thanks, that did the trick. Here is the function without the fix:
Code:
png_render_6_8:
              MOVE.L         A5,-(A7)                 ;2f0d 
              MOVE.W         #$10,A5                  ;3a7c 0010 
              JSR            (__cxexst).l             ;4eb9 0000 0000 
              MOVEM.L        D2/D3/D4/D5/D6/D7/A2/A3,-(A7);48e7 3f30 
___png_render_6_8__1:
              MOVE.L         $10(A5),A2               ;246d 0010 
              MOVE.L         $c(A5),A3                ;266d 000c 
              TST.B          $27(A5)                  ;4a2d 0027 
              SNE            D0                       ;56c0 
              NEG.B          D0                       ;4400 
              EXTB.L         D0                       ;49c0 
              SUBQ.L         #$1,D0                   ;5380 
              MOVE.L         $8(A5),A0                ;206d 0008 
              LEA            $12(A0),A1               ;43e8 0012 
              MOVE.W         (A1)+,D1                 ;3219 
              MOVEQ.L        #$0,D2                   ;7400 
              MOVE.B         D1,D2                    ;1401 
              MOVE.W         (A1)+,D1                 ;3219 
              MOVEQ.L        #$0,D3                   ;7600 
              MOVE.B         D1,D3                    ;1601 
              MOVE.W         (A1)+,D1                 ;3219 
              MOVE.L         D0,$2c(A7)               ;2f40 002c 
              MOVEQ.L        #$0,D0                   ;7000 
              MOVE.B         D1,D0                    ;1001 
              MOVE.L         D0,$20(A7)               ;2f40 0020 
              MOVE.L         D2,$28(A7)               ;2f42 0028 
              MOVE.L         D3,$24(A7)               ;2f43 0024 
              BRA.B          ___png_render_6_8__8     ;6060 
___png_render_6_8__2:
              MOVEQ.L        #$0,D7                   ;7e00 
              LEA            (A3)+,A1                 ;43db 
              MOVE.B         (A1)+,D7                 ;1e19 
              MOVEQ.L        #$0,D6                   ;7c00 
              MOVE.B         (A1)+,D6                 ;1c19 
              MOVEQ.L        #$0,D5                   ;7a00 
              MOVE.B         (A1)+,D5                 ;1a19 
              MOVEQ.L        #$0,D0                   ;7000 
              MOVE.B         (A1)+,D0                 ;1019 
              OR.L           $2c(A7),D0               ;80af 002c 
              MOVEQ.L        #$0,D4                   ;7800 
              MOVE.W         D0,D4                    ;3800 
              TST.B          $27(A5)                  ;4a2d 0027 
              BEQ.B          ___png_render_6_8__5     ;670a 
___png_render_6_8__3:
              TST.B          $1b(A5)                  ;4a2d 001b 
              BEQ.B          ___png_render_6_8__5     ;6704 
___png_render_6_8__4:
              MOVEQ.L        #$1,D0                   ;7001 
              DC.W           $c40                     ;0c40 
___png_render_6_8__5:
              MOVEQ.L        #$0,D0                   ;7000 
___png_render_6_8__6:
              EXTB.L         D0                       ;49c0 
              MOVE.B         $1f(A5),D1               ;122d 001f 
              EXTB.L         D1                       ;49c1 
              MOVEQ.L        #$0,D2                   ;7400 
              MOVE.B         $23(A5),D2               ;142d 0023 
              MOVE.L         A2,-(A7)                 ;2f0a 
              MOVE.L         D2,-(A7)                 ;2f02 
              MOVE.L         D1,-(A7)                 ;2f01 
              MOVE.L         D0,-(A7)                 ;2f00 
              MOVE.L         $30(A7),-(A7)            ;2f2f 0030 
              MOVE.L         $38(A7),-(A7)            ;2f2f 0038 
              MOVE.L         $40(A7),-(A7)            ;2f2f 0040 
              MOVE.L         D4,-(A7)                 ;2f04 
              MOVE.L         D5,-(A7)                 ;2f05 
              MOVE.L         D6,-(A7)                 ;2f06 
              MOVE.L         D7,-(A7)                 ;2f07 
              BSR.W          render_pixel             ;6100 ecb0 
___png_render_6_8__7:
              LEA            $2c(A7),A7               ;4fef 002c 
              MOVE.L         D0,A2                    ;2440 
___png_render_6_8__8:
              MOVE.L         $14(A5),D0               ;202d 0014 
              SUBQ.L         #$1,$14(A5)              ;53ad 0014 
              TST.L          D0                       ;4a80 
              BNE.B          ___png_render_6_8__2     ;6694 
___png_render_6_8__9:
              MOVEQ.L        #$0,D0                   ;7000 
___png_render_6_8__10:
              MOVEM.L        (A7)+,D2/D3/D4/D5/D6/D7/A2/A3;4cdf 0cfc 
              MOVE.W         #$10,A0                  ;307c 0010 
              ADD.L          A0,A7                    ;dfc8 
              MOVE.L         (A7)+,A5                 ;2a5f 
              RTS                                     ;4e75
and with the fix
Code:
png_render_6_8:
              MOVE.L         A5,-(A7)                 ;2f0d 
              MOVE.W         #$14,A5                  ;3a7c 0014 
              JSR            (__cxexst).l             ;4eb9 0000 0000 
              MOVEM.L        D2/D3/D4/D5/D6/D7/A2/A3,-(A7);48e7 3f30 
___png_render_6_8__1:
              MOVE.L         $14(A5),D7               ;2e2d 0014 
              MOVE.L         $10(A5),A2               ;246d 0010 
              MOVE.L         $c(A5),A3                ;266d 000c 
              MOVE.L         $8(A5),A0                ;206d 0008 
              LEA            $12(A0),A1               ;43e8 0012 
              MOVE.W         (A1)+,D0                 ;3019 
              MOVEQ.L        #$0,D1                   ;7200 
              MOVE.B         D0,D1                    ;1200 
              MOVE.W         (A1)+,D0                 ;3019 
              MOVEQ.L        #$0,D2                   ;7400 
              MOVE.B         D0,D2                    ;1400 
              MOVE.W         (A1)+,D0                 ;3019 
              MOVEQ.L        #$0,D3                   ;7600 
              MOVE.B         D0,D3                    ;1600 
              MOVE.L         D1,$30(A7)               ;2f41 0030 
              MOVE.L         D2,$2c(A7)               ;2f42 002c 
              MOVE.L         D3,$28(A7)               ;2f43 0028 
              TST.B          $27(A5)                  ;4a2d 0027 
              SNE            D0                       ;56c0 
              NEG.B          D0                       ;4400 
              EXTB.L         D0                       ;49c0 
              SUBQ.L         #$1,D0                   ;5380 
              MOVE.L         D0,$24(A7)               ;2f40 0024 
              BRA.W          ___png_render_6_8__10    ;6000 009c 
___png_render_6_8__2:
              MOVE.L         A3,A0                    ;204b 
              LEA            (A0),A1                  ;43d0 
              MOVE.B         (A1)+,D0                 ;1019 
              MOVE.B         (A1)+,D1                 ;1219 
              MOVE.B         (A1)+,D2                 ;1419 
              ADDQ.L         #$4,A3                   ;588b 
              MOVE.B         (A1)+,D3                 ;1619 
              MOVE.B         D0,$22(A7)               ;1f40 0022 
              MOVE.B         D1,$21(A7)               ;1f41 0021 
              MOVE.L         D7,D0                    ;2007 
              ADDQ.L         #$1,D0                   ;5280 
              BNE.B          ___png_render_6_8__4     ;6618 
___png_render_6_8__3:
              CLR.L          -(A7)                    ;42a7 
              PEA            (+$302).l                ;4879 0000 0302 
              PEA            (__iob+$22).l            ;4879 0000 0022 
              JSR            (fprintf).l              ;4eb9 0000 0000 
              LEA            $c(A7),A7                ;4fef 000c 
___png_render_6_8__4:
              MOVE.B         $22(A7),D0               ;102f 0022 
              MOVEQ.L        #$0,D6                   ;7c00 
              MOVE.B         D0,D6                    ;1c00 
              MOVE.B         $21(A7),D0               ;102f 0021 
              MOVEQ.L        #$0,D5                   ;7a00 
              MOVE.B         D0,D5                    ;1a00 
              MOVEQ.L        #$0,D4                   ;7800 
              MOVE.B         D2,D4                    ;1802 
              TST.B          $27(A5)                  ;4a2d 0027 
              BEQ.B          ___png_render_6_8__7     ;670a 
___png_render_6_8__5:
              TST.B          $1b(A5)                  ;4a2d 001b 
              BEQ.B          ___png_render_6_8__7     ;6704 
___png_render_6_8__6:
              MOVEQ.L        #$1,D0                   ;7001 
              DC.W           $c40                     ;0c40 
___png_render_6_8__7:
              MOVEQ.L        #$0,D0                   ;7000 
___png_render_6_8__8:
              MOVEQ.L        #$0,D1                   ;7200 
              MOVE.B         D3,D1                    ;1203 
              OR.L           $24(A7),D1               ;82af 0024 
              MOVEQ.L        #$0,D2                   ;7400 
              MOVE.W         D1,D2                    ;3401 
              EXTB.L         D0                       ;49c0 
              MOVE.B         $1f(A5),D1               ;122d 001f 
              EXTB.L         D1                       ;49c1 
              MOVEQ.L        #$0,D3                   ;7600 
              MOVE.B         $23(A5),D3               ;162d 0023 
              MOVE.L         A2,-(A7)                 ;2f0a 
              MOVE.L         D3,-(A7)                 ;2f03 
              MOVE.L         D1,-(A7)                 ;2f01 
              MOVE.L         D0,-(A7)                 ;2f00 
              MOVE.L         $38(A7),-(A7)            ;2f2f 0038 
              MOVE.L         $40(A7),-(A7)            ;2f2f 0040 
              MOVE.L         $48(A7),-(A7)            ;2f2f 0048 
              MOVE.L         D2,-(A7)                 ;2f02 
              MOVE.L         D4,-(A7)                 ;2f04 
              MOVE.L         D5,-(A7)                 ;2f05 
              MOVE.L         D6,-(A7)                 ;2f06 
              BSR.W          render_pixel             ;6100 ec70 
___png_render_6_8__9:
              LEA            $2c(A7),A7               ;4fef 002c 
              MOVE.L         D0,A2                    ;2440 
___png_render_6_8__10:
              MOVE.L         D7,D0                    ;2007 
              SUBQ.L         #$1,D7                   ;5387 
              TST.L          D0                       ;4a80 
              BNE.W          ___png_render_6_8__2     ;6600 ff5e 
___png_render_6_8__11:
              MOVEQ.L        #$0,D0                   ;7000 
___png_render_6_8__12:
              MOVEM.L        (A7)+,D2/D3/D4/D5/D6/D7/A2/A3;4cdf 0cfc 
              MOVE.W         #$14,A0                  ;307c 0014 
              ADD.L          A0,A7                    ;dfc8 
              MOVE.L         (A7)+,A5                 ;2a5f 
              RTS                                     ;4e75
If we compare these to the ones above, we can see, that the 'illegal' ($43db) is really there. SAS/C "says", it is a 'LEA (A3)+,A1' while WinUAE says it is illegal. According to this opcode table (http://goldencrystal.free.fr/M68kOpcodes-v2.3.pdf) 'LEA' is built as '0100 An 111 MODE Xn', so, '$43db' boils to down '0100 A1 111 (An)+ A3', so this is valid and '$43db' is 'LEA (A3)+,A1'. So, this should not be 'illegal'. Either this is an alignment bug in SAS/C, or the 68020 handles this instruction type differently (then SAS/C should not generate code like this for 68020), or it is a decoding bug in WinUAE 5.0.0 (not likely, i think Zener used a real Amiga).

I've reuploaded the old and buggy v1.1.2 to there:
- http://oscomp.hu/depot/png2ilbm_1.1....miga-68000.lha
- http://oscomp.hu/depot/png2ilbm_1.1....miga-68020.lha
- http://oscomp.hu/depot/png2ilbm_1.1....8020+68881.lha
And a testing image which causes GURU $80000004 in WinUAE 5.0.0: http://oscomp.hu/depot/png2ilbm_1.1....g_6_8_test.png

Could someone test it on a real hardware too, that it is giving GURU $80000004 there too? Thanks, my equipment is currently not available, my flat is a mess...

Edit: In WinUAE it causes GURU $80000004 under pure 68000 with the 68000 binary; this is not 68020-related.
Quote:
Originally Posted by E-Penguin View Post
Many years ago I was going through some low-level code in a spacecraft control system and I found a line with just printf(), surrounded by "DO NOT REMOVE" comments. "Pah," thought I, knowing better, and removed it. The damned thing crashed almost immediately. I put the printf() back in and all was well, so I added another few rows of comments along the lines of "no, really, do not remove this!" and got on with things.

As far as I know this "feature" is present in all subsequent versions and has successfully sent probes to Mars, Venus, Mercury, the Sun and Jupiter. So all's well that end's well.
We now face a very similar case...these C compilers are full with nasty surprises.
Quote:
Originally Posted by modrobert View Post
Works, got the "insufficient memory or corrupted data" error, also managed to convert the images with 8mb fast RAM.
Cool, one less bug, one less problem.

Last edited by TCH; 11 December 2023 at 18:10. Reason: 68020 ruled out as cause...
TCH is offline  
Old 11 December 2023, 18:15   #79
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,975
"LEA (A3)+,A1" is illegal opcode for 68000, for 68020+ perhaps too, but im not sure. Im not coding for 68020+ too many.
Don_Adan is offline  
Old 11 December 2023, 18:21   #80
TCH
Newbie Amiga programmer
 
TCH's Avatar
 
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
You mean this instruction itself is illegal? Why?
TCH is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
new WAV to 8SVX converter for Amiga, MorphOS and Linux TCH Amiga scene 26 11 December 2023 16:10
FS-UAE 2.0 for Windows, Mac OS X, Linux and FreeBSD FrodeSolheim News 6 31 October 2012 23:25
PNG Icon to Color Icon Converter? Leandro Jardim request.Apps 1 24 May 2010 04:39
UAE for Sun Solaris (Sparc) commie1974 support.OtherUAE 8 31 August 2006 21:46
convert .info to png or jpg(with linux) lostfriend request.Apps 4 22 March 2006 01:26

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:23.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10764 seconds with 16 queries