Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Segmentation fault at a perfect running code

Segmentation fault at a perfect running code

Scheduled Pinned Locked Moved C / C++ / MFC
c++sysadminlinuxperformancehelp
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cem Kalyoncu
    wrote on last edited by
    #1

    I have completed a very important project. I did in VC++ and uploaded to Linux server. After then, I have re-compiled my work (without errors) and run it. It wrotes Segmentation fault, but when i checked output file it is actually the one that i have intended to have. Code uses dynamic memory allocation, file read and write, and 9 nestled for loops. Moreover I have uploaded two more projects and they were working without giving the segmentation fault. Another interesting subject about the code is that it writes values to the file at the end. If you have experienced something like this please send your comments. Deadline for the project is by tommorrow night (15th April). However comments after that time will still be useful. May the bug killer be with you... Cem Kalyoncu

    D M M 3 Replies Last reply
    0
    • C Cem Kalyoncu

      I have completed a very important project. I did in VC++ and uploaded to Linux server. After then, I have re-compiled my work (without errors) and run it. It wrotes Segmentation fault, but when i checked output file it is actually the one that i have intended to have. Code uses dynamic memory allocation, file read and write, and 9 nestled for loops. Moreover I have uploaded two more projects and they were working without giving the segmentation fault. Another interesting subject about the code is that it writes values to the file at the end. If you have experienced something like this please send your comments. Deadline for the project is by tommorrow night (15th April). However comments after that time will still be useful. May the bug killer be with you... Cem Kalyoncu

      D Offline
      D Offline
      Daniel Turini
      wrote on last edited by
      #2

      Sorry, but 99.999999% of the time, the problem is with your code, not with the compiler. And without seeing the code, we can't have a clue about why it's failing... I see dumb people

      1 Reply Last reply
      0
      • C Cem Kalyoncu

        I have completed a very important project. I did in VC++ and uploaded to Linux server. After then, I have re-compiled my work (without errors) and run it. It wrotes Segmentation fault, but when i checked output file it is actually the one that i have intended to have. Code uses dynamic memory allocation, file read and write, and 9 nestled for loops. Moreover I have uploaded two more projects and they were working without giving the segmentation fault. Another interesting subject about the code is that it writes values to the file at the end. If you have experienced something like this please send your comments. Deadline for the project is by tommorrow night (15th April). However comments after that time will still be useful. May the bug killer be with you... Cem Kalyoncu

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #3

        ... are you trying to run a Win32 executable on a linux OS ? ...


        Maximilien Lincourt Your Head A Splode - Strong Bad

        C 1 Reply Last reply
        0
        • M Maximilien

          ... are you trying to run a Win32 executable on a linux OS ? ...


          Maximilien Lincourt Your Head A Splode - Strong Bad

          C Offline
          C Offline
          Cem Kalyoncu
          wrote on last edited by
          #4

          no.. I have recompiled it using g++. May the bug killer be with you... Cem Kalyoncu

          M 1 Reply Last reply
          0
          • C Cem Kalyoncu

            no.. I have recompiled it using g++. May the bug killer be with you... Cem Kalyoncu

            M Offline
            M Offline
            Maximilien
            wrote on last edited by
            #5

            ok ... so ... probable errors, bad initializations of variable, bad allocation, bad error checking ... be sure to initialize everything, check all pointers, ... and build in debug and trace on linux ...


            Maximilien Lincourt Your Head A Splode - Strong Bad

            1 Reply Last reply
            0
            • C Cem Kalyoncu

              I have completed a very important project. I did in VC++ and uploaded to Linux server. After then, I have re-compiled my work (without errors) and run it. It wrotes Segmentation fault, but when i checked output file it is actually the one that i have intended to have. Code uses dynamic memory allocation, file read and write, and 9 nestled for loops. Moreover I have uploaded two more projects and they were working without giving the segmentation fault. Another interesting subject about the code is that it writes values to the file at the end. If you have experienced something like this please send your comments. Deadline for the project is by tommorrow night (15th April). However comments after that time will still be useful. May the bug killer be with you... Cem Kalyoncu

              M Offline
              M Offline
              Mike Dimmick
              wrote on last edited by
              #6

              Unix 'segmentation fault' is much the same as Windows' 'access violation'. It's caused by trying to read or write through a bad pointer, or by trying to jump to a bad location. Usually this means that you're trying to read or write off the end of a buffer, or you're not checking the return value of one or more functions for errors before using that value (where the function returns a pointer, e.g. fopen). It can also be an uninitialised pointer. Jumping to a bad location is much harder and usually requires an uninitialised function pointer. Stability. What an interesting concept. -- Chris Maunder

              C 1 Reply Last reply
              0
              • M Mike Dimmick

                Unix 'segmentation fault' is much the same as Windows' 'access violation'. It's caused by trying to read or write through a bad pointer, or by trying to jump to a bad location. Usually this means that you're trying to read or write off the end of a buffer, or you're not checking the return value of one or more functions for errors before using that value (where the function returns a pointer, e.g. fopen). It can also be an uninitialised pointer. Jumping to a bad location is much harder and usually requires an uninitialised function pointer. Stability. What an interesting concept. -- Chris Maunder

                C Offline
                C Offline
                Cem Kalyoncu
                wrote on last edited by
                #7

                Thanks for all, The answer is actually trying to access out of bounds of a variable - it should give access violation but in Windows it allocates a litle more space then you have requested (duplicates of four i guess). the proplem is with the read routine that seems nearly perfect, I found the error when I tried to free the variable. It actually gave me error at that time (before I forgot to free them:) ). It is very interesting not to get an error on Windows. As Mike said it is actually Access Violation. Thanks for all May the bug killer be with you... Cem Kalyoncu

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups