QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: deniscassiano on February 23, 2018, 07:42:27 am

Title: Port old program qbasic 1.1 to QB64 throws segmentation fault
Post by: deniscassiano on February 23, 2018, 07:42:27 am
Hi Guys,

I need convert a old qb 1.1 program to QB64. I change a bit from code to can compile and run, but when i attempt run the program in QB64 editor or in command line i get random segmentation fault: 11 error. The program is simple: read some random files, perform some calcs to volumetric measures and write to random and text files.
I attempt run int in MACOS High Sierra and Ubuntu Mate 17.10.1 and both get this issue. How i can debug this? No errors in Editor output or c++ dump. only segmentation fault: 11
Title: Re: Port old program qbasic 1.1 to QB64 throws segmentation fault
Post by: FellippeHeitor on February 23, 2018, 07:48:24 am
You can paste your code here (or attach it if it's too long) so we can have a look and try to help you.

Welcome to the forum.
Title: Re: Port old program qbasic 1.1 to QB64 throws segmentation fault
Post by: Pete on February 23, 2018, 12:09:51 pm
Yes, please post the code. Happy to run it and see what's up, although I run Windows.

Question on posting code. I tried to put a prog in a code box, not that big either, and I had to end up attaching  it. Can that limit be upped? Frankly it is easier to paste code and read code in a code box, rather than upload/download it.

Pete :)
Title: Re: Port old program qbasic 1.1 to QB64 throws segmentation fault
Post by: odin on February 23, 2018, 12:30:51 pm
Question on posting code. I tried to put a prog in a code box, not that big either, and I had to end up attaching  it. Can that limit be upped? Frankly it is easier to paste code and read code in a code box, rather than upload/download it.

Pete :)

Noted.
Title: Re: Port old program qbasic 1.1 to QB64 throws segmentation fault
Post by: deniscassiano on March 01, 2018, 09:59:07 am
Hi Guys,

I can't send all code because my client want confidentiality, but a bit of code that throws segmentation fault is:

OPEN "S32342323.DAT" FOR RANDOM AS #21 LEN = 58
FIELD #21, 4 AS I1$, 4 AS I2$, 21 AS I3$, 21 AS I4$, 1 AS I5$, 3 AS I6$, 4 AS I7$
FIELD #21, 2 AS J1$, 4 AS J2$, 2 AS J3$, 4 AS J4$, 4 AS J5$, 2 AS J6$, 2 AS J7$, 2 AS J8$, 2 AS J9$, 4 AS J10$, 4 AS J11$, 4 AS J12$, 4 AS J13$, 4 AS J14$, 4 AS J15$, 2 AS J16$, 4 AS J17$, 4 AS J18$

1210 KK = 0: I = 0: QTOT = 0
1220 FOR I = 1 TO NT
    PRINT "ACESSANDO LINHA-> " + STR$(I):
    1230 GET #21, I + 1: SINIC = J2$: IFIM = CVI(J3$): VAZAO1 = CVS(J4$): C1 = CVS(J5$)
    'NUM30 = CVI(J6$)
    'NUM45 = CVI(J7$): NUM60 = CVI(J8$): NUM90 = CVI(J9$)
    PRINT "DADOS: ["; SINIC; " - "; IFIM; " - "; VAZAO1; " - "; C1; " - "; NUM30; " - "; NUM45; " - "; NUM60; " - "; NUM90; "]";
    PRINT "DADOS"
    1240 IF C1 = 0 THEN 1400
    1250 COIFA = CVS(J10$): COTU30 = CVS(J11$): COTU45 = CVS(J12$): COTU60 = CVS(J13$): COTU90 = CVS(J14$): ENTRA = CVS(J15$): KSOMA = CVI(J16$): TEMP = CVS(J17$)
    PRINT "DADOS: ["; COIFA; " - "; CUTU30; " - "; COTU45; " - "; COTU60; " - "; COTU90; " - "; ENTRA; " - "; KSOMA; " - "; TEMP; "]";
    1260 IF COIFA <> 0 THEN ACEL = 1 ELSE ACEL = 0

NEXT I


This issue is random. The code runs fine in first run, but in next attempts i get segmentation fault: 11 our bus error: 10
Title: Re: Port old program qbasic 1.1 to QB64 throws segmentation fault
Post by: Petr on March 01, 2018, 10:07:36 am
Please add here a complete code. This is uncomplete. What is SINIC? Is declared as number in this program, next - line 1400 miss, as i look at, so if this FOR NEXT I loop is run, then file is read in one direction. If is read  next time, reading start on last position - not in file begin. In this program is none CLOSE or SEEK.
Title: Re: Port old program qbasic 1.1 to QB64 throws segmentation fault
Post by: FellippeHeitor on March 01, 2018, 10:17:44 am
Denis, how did you pinpoint this bit as the faulty bit?