It is currently Wed Sep 30, 2020 9:58 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 34 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 5:47 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Fri Apr 25, 2003 4:34 pm
Posts: 987
Location: Canada
@Saki
Also note that your "workaround" disables the use of #PB_IGNORE

_________________
Image Image


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 6:48 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 3321
Location: Boston, MA
It is good you defined a crash case for a specific unsupported condition.
But, as Demivec mentioned, there are many, many cases like this.
Please edit this post for Feature Request - throw compiler error for out of bounds input.

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 6:52 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 234
Location: Pandora
@demivec
I think it's not good to declare things that are not well implemented as good, they will not get better.

PokeL and CallFunctionFast are completely different things, which are not at all comparable to ResizeImage.

ResizeImage is one of the most used graphic functions, it should be absolutely Bulletproof.

@Skywalk
Yes, they can move it.
I was just annoyed to be declared a fool, because of a not properly programmed function, not very nice.
If this error occurs in a large piece of software and people complain that the exe does not terminate,
it can be very bad to find the error.

When zooming out or shrinking an image in a dynamic environment, it can quickly approach zero.
It's not stupid at all when that happens.
To expect that zero will slowly but surely shoot the computer down without being noticed is really not to be expected.

_________________
地球上の平和


Last edited by Saki on Mon Aug 10, 2020 12:43 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 9:21 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 6:14 pm
Posts: 1852
Location: Germany (Saxony, Deutscheinsiedel)
Topic renamed and moved to FeatureRequests.

As the misbehaviour only happens, when zero is used as ResizeImage() parameter (which is not allowed according to the manual) its no bug of the PB command.

Anyway, because of the massive problems, this false use can cause, I see a feature-request here to make the ResizeImage() command more bullet-proof.

_________________
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 10:03 pm 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 1007
The compiler returns this error message for CreateImage() if 0 is used for width or height:

Code:
CreateImage(): Image 'Width' is too small, should be >0.

The same error-check should apply for ResizeImage(), to avoid the exe freezing at 25% CPU.


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 10:43 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 234
Location: Pandora
BarryG wrote:
The compiler returns this error message for CreateImage() if 0 is used for width or height:

Code:
CreateImage(): Image 'Width' is too small, should be >0.

The same error-check should apply for ResizeImage(), to avoid the exe freezing at 25% CPU.


Hi start it without debugger, or create an exe.
With every start an instance remains in the ram and continues to run after it is finished.
If you start 30x, you have 30 instances running in the background.
Then the computer freezes and gets hot.

You can see that right away in the task manager.

_________________
地球上の平和


Top
 Profile  
Reply with quote  
 Post subject: Re: Make ResizeImage bullet-proof, as parameter 0 cause prob
PostPosted: Thu Jul 30, 2020 3:15 am 
Offline
Enthusiast
Enthusiast

Joined: Wed Mar 11, 2009 4:06 pm
Posts: 319
Location: NL
Whats this doing in feature request? Its clearly a bug. A standard image function causing massive damage when fed random values. This is btw also the cause of many hacks out there. Not checking input parameters!

Some try to defend anything PB guess. Its NOT a low level function where one can peek pook till crash... and a crash is the most you got in that case. Memory cleaned up, process killed.

Any user (library) function must validate and sanitize input parameters! Programmer 101. Who doesnt agree should not create code thats used by someone else.


Top
 Profile  
Reply with quote  
 Post subject: Re: Make ResizeImage bullet-proof, as parameter 0 cause prob
PostPosted: Thu Jul 30, 2020 9:26 am 
Offline
Addict
Addict

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 927
The strange thing is that this function exists since version 3.0 (April 2002) and nobody has noticed it for 18 years!?
Or maybe this function has been modified since then?
In any case it's quite annoying.

The main problem is that this does not crash the program but fills the ram and increases the % CPU, in the (rare) case where it is run several times.
Moreover, it can't be detected with OnError
The program remains resident while the window is closed without errors.

Since this is a reproducible bug, it would deserve a version 5.72.1 (IMHO).

:wink:

_________________
(English is not my native language, I use an online translator.)


Top
 Profile  
Reply with quote  
 Post subject: Re: Make ResizeImage bullet-proof, as parameter 0 cause prob
PostPosted: Thu Jul 30, 2020 10:02 am 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 1007
Marc56us wrote:
nobody has noticed it for 18 years!?

I guess most of us check the W/H values before resizing.


Top
 Profile  
Reply with quote  
 Post subject: Re: Make ResizeImage bullet-proof, as parameter 0 cause prob
PostPosted: Thu Jul 30, 2020 3:50 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 234
Location: Pandora
Rinzwind wrote:
Whats this doing in feature request? Its clearly a bug. A standard image function causing massive damage when fed random values. This is btw also the cause of many hacks out there. Not checking input parameters!

Some try to defend anything PB guess. Its NOT a low level function where one can peek pook till crash... and a crash is the most you got in that case. Memory cleaned up, process killed.

