Bugs

General discussion for topics related to the FreeBASIC project or its community.
dodicat
Posts: 7444
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Bugs

Post by dodicat »

Here is code with warnings and an error
duff.bas

Code: Select all

#cmdline "-exx"
dim as long ptr p=1
print *p
sleep 
If I compile this with the 32 bit compiler to get duff.exe.
I then run this duff.exe from the command line I get
Aborting due to runtime error 12 ("segmentation violation" signal) in C:\Users\Computer\Desktop\fb\code\allbas\temp\duff.bas::()

However If I compile with the 64 bit compiler and run from the command line I get no error message on the console, just a crash with the console remaining open.
fxm
Moderator
Posts: 11124
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Bugs

Post by fxm »

I get the same warnings and the same runtime error for 32-bit/gas, 32-bit/gcc, 64-bit/gcc.
But no runtime error for 64-bit/gas64.
dodicat
Posts: 7444
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Bugs

Post by dodicat »

-gen gas 32 bits OK I get the runtime error
-gen gcc 32 bits OK I get the runtime error

-gen gcc 64 bits NOT OK, crash with no runtime error.
-gen gas64 OK I get the runtime error.
fb 1.09.0
Win 10
(using -exx throughout of course)
Tested applying the commands options in code and applying the command options as compiler flags, no difference.
adeyblue
Posts: 192
Joined: Nov 07, 2019 20:08

Re: Bugs

Post by adeyblue »

SARG wrote: May 12, 2022 10:17 I don't know if it was really intended.
Easy to fix/change by just removing one line.

Code: Select all

	case OPT_E
		fbSetOption( FB_COMPOPT_ERRORCHECK, TRUE )
		fbSetOption( FB_COMPOPT_UNWINDINFO, TRUE )  <-------- 
Jeff invented the command line option for that, so if its there,'-e' is very definitely what he wanted it to be guarded/enabled by. My patch had it enabled by default without a switch. I still think that's how it should be but eh, it's Jeff's ballpit. I'm just playing in it.
fxm
Moderator
Posts: 11124
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Bugs

Post by fxm »

It would shock me that '-e' ('QuickBASIC type error checking') would also imply 'unwindinfo' and that 'ex' wouldn't do it, knowing that '-ex' is just 'QuickBASIC type error checking' + 'Resume capacity'.
SARG
Posts: 1455
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Bugs

Post by SARG »

fxm wrote: May 13, 2022 19:49 I get the same warnings and the same runtime error for 32-bit/gas, 32-bit/gcc, 64-bit/gcc.
But no runtime error for 64-bit/gas64.
I got the rutime error. (FreeBASIC Compiler - Version 1.10.0 (2022-03-27), built for win64 (64bit))

Code: Select all

D:\compiler108\freebasic64bit\fbc64_gas64.exe "D:\fb32bit\test3.bas" -gen gas64 -R
 
D:\fb32bit\test3.bas(2) warning 4(2): Suspicious pointer assignment
D:\fb32bit\test3.bas(2) warning 4(2): Suspicious pointer assignment

Aborting due to runtime error 12 ("segmentation violation" signal) in D:\fb32bit\test3.bas::()

fxm wrote: May 13, 2022 21:59 It would shock me that '-e' ('QuickBASIC type error checking') would also imply 'unwindinfo' and that 'ex' wouldn't do it, knowing that '-ex' is just 'QuickBASIC type error checking' + 'Resume capacity'.
I agree with fxm it's not consistent. I would remove the option from -e or extent for -ex and -exx.
dodicat
Posts: 7444
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Bugs

Post by dodicat »

Hi SARG
Yes, -gen gas64 is OK
But -gen gcc doesn't give the error to the console in 64 bits (here anyway), It merely crashes.
Which must be a bug in -exx flag for -gen gcc 64 bits.
You would expect consistency, and it means my quickrunner.exe (A little command line runner), instead of a batch file, won't pick up run time errors in 64 bit fbc compiled .exe's.
It isn't just a flight of fancy bug finder on my part, but a temporary stop to my quick runner project.
And much has been discussed of late about errors.
...
Just Tested
FreeBASIC Compiler - Version 1.10.0 (2022-04-30), built for win64 (64bit)
OK -gen gcc
OK -gen gas64
Is there a 32 bit version 1.10.0 I can test?
fxm
Moderator
Posts: 11124
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Bugs

Post by fxm »

