linux segfault imageinfo(screen..

General FreeBASIC programming questions.
Post Reply
dafhi
Posts: 1641
Joined: Jun 04, 2005 9:51

linux segfault imageinfo(screen..

Post by dafhi »

bug? .. mx linux (deb

Code: Select all

var w = 800, h = 600

screenres w,h

dim as any ptr p = imagecreate(100,100)
if imageinfo( screenptr) = 0 then put screenptr, (0,0), p, pset
if imageinfo( p) = 0 then imagedestroy p
exagonx
Posts: 315
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: linux segfault imageinfo(screen..

Post by exagonx »

dafhi wrote: Mar 15, 2022 7:17 bug? .. mx linux (deb

Code: Select all

var w = 800, h = 600

screenres w,h

dim as any ptr p = imagecreate(100,100)
if imageinfo( screenptr) = 0 then put screenptr, (0,0), p, pset
if imageinfo( p) = 0 then imagedestroy p
Work correctly on Windows 10 64Bit ( FreeBASIC 1.09)
Work correctly on MS-DOS 6.22 (FreeBASIC 1.09)
Work correctly on Ubuntu UTC 2021 x86_64(FreeBASIC 1.09)
dafhi
Posts: 1641
Joined: Jun 04, 2005 9:51

Re: linux segfault imageinfo(screen..

Post by dafhi »

Thanks for the report. I tried on mx linux and sparky both give the error
fxm
Moderator
Posts: 12107
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: linux segfault imageinfo(screen..

Post by fxm »

imageinfo( screenptr)
is invalid (aleatory result), because screenptr is not the address of an image buffer.

- In any case the instruction:
put screenptr, (0,0), p, pset
is downright a bug because screenptr is not the address of an image buffer.
- To print an image buffer on the screen, the target image buffer pointer argument must be omitted:
put (0,0), p, pset
dafhi
Posts: 1641
Joined: Jun 04, 2005 9:51

Re: linux segfault imageinfo(screen..

Post by dafhi »

on MX Linux an error with this bit of code is
double free or corruption (top)

Code: Select all

screenres 800,600

var i = 150
dim as any ptr im = imagecreate(i,i)

imagedestroy im
if imageinfo(im) = 0 then imagedestroy im
fxm
Moderator
Posts: 12107
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: linux segfault imageinfo(screen..

Post by fxm »

After:
imagedestroy im
'im' becomes a dangling pointer.
Therefore:
imageinfo(im)
is illicit (and also a second 'imagedestroy im').
exagonx
Posts: 315
Joined: Mar 20, 2009 17:03
Location: Italy
Contact:

Re: linux segfault imageinfo(screen..

Post by exagonx »

fxm wrote: Mar 15, 2022 16:43 imageinfo( screenptr)
is invalid (aleatory result), because screenptr is not the address of an image buffer.

- In any case the instruction:
put screenptr, (0,0), p, pset
is downright a bug because screenptr is not the address of an image buffer.
- To print an image buffer on the screen, the target image buffer pointer argument must be omitted:
put (0,0), p, pset
Hi fxm , please can you explain why in MSDOS, Windows 10 and Linux Ubuntu work ?
Its something I done without know ?

I have a little problem to understand the graphics coding actually.

Thanx
dafhi
Posts: 1641
Joined: Jun 04, 2005 9:51

Re: linux segfault imageinfo(screen..

Post by dafhi »

Interesting. i forget who posted the if test for imageinfo.

Well thanks i guess ill work on my string problem then. After sparky finishes installing
fxm
Moderator
Posts: 12107
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: linux segfault imageinfo(screen..

Post by fxm »

exagonx wrote: Mar 15, 2022 19:01 Hi fxm , please can you explain why in MSDOS, Windows 10 and Linux Ubuntu work ?
Its something I done without know ?

Not crashing does not mean working!
Depending on the OS environment, an instruction using a dangling pointer may or may not crash.
Post Reply