IsPicture on virtual file derived from a RAM: file

Report any Hollywood bugs here
Post Reply
zylesea
Posts: 227
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

IsPicture on virtual file derived from a RAM: file

Post by zylesea »

I found a small oddity that leads to a hard crash (application is mediating) (at least on MorphOS).
The follwing code fragment

Code: Select all

my_thumb = DefineVirtualFile(mythfile$, thumbstart$, thumbend$-thumbstart$, "thumbnail.jpg")
ret_val, table=IsPicture(my_thumb)                
crashes if executed more than ten times AND the path of the original file that the virtual file is derived from is RAM: based.
If the files are not RAM: based everything works as expected. Also if files are in RAM: but are less than 10 it's works okay, too.

You may try it out with exutil, select show thumbnails and select a few (ell, more than 10) pics in RAM:..
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: IsPicture on virtual file derived from a RAM: file

Post by airsoftsoftwair »

Hmm, sounds weird. Can you upload a complete demo script (with a sample image) that I can just run and try here?
zylesea
Posts: 227
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

Re: IsPicture on virtual file derived from a RAM: file

Post by zylesea »

airsoftsoftwair wrote:Hmm, sounds weird. Can you upload a complete demo script (with a sample image) that I can just run and try here?
Here's a short working demo program (a very basic thumbnail viewer) showing this behaviour:

Code: Select all

@DISPLAY {Width = 880, Height = 600, Color = #WHITE}
kx=0

mytemppath$="ram:"                           ; does work only with _less_ than 10 pictures with an embedded thumbnail
;mytemppath$="work:pixx/"                ; does always work, adjust your path

Function p_mythumb()
              OpenFile (1,fullpath$)
              jpgstringsize$=30000
              If FileSize(fullpath$)<30000 Then jpgstringsize$= FileSize(fullpath$)
              my_rawjpg$=ReadString(1,jpgstringsize$)
              thumbstart$=(PatternFindStrDirect(my_rawjpg$,"\255\216",100))   
              thumbend$=(PatternFindStrDirect(my_rawjpg$,"\255\217",100))   
              If thumbend$ <> -1 And  thumbend$>thumbstart$
                 my_thumb = DefineVirtualFile(fullpath$, thumbstart$, thumbend$-thumbstart$, "thumbnail.jpg")
                  DebugPrint ("virtual file defined") ;bis hier alles okay
                  ret_valx, table=IsPicture(my_thumb) ;                           <--- here the crash does happen at the 10th repetition if original files are from RAM:
                   DebugPrint("passed IsPicture for the ", kx,"th time")
                 If ret_valx=True
                    DebugPrint(fullpath$)
                    If ret_valx=True
                    LoadBrush (kx,my_thumb)
                    Else
                    LoadBrush (kx,FullPath$)
                        EndIf
                    ScaleBrush (kx, 80, #KEEPASPRAT, smooth)
                     Else
                    ret_val, table=IsPicture(fullpath$)
                    If ret_val=True
                       LoadBrush (kx,fullpath$)
                       ScaleBrush (kx, 80, #KEEPASPRAT, smooth)
                    Else
                       Local nogood$="No valid thumbnail for file "..fullpath$
                       DebugPrint(nogood$)
                    EndIf
                EndIf
              Else
                DebugPrint("No thumb")
                ret_val, table=IsPicture(fullpath$)
                If ret_val=True
                   LoadBrush (kx,fullpath$)
                   ScaleBrush (kx, 80, #KEEPASPRAT, smooth)
                Else
                   Local nogood$="No valid thumbnail for file "..new_file_name$
                   DebugPrint(nogood$)
                EndIf
            EndIf
EndFunction

Function get_thumbs()
OpenDirectory (1,mytemppath$)
kx=0
 e = NextDirectoryEntry(1)
        While e <> Nil  
            ret_val=False
            fullpath$=mytemppath$..e.name
                ret_val, table=IsPicture(fullpath$)
                If ret_val=True
                   kx=kx+1
                   p_mythumb()
                   If kx>0 Then DisplayBrush(kx, (kx%10)*90-80,10+((kx-kx%10)*7))
                EndIf
          e = NextDirectoryEntry(1)
    Wend
        DebugPrint("kx total=",kx)
        CloseDirectory(1)
EndFunction
get_thumbs()
Repeat
	WaitEvent
Forever                
Just adjust the mytemppath$ variable at the scipt's start to a location with some picture files. To trigger a failure just copy at least 10 jpgs (with an embedded thumbnail) to RAM: and run the script. It always crashes (application is mediating) at the isPicture check on virtualfile (thumbnail) #10 on my system.
I didn't include example picture files as it crashes with all picture files I threw at the scipt where a thumbnail was recognized.
If it helps I can send you a MorphOS debug log.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: IsPicture on virtual file derived from a RAM: file

Post by airsoftsoftwair »

Can't reproduce the crash here. I've tested it with the files page_whatsnew1.jpg to page_whatsnew10.jpg from the Welcome example that comes with Hollywood. Worked just fine, no crash. Do these files work on your system?
zylesea
Posts: 227
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

Re: IsPicture on virtual file derived from a RAM: file

Post by zylesea »

Have you tried it on MorphOS? Crashes with the pictures you used here, too. But it seems to be an issue with the MorphOS binary. The same script but compiled for 68k runs w/o that bug on MorphOS.
I put a MorphOS-binary for testing here

The bug hapens on both MorphOS machines I tested: Powerbook and Mini, both run MorphOS 3.9.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: IsPicture on virtual file derived from a RAM: file

Post by airsoftsoftwair »

Doesn't crash here. I copied "ispicturebugtestmos" to RAM:, then I copied page_whatsnew1 to 10.jpg to RAM:, then I started the program. Debug output ended with "passed IsPicture for the 10 th time / ram:page_whatsnew10.jpg / ks total = 10." No crash. Tested on MorphOS 3.9 on a Pegasos 2 and on MorphOS 3.7 on a Powerbook.

Can you try to boot MorphOS from CD and see if it also crashes when running a vanilla MorphOS with no 3rd party tools? Maybe some 3rd party software is causing the trouble here. My MorphOS installations are both pretty barebones.
zylesea
Posts: 227
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

Re: IsPicture on virtual file derived from a RAM: file

Post by zylesea »

Digged a bit around and found a MorphOS 3.6 CD to boot off from (with 3.9 boot.img from hd then). The crash does _not_ happen then. I think we can say it's a problem on my particular set up then. I thought - still think - my system is rather clean and not messed up too much, but I'll dig into that. For now it's good to know that it is no general prob and no prob on my code - which I guessed on first. But it must be quite a strange side effect - in particular I think it's weird that the 68k binary on my MorphOS intallation runs w/o crashing, but the ppc native binary crashes.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: IsPicture on virtual file derived from a RAM: file

Post by airsoftsoftwair »

For now it's good to know that it is no general prob and no prob on my code - which I guessed on first.
Keep in mind, though, that if Hollywood crashes, it's never a problem with your code because Hollywood is designed to never crash. All scripts are running inside a sandbox. So whenever Hollywood crashes, please file a bug report.

This issue could still be a bug in Hollywood but I'm afraid I'd need to be able to reproduce it here in order to fix it. So maybe try disabling your 3rd party software one by one and see if the error goes away. If you've identified a program as the culprit, then let me know and I'll see if the bug is in Hollywood or the other program.
Post Reply