SARG wrote: May 13, 2022 23:24
fxm wrote: May 13, 2022 21:59 It would shock me that '-e' ('QuickBASIC type error checking') would also imply 'unwindinfo' and that 'ex' wouldn't do it, knowing that '-ex' is just 'QuickBASIC type error checking' + 'Resume capacity'.
I agree with fxm it's not consistent. I would remove the option from -e or extent for -ex and -exx.
Bug report filled in:
#959 Inconsistency between '-e' compiler option vs. '-ex' and '-exx'
SARG
Posts: 1455
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Bugs

Post by SARG »

Hi dodicat,
Is there a 32 bit version 1.10.0 I can test?
https://users.freebasic-portal.de/stw/b ... -04-30.zip

@fxm
Thanks for the bug report.

For now I don't understand the different behaviour between 1.09/1.10 64bit. The only thing found is there are some instructions added by adeyblue.
Need to go deeper.
coderJeff
Site Admin
Posts: 3927
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Bugs

Post by coderJeff »

I appreciate you guys digging in to the fbc 1.10 development. Thank-you.

__FB_ERR__ was always a bit masked type field, but up until 1.07.0 it could only have 4 possible values, 0,1,3,7. Internally it is INTEGER. Externally as presented to the user, it is literal text pasted in where used. Additional bits were added in 1.07.0 and later. Please consider higher number bits reserved for future use and should (now) always bitwise AND the __FB_ERR__ value with some mask to check values.

Code: Select all

'' __FB_ERR__ is actually literal text - not a typed symbol
#cmdline "-eunwind"
print __FB_QUOTE__( __FB_JOIN__( __FB_JOIN__( *, __FB_ERR__ ), * ) )
'' should print *512* if no other commandline options

'' that is, the following are equivalent
#print typeof(__FB_ERR__)
#print typeof(512)
IMHO, the stack unwinding and error handling are a hard problem and I wanted adeyblue (for as long as is interested) to be able to work on development. My intent with '-eunwind' was to only enable the new unwind code generation if specified, which would give SARG a chance to review changes in gas64 end on the main branch. But I see now I mucked it up with '-e'. So as of now, at the very least '-eunwind' should also be enabled for '-ex' and '-exx'. And maybe in future enabled by default (i.e. remove '-eunwind' option completely and fbc will do stack unwinding if the target supports it).

The difference of crash between 1.09.0 (and older versions) and 1.10.0 currently is due to gcc compile option '-fno-unwind-tables' changed to '-funwind-tables'. I didn't dig too deep. My guess is that either 64bit or newer mingw-w64/gcc expect certain structures (like unwind tables) to be present in signal handling. But I'm not sure, I could be making that up.

If there is enough participation in reviewing and trying to use (or break) the fbc development version, I feel like we could take a few more risks in attempting new features or changes. Basically, just going for it and see what the feed back is more often.
dodicat
Posts: 7444
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Bugs

Post by dodicat »

I have updated my quick runner to show runtime errors (keeps the console open no matter what, except power cuts).
viewtopic.php?p=264633#p264633
coderJeff
Site Admin
Posts: 3927
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Bugs

Post by coderJeff »

In latest fbc/master I made changes to gas64 that should prevent an fbc crash (which SARG is welcome to change as needed), and added '-eunwind' to be implied by '-e', '-ex', '-exx'. I look forward to feedback as to how this works out. There are a number of targets/platforms that others are interested in, but I don't really use or test on.
dodicat
Posts: 7444
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Bugs

Post by dodicat »

strange result from iif

Code: Select all

dim as single s=sqr(12)
print s,sqr(12)
print csng(sqr(12))

dim as long k=1
print iif(k=1,csng(sqr(12)),sqr(12))
k=2
print iif(k=1,csng(sqr(12)),sqr(12))
sleep 
fxm
Moderator
Posts: 11124
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Bugs

Post by fxm »

Often, when finding something weird, reading the documentation first is interesting (IIF is a conditional function evaluating at runtime):
.....
When IIf treats expressions of mixed numeric types (conditional expression evaluated at run-time):
- if at least one expression is of floating-point type, the result type is the floating-point type (the bigger in case of two floating-point types),
- if the two expressions are of integer types, the result type is the bigger type of both (see Coercion and Conversion for the precise ranking of integer types)
.....
dodicat
Posts: 7444
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Bugs

Post by dodicat »

Thanks fxm.
Tested c++, same result.
conclusion:
1) I should read the help file.
2) Ten million c++ users can't be wrong.
Post Reply