Any user (library) function must validate and sanitize input parameters! Programmer 101. Who doesnt agree should not create code thats used by someone else.

Hi,
it's just like that.

It is quite common to repeat a function until it returns zero.

To say now that this works, but at image size zero it doesn't work and that's right, is quite adventurous.
It is logical and common to check a function to see if it returns zero to end a process when it does.
See for example FlushFileBuffer()

In the case of ResizeImage it contradicts every logic, why this should bang when reliably zero is reported back.

It was a coincidence that I was working on a shrink function for images and it ran to zero.

The computer began to get very hot.
I was stunned, looked at the task manager
and see the reason for this was the countless running instances in Ram.

So I check the code and find the cause.
This happened quickly because I already suspected it had something to do with ResizeImage and a zero value.

To me, this is a worse bug.
The consequences can cause damage to hardware and software.

Try this, you get immediately a Error message : Image 'Width' is > 32000 Pixels :wink:
Code:
imageID = CreateImage(#PB_Any , 1e5 , 1e5)

_________________
地球上の平和


Last edited by Saki on Sat Aug 01, 2020 7:18 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Make ResizeImage bullet-proof, as parameter 0 cause prob
PostPosted: Thu Jul 30, 2020 10:33 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Jun 24, 2006 3:29 am
Posts: 258
Location: Edinburgh, Scotland.
This has got to be one of the most bizarre threads I've ever encountered on these forums. Not because of the request/report, but because of some of the comments about it.

A computer got hot and that's supposed to be PB's fault? :D Try proper cooling.

The manual clearly states NOT to use 0. And whatever the discrepancies between "similar" functions, it is clearly stated. Therefore, if you do not take the obvious common sense approach and bounds check your values for this function, then it is YOUR fault. Programmer 101 preface: Read (and understand) the manual for the functions you are using.

And no, I'm not blindly defending PB like some fanboi. There is no legal or moral requirement for PB to do anything to satisfy the notion in your mind that all functions should sanitize the values. There is obviously (probably) some reason ResizeImage works in this way - and regardless, the manual states it. It is not hidden from you. If you choose to ignore it, well... *shrug* ...it may well be an odd discrepancy, but it is a documented one.

I have experienced this exact "problem" myself a while back. I didn't throw a wobbly... I checked the manual for the function again, and followed its clearly implied advice: BOUNDS CHECK YOUR OWN VALUES.

I don't actually even disagree with the FR/"bug" (lol) report, but seriously... some of the statements in this thread are nothing short of hilarious.

_________________
Proud supporter of PB! * Musician * C64/6502 Freak


Top
 Profile  
Reply with quote  
 Post subject: Re: Make ResizeImage bullet-proof, as parameter 0 cause prob
PostPosted: Thu Jul 30, 2020 11:08 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 234
Location: Pandora
@oreopa
Your posting's not exactly unfunny either.
You seem to know a lot about programming.
Your other postings are really convincing and full of interesting content ! ( as sample : #z = #PB_Any ) :D

One last one please, explain this to us :
oreopa wrote:
There is obviously (probably) some reason ResizeImage works in this way


Let someone explain to you why computers can get hot.
oreopa wrote:
A computer got hot and that's supposed to be PB's fault? :D Try proper cooling.


If you really don't know anything about something, it's better to keep quiet. :wink:

_________________
地球上の平和


Last edited by Saki on Sat Aug 01, 2020 7:18 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Make ResizeImage bullet-proof, as parameter 0 cause prob
PostPosted: Fri Jul 31, 2020 8:23 am 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 1007
Both CreateImage() and ResizeImage() say this in the Help manual:

Quote:
The dimensions of the new image. Both the width and height must be greater than zero.

But only CreateImage() raises an error if this is not the case. So why does one command do a sanitation check, and the other doesn't? There should be consistency.


Top
 Profile  
Reply with quote  
 Post subject: Re: Make ResizeImage bullet-proof, da Parameter 0 prob verur
PostPosted: Fri Jul 31, 2020 9:51 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Jun 24, 2006 3:29 am
Posts: 258
Location: Edinburgh, Scotland.
Saki wrote:
@oreopa
Your posting's not exactly unfunny either.


Glad I amused you back. :D It really wasn't a personal attack, and I will apologize for the tone of my post, if not the content.

_________________
Proud supporter of PB! * Musician * C64/6502 Freak


Top
 Profile  
Reply with quote  
 Post subject: Re: Make ResizeImage bullet-proof, as parameter 0 cause prob
PostPosted: Fri Jul 31, 2020 11:47 am 
Offline
Enthusiast
Enthusiast

Joined: Fri Jun 05, 2020 12:47 am
Posts: 113
Have you try something like this

Code:
Procedure ResizeImagePlus (imageID,w,h)
  If W=0 or h=0
     ;write here your code for an empty/clear/null sprite
  ELSE
     ResizeImage(imageID , w , h)
  ENDIF
endprocedure


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 34 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye