Menu

Native Linux Build Issue - Resolved

Anobium
2016-07-14
2016-07-24
  • Anobium

    Anobium - 2016-07-14

    Paolo Iocco reported and resolved an issue when compling using a native build of the compiler (not WINE) for Linux.

    The compiler crashed with an error. Error in `/usr/share/GcBasic/gcbasic': double free or corruption (fasttop): 0x00000000050ec690

    The error was caused by a missing #endif in a source .h file.

    This is now resolved by Paolo. Please use the following files to resolve https://sourceforge.net/p/gcbasic/code/HEAD/tree/GCBASIC/trunk/include/glcd_ILI9340.h and
    https://sourceforge.net/p/gcbasic/code/HEAD/tree/GCBASIC/trunk/include/glcd_ILI9341.h Update your installation with these files.

    Any distribution after v.0.95.007 after July 14th 2016 will have these files included.

     

    Last edit: Anobium 2016-07-19
    • Jim Gregory

      Jim Gregory - 2016-07-19

      FWIW, the second link in your note to glcd_ILI9341.h returns a 404 error, due to the inclusion of the period in the sentence as part of the URL :).

      The current archived version on the download site still contains the old files. But even after updating them, I'm still getting a similar error:

      Error in `/usr/bin/../bin/gcc': double free or corruption (top): 0x0081d060

      I am compiling it on a Raspberry Pi 3 running the Raspbian version of Debian.

      Also, the install.sh script will silently fail during the build process unless line 49 in install.sh is changed from:

      Version=$(expr "$(grep '3h=Show GCBasic Compiler' $VersionFile)" : '.* v\(.*\) b')
      

      to:

      Version=$(expr "$(grep '3h=Show GCBASIC Compiler' $VersionFile)" : '.* v\(.*\) b')
      

      to match the corresponding line in SynToolbars.ini.

      -Jim

       

      Last edit: Jim Gregory 2016-07-19
  • Anobium

    Anobium - 2016-07-19

    Thank for the posting.

    A few questions. When you response please note I do not have a specific Linux build that you are using.

    1. Installation/Script Error:
      a. Does the installation complete?
      b. Do you think the script error is specific to your Linux build?
      c. Reference the script error. If this is specific to your Linux build. How do we adapt the script to cater for this specific Linux build error?
      d. The changes you recommend. I cannot see the difference between the two commands in your posting.

    2. Error message:
      a. When is the error message issue? During which operation? Open a file, editing file, compiling? Do you have a specific program that is issuing this error message (please post if this this the case)?
      b. If the message is during compiling. Can you please isolate the issue? This means finding the root cause of the issue by removing as much of the user program as possible.
      Last week Paola locate the silly program error in one of the GLCD*.h files. We do need your help to find the root cause of the issue.

    3. Error URL
      a. I can fix that.

    4. Anobium

     
    • Jim Gregory

      Jim Gregory - 2016-07-19

      Sorry I did not describe the problem more thoroughly. In answer to your questions:

      1a. No, the installation does not complete. If I run "./install.sh build" with the default version of the script, nothing happens and it returns immediately to the command prompt:

          pi@rpi3:~/GreatCowBasic/Sources:$ ./install.sh build
          pi@rpi3:~/GreatCowBasic/Sources:$
      
      If I make the change I indicated to line 49, then it will start to build but fail during the compilation step:
      
          pi@rpi3:~/GreatCowBasic/Sources:$ sed -i '49 s/GCBasic/GCBASIC/' install.sh 
          pi@rpi3:~/GreatCowBasic/Sources:$ ./install.sh build
          -e 
          Compiling GCBASIC Version 0.95.007, Release 2016-06-26
      
          FreeBASIC Compiler - Version 1.06.0 (06-03-2016), built for linux-arm (32bit)
          Copyright (C) 2004-2016 The FreeBASIC development team.
          target:       linux-arm, armv7-a, 32bit
          compiling:    gcbasic.bas -o gcbasic.c (main module)
          compiling C:  /usr/bin/../bin/gcc -march=native -S -nostdlib -nostdinc -Wall -Wno-unused-label -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-main -Werror-implicit-function-declaration -O0 -fno-strict-aliasing -frounding-math -fno-math-errno -fwrapv -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables "gcbasic.c" -o "gcbasic.asm"
          *** Error in `/usr/bin/../bin/gcc': double free or corruption (top): 0x01a61060 ***
          gcbasic.bas() error 90: Executable not found: "/usr/bin/../bin/gcc"
          pi@rpi3:~/GreatCowBasic/Sources:$
      

      1b. I doubt it's specific to my build
      1c. The problem in line 49 is it's attempting to retrieve the GCBasic version and release date from the SynToolbars.ini file using a case-sensistive grep search, but not finding a match. Lines 48-49 from install.sh:

           # Get version number, release date from SynToolbars.ini, gcbasic.bas
           Version=$(expr "$(grep '3h=Show GCBasic Compiler' $VersionFile)" : '.* v\(.*\) b')
      
      It is not finding a match because my SyntToolbars.ini file contains:
      
           3h=Show GCBASIC Compiler v0.95.007 build date
      
      Note the difference: 'GCBasic' != 'GCBASIC'.
      
      You can fix this by either changing the text grep is searching for (note change from 'Basic' to 'BASIC':
      
           Version=$(expr "$(grep '3h=Show GCBASIC Compiler' $VersionFile)" : '.* v\(.*\) b')
      
      or by changing the command to a case-insenstive search (note the added '-i' flag in the grep command):
      
           Version=$(expr "$(grep -i '3h=Show GCBasic Compiler' $VersionFile)" : '.* v\(.*\) b')
      
      Either solution should work.
      

      2a. The error occurs during the compilation of the GCB compiler in the build step, which halts the installation.

      2b. It may be another missing #ENDIF somewhere :(. I'll try to grep the include files to see if there's an unequal number of #if and #endif in any other of them.

      • Jim
       
      • Anobium

        Anobium - 2016-07-19

        Thanks. I have asked for help to resolve these issues.

        I am not expert to resolve this.

        Anobium

         
      • T. Lee Davidson

        T. Lee Davidson - 2016-07-19

        Hello Jim,

        Yes, the install.sh script does indeed need to be corrected for case-sensitivity. After correcting line 49, I get a successful build on OpenSUSE Leap 42.1 (x86-64):

        ./install.sh build
        
        Compiling GCBASIC Version 0.95.007, Release 2016-06-26
        
        FreeBASIC Compiler - Version 1.05.0 (01-31-2016), built for linux-x86_64 (64bit)
        Copyright (C) 2004-2016 The FreeBASIC development team.
        target:       linux-x86_64, x86-64, 64bit
        compiling:    gcbasic.bas -o gcbasic.c (main module)
        compiling C:  gcc -m64 -march=native -S -nostdlib -nostdinc -Wall -Wno-unused-label -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-main -Werror-implicit-function-declaration -O0 -fno-strict-aliasing -frounding-math -fno-math-errno -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -masm=intel "gcbasic.c" -o "gcbasic.asm"
        assembling:   as --64 --strip-local-absolute "gcbasic.asm" -o "gcbasic.o"
        linking:      ld -m elf_x86_64 -o "gcbasic" -dynamic-linker /lib64/ld-linux-x86-64.so.2 "/usr/local/bin/../lib/freebasic/linux-x86_64/fbextra.x" -s -L "/usr/local/bin/../lib/freebasic/linux-x86_64" -L "." -L "/usr/lib64/gcc/x86_64-suse-linux/4.8" "/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crt1.o" "/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crti.o" "/usr/lib64/gcc/x86_64-suse-linux/4.8/crtbegin.o" "/usr/local/bin/../lib/freebasic/linux-x86_64/fbrt0.o" "gcbasic.o" "-(" -lfb -ltinfo -lm -ldl -lpthread -lgcc -lgcc_eh -lc "-)" "/usr/lib64/gcc/x86_64-suse-linux/4.8/crtend.o" "/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crtn.o" 
        
        Compiled successfully.
        
        Version: 0.95.007
        Release: 2016-06-26
        

        It's probably not the issue, but the FreeBASIC readme.txt lists required packages for Debian:
        "gcc libncurses5-dev libffi-dev libgl1-mesa-dev libx11-dev libxext-dev libxrender-dev libxrandr-dev libxpm-dev".

        I'm wondering if Paolo Iocco was also using a flavor of Debian.

         
        • Anobium

          Anobium - 2016-07-19

          I will make the changes to the distribution and release asap

           
        • Jim Gregory

          Jim Gregory - 2016-07-19

          Thanks for sharing your build.

          I checked and already have those required packages installed.

          The only differences I can see between your build and mine are:

          1. You're using a different architecture (x8_64 vs ARM A7)
          2. You're compiling for 64 bit while I'm compiling for 32-bit,
          3. You're using a slightly older version of FreeBASIC (1.05 vs 1.06), and
          4. You're using OpenSUSE while I'm using Debian.

          FWIW, I sucessfully installed the previous version of GC Basic about a month or so ago on a Raspberry Pi 2, so I'm not sure if it's a problem with the new versions of FreeBASIC, GCBasic, or something else.

           
          • T. Lee Davidson

            T. Lee Davidson - 2016-07-19

            I see one more difference.

            In my build's "compiling C:" line, fbc is using a relative path to gcc which is in /usr/bin, and /usr/bin is in my PATH. In your build's "compiling C:" line, fbc is using an absolute path to gcc, "/usr/bin/../bin/gcc". And, interestingly, after the error, "/usr/bin/../bin/gcc" is no longer found.

             
            • Jim Gregory

              Jim Gregory - 2016-07-20

              I noticed that, too. Do you know how the fbc compiler determines what path to use for gcc? Both fbc and gcc are installed in /usr/bin on my system, and /usr/bin is in my environment's path variable.

               
              • T. Lee Davidson

                T. Lee Davidson - 2016-07-20

                No, I do not know how fbc determines the path for gcc. The difference may be because I downloaded the pre-compiled binaries for Linux (v1.05 being the latest available), and I suspect that you probably compiled fbc from source.

                 
        • Jim Gregory

          Jim Gregory - 2016-07-20

          OK, I can successfully compile the latest version of GCB (with the fixes mentioned above) on my Raspberry Pi 2 using FreeBasic V. 1.06.0 (04-30-2016), but I cannot compile it on my Raspberry Pi 3 using FreeBasic V 1.06.0 (06-03-2016).

          So the problem is not with GCB. :)

          On the RPi2, fbc calls gcc using 'gcc'. On the RPi3, it calls gcc using '/usr/bin/../bin/gcc'. That could be the problem. I'll see on the fbc forum how to change this.

          Would there be an leftover object files I need to remove before recompiling? Usually when compiling you can run 'make clean', but since there's no Makefile nor a 'clean' function inside install.sh, I don't know what (if any) files I should remove.

          • Jim
           
          • T. Lee Davidson

            T. Lee Davidson - 2016-07-20

            The fbc compiler cleans up its own intermediate files. There are no leftover object files; nothing that needs to be cleaned. Just re-build. The gcbasic executable, if it exists, will get overwritten.

            It's good to know that you may have isolated the issue.

             
      • Jim Gregory

        Jim Gregory - 2016-07-24

        OK, I finally was able to fix this problem and get it to compile correctly on a Raspberry Pi 3.

        The key is removing the '-arch native' flag when calling fbc in the build function of install.sh; i.e., changing this:

        CC="fbc -exx -v -arch native -R gcbasic.bas" # Compile Command
        

        to this:

        CC="fbc -exx -v -R gcbasic.bas" # Compile Command
        

        Then everything compiled normally.

        The interesting thing is, the original code (with '-arch native') will work on a Raspberry Pi 2 and an Orange Pi 2 Plus, but not a Raspberry Pi 3. All have an ARM7 architecure.

         

        Last edit: Jim Gregory 2016-07-24
    • Jim Gregory

      Jim Gregory - 2016-07-19

      I think the problem might be in timer.h in /GreatCowBasic/include/lowlevel. There are 200 #if's, but only 199 #endif's. :( I'll try to find the missing one.

       
      • Jim Gregory

        Jim Gregory - 2016-07-19

        No, that wasn't it. There was a '#if' in a comment in the header of the file. :(

        That was the only file with an unbalanced set of #ifs/#endif under the include directory, so that's not the problem.

         

        Last edit: Jim Gregory 2016-07-19
        • Anobium

          Anobium - 2016-07-19

          I am puzzled. Which error this ? Is the when compiling the Great Cow BASIC compiler? or, a Great Cow BASIC user program?

           
          • Jim Gregory

            Jim Gregory - 2016-07-19

            I get the error compiling the GC Basic compiler. Sorry if I didn't make that clear.

             

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.