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
  1. Home
  2. The Lounge
  3. A Few Billion Lines of Code

A Few Billion Lines of Code

Scheduled Pinned Locked Moved The Lounge
questionlinqcomdata-structuressales
12 Posts 9 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.
  • H Hans Dietrich

    The folks at Coverity (www.coverity.com wrote up their commercial static analysis tool in the CACM (A Few Billion Lines of Code Later: Using Static Analysis to Find Bugs in the Real World). Very interesting and enjoyable read. They describe in detail the pitfalls in building such a tool, and give examples of some sales situations they encountered. These include:

    User: "How do I run your tool?"

    Coverity: "Oh, it's easy. Just type 'cov-build' before your build command."

    User: "Build command? I just push this [GUI] button..."

    Upon seeing an error report saying the following loop body was dead code

    for(i = 1; i < 0; i++)
        ...dead code...
    

    Programmer: "No, that's a false positive; a loop executes at least once."

    For this memory corruption error (32-bit machine)

    int a\[2\], b;
    memset(a, 0, 12);
    

    Programmer: "No, I meant to do that; they are next to each other."

    For this use-after-free

    free(foo);
    foo->bar = ...;
    

    Programmer: "No, that's OK; there is no malloc call between the free and use."

    And my personal favorite:

    A buffer overflow checker flagged a bunch of errors of the form

    unsigned p\[4\];
    p\[4\] = 1;
    

    Programmer: "No, ANSI lets you write 1 past the end of the array."

    See more discussion at Lambda the Ultimate.

    Best wishes, Hans


    [Hans Dietrich Software]

    K Offline
    K Offline
    Kasson
    wrote on last edited by
    #2

    Good. My 5 for you.

    With Regards, Kasson. Birth is a mistake you'll spend your whole life trying to correct.

    1 Reply Last reply
    0
    • H Hans Dietrich

      The folks at Coverity (www.coverity.com wrote up their commercial static analysis tool in the CACM (A Few Billion Lines of Code Later: Using Static Analysis to Find Bugs in the Real World). Very interesting and enjoyable read. They describe in detail the pitfalls in building such a tool, and give examples of some sales situations they encountered. These include:

      User: "How do I run your tool?"

      Coverity: "Oh, it's easy. Just type 'cov-build' before your build command."

      User: "Build command? I just push this [GUI] button..."

      Upon seeing an error report saying the following loop body was dead code

      for(i = 1; i < 0; i++)
          ...dead code...
      

      Programmer: "No, that's a false positive; a loop executes at least once."

      For this memory corruption error (32-bit machine)

      int a\[2\], b;
      memset(a, 0, 12);
      

      Programmer: "No, I meant to do that; they are next to each other."

      For this use-after-free

      free(foo);
      foo->bar = ...;
      

      Programmer: "No, that's OK; there is no malloc call between the free and use."

      And my personal favorite:

      A buffer overflow checker flagged a bunch of errors of the form

      unsigned p\[4\];
      p\[4\] = 1;
      

      Programmer: "No, ANSI lets you write 1 past the end of the array."

      See more discussion at Lambda the Ultimate.

      Best wishes, Hans


      [Hans Dietrich Software]

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #3

      We use coverty, interestingly they licence it on a number of lines of code basis which makes it rather expensive for large code bases

      P 1 Reply Last reply
      0
      • H Hans Dietrich

        The folks at Coverity (www.coverity.com wrote up their commercial static analysis tool in the CACM (A Few Billion Lines of Code Later: Using Static Analysis to Find Bugs in the Real World). Very interesting and enjoyable read. They describe in detail the pitfalls in building such a tool, and give examples of some sales situations they encountered. These include:

        User: "How do I run your tool?"

        Coverity: "Oh, it's easy. Just type 'cov-build' before your build command."

        User: "Build command? I just push this [GUI] button..."

        Upon seeing an error report saying the following loop body was dead code

        for(i = 1; i < 0; i++)
            ...dead code...
        

        Programmer: "No, that's a false positive; a loop executes at least once."

        For this memory corruption error (32-bit machine)

        int a\[2\], b;
        memset(a, 0, 12);
        

        Programmer: "No, I meant to do that; they are next to each other."

        For this use-after-free

        free(foo);
        foo->bar = ...;
        

        Programmer: "No, that's OK; there is no malloc call between the free and use."

        And my personal favorite:

        A buffer overflow checker flagged a bunch of errors of the form

        unsigned p\[4\];
        p\[4\] = 1;
        

        Programmer: "No, ANSI lets you write 1 past the end of the array."

        See more discussion at Lambda the Ultimate.

        Best wishes, Hans


        [Hans Dietrich Software]

        P Offline
        P Offline
        peterchen
        wrote on last edited by
        #4

        Amazing read - not just for the WTF list you reproduced. For a giant-project-maintainer it's a already a pleasure to not read about rubyrailing MVVPXML-controlinversed tenliners. Reading about projects larger than "mine" is certainly not to be missed.

        FILETIME to time_t
        | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

        1 Reply Last reply
        0
        • H Hans Dietrich

          The folks at Coverity (www.coverity.com wrote up their commercial static analysis tool in the CACM (A Few Billion Lines of Code Later: Using Static Analysis to Find Bugs in the Real World). Very interesting and enjoyable read. They describe in detail the pitfalls in building such a tool, and give examples of some sales situations they encountered. These include:

          User: "How do I run your tool?"

          Coverity: "Oh, it's easy. Just type 'cov-build' before your build command."

          User: "Build command? I just push this [GUI] button..."

          Upon seeing an error report saying the following loop body was dead code

          for(i = 1; i < 0; i++)
              ...dead code...
          

          Programmer: "No, that's a false positive; a loop executes at least once."

          For this memory corruption error (32-bit machine)

          int a\[2\], b;
          memset(a, 0, 12);
          

          Programmer: "No, I meant to do that; they are next to each other."

          For this use-after-free

          free(foo);
          foo->bar = ...;
          

          Programmer: "No, that's OK; there is no malloc call between the free and use."

          And my personal favorite:

          A buffer overflow checker flagged a bunch of errors of the form

          unsigned p\[4\];
          p\[4\] = 1;
          

          Programmer: "No, ANSI lets you write 1 past the end of the array."

          See more discussion at Lambda the Ultimate.

          Best wishes, Hans


          [Hans Dietrich Software]

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #5

          I wonder what it does with something like:

          short* c = argv [ 1 ] + 1 ;

          switch ( *c )
          {
          case 'an' : printf ( "January" ) ; break ;
          case 'eb' : printf ( "February" ) ; break ;
          case 'ar' : printf ( "March" ) ; break ;
          case 'pr' : printf ( "April" ) ; break ;
          case 'ay' : printf ( "May" ) ; break ;
          case 'un' : printf ( "June" ) ; break ;
          case 'ul' : printf ( "July" ) ; break ;
          case 'ug' : printf ( "August" ) ; break ;
          case 'ep' : printf ( "September" ) ; break ;
          case 'ct' : printf ( "October" ) ; break ;
          case 'ov' : printf ( "November" ) ; break ;
          case 'ec' : printf ( "December" ) ; break ;
          }

          You can stuff two characters in a char literal. :-D On my first job out of college I did that for parsing some reports. (VMS-style dates 19-Jan-2011 X| .)

          1 Reply Last reply
          0
          • L Lost User

            We use coverty, interestingly they licence it on a number of lines of code basis which makes it rather expensive for large code bases

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #6

            If it's C-like language, remove all the carriage-returns before passing your code in.

            1 Reply Last reply
            0
            • H Hans Dietrich

              The folks at Coverity (www.coverity.com wrote up their commercial static analysis tool in the CACM (A Few Billion Lines of Code Later: Using Static Analysis to Find Bugs in the Real World). Very interesting and enjoyable read. They describe in detail the pitfalls in building such a tool, and give examples of some sales situations they encountered. These include:

              User: "How do I run your tool?"

              Coverity: "Oh, it's easy. Just type 'cov-build' before your build command."

              User: "Build command? I just push this [GUI] button..."

              Upon seeing an error report saying the following loop body was dead code

              for(i = 1; i < 0; i++)
                  ...dead code...
              

              Programmer: "No, that's a false positive; a loop executes at least once."

              For this memory corruption error (32-bit machine)

              int a\[2\], b;
              memset(a, 0, 12);
              

              Programmer: "No, I meant to do that; they are next to each other."

              For this use-after-free

              free(foo);
              foo->bar = ...;
              

              Programmer: "No, that's OK; there is no malloc call between the free and use."

              And my personal favorite:

              A buffer overflow checker flagged a bunch of errors of the form

              unsigned p\[4\];
              p\[4\] = 1;
              

              Programmer: "No, ANSI lets you write 1 past the end of the array."

              See more discussion at Lambda the Ultimate.

              Best wishes, Hans


              [Hans Dietrich Software]

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #7

              I've palmed off delegated setting up a Coverity job on our software to my intern, I'll pass this on. :evil-cackle:

              Join the cool kids - Come fold with us[^]

              1 Reply Last reply
              0
              • H Hans Dietrich

                The folks at Coverity (www.coverity.com wrote up their commercial static analysis tool in the CACM (A Few Billion Lines of Code Later: Using Static Analysis to Find Bugs in the Real World). Very interesting and enjoyable read. They describe in detail the pitfalls in building such a tool, and give examples of some sales situations they encountered. These include:

                User: "How do I run your tool?"

                Coverity: "Oh, it's easy. Just type 'cov-build' before your build command."

                User: "Build command? I just push this [GUI] button..."

                Upon seeing an error report saying the following loop body was dead code

                for(i = 1; i < 0; i++)
                    ...dead code...
                

                Programmer: "No, that's a false positive; a loop executes at least once."

                For this memory corruption error (32-bit machine)

                int a\[2\], b;
                memset(a, 0, 12);
                

                Programmer: "No, I meant to do that; they are next to each other."

                For this use-after-free

                free(foo);
                foo->bar = ...;
                

                Programmer: "No, that's OK; there is no malloc call between the free and use."

                And my personal favorite:

                A buffer overflow checker flagged a bunch of errors of the form

                unsigned p\[4\];
                p\[4\] = 1;
                

                Programmer: "No, ANSI lets you write 1 past the end of the array."

                See more discussion at Lambda the Ultimate.

                Best wishes, Hans


                [Hans Dietrich Software]

                Mike HankeyM Offline
                Mike HankeyM Offline
                Mike Hankey
                wrote on last edited by
                #8

                Little pearls of wisdom eh? Billion lines of code I would imagine there is a bunch more. Good one thanks for sharing.

                I like long walks, especially when they are taken by people who annoy me. http://www.hq4thmarinescomm.com[^]
                My Site

                1 Reply Last reply
                0
                • H Hans Dietrich

                  The folks at Coverity (www.coverity.com wrote up their commercial static analysis tool in the CACM (A Few Billion Lines of Code Later: Using Static Analysis to Find Bugs in the Real World). Very interesting and enjoyable read. They describe in detail the pitfalls in building such a tool, and give examples of some sales situations they encountered. These include:

                  User: "How do I run your tool?"

                  Coverity: "Oh, it's easy. Just type 'cov-build' before your build command."

                  User: "Build command? I just push this [GUI] button..."

                  Upon seeing an error report saying the following loop body was dead code

                  for(i = 1; i < 0; i++)
                      ...dead code...
                  

                  Programmer: "No, that's a false positive; a loop executes at least once."

                  For this memory corruption error (32-bit machine)

                  int a\[2\], b;
                  memset(a, 0, 12);
                  

                  Programmer: "No, I meant to do that; they are next to each other."

                  For this use-after-free

                  free(foo);
                  foo->bar = ...;
                  

                  Programmer: "No, that's OK; there is no malloc call between the free and use."

                  And my personal favorite:

                  A buffer overflow checker flagged a bunch of errors of the form

                  unsigned p\[4\];
                  p\[4\] = 1;
                  

                  Programmer: "No, ANSI lets you write 1 past the end of the array."

                  See more discussion at Lambda the Ultimate.

                  Best wishes, Hans


                  [Hans Dietrich Software]

                  E Offline
                  E Offline
                  ettl martin
                  wrote on last edited by
                  #9

                  We are using cppcheck(http://sourceforge.net/projects/cppcheck/), its open-source and IMHO even better and more accurate than coverity!

                  1 Reply Last reply
                  0
                  • H Hans Dietrich

                    The folks at Coverity (www.coverity.com wrote up their commercial static analysis tool in the CACM (A Few Billion Lines of Code Later: Using Static Analysis to Find Bugs in the Real World). Very interesting and enjoyable read. They describe in detail the pitfalls in building such a tool, and give examples of some sales situations they encountered. These include:

                    User: "How do I run your tool?"

                    Coverity: "Oh, it's easy. Just type 'cov-build' before your build command."

                    User: "Build command? I just push this [GUI] button..."

                    Upon seeing an error report saying the following loop body was dead code

                    for(i = 1; i < 0; i++)
                        ...dead code...
                    

                    Programmer: "No, that's a false positive; a loop executes at least once."

                    For this memory corruption error (32-bit machine)

                    int a\[2\], b;
                    memset(a, 0, 12);
                    

                    Programmer: "No, I meant to do that; they are next to each other."

                    For this use-after-free

                    free(foo);
                    foo->bar = ...;
                    

                    Programmer: "No, that's OK; there is no malloc call between the free and use."

                    And my personal favorite:

                    A buffer overflow checker flagged a bunch of errors of the form

                    unsigned p\[4\];
                    p\[4\] = 1;
                    

                    Programmer: "No, ANSI lets you write 1 past the end of the array."

                    See more discussion at Lambda the Ultimate.

                    Best wishes, Hans


                    [Hans Dietrich Software]

                    K Offline
                    K Offline
                    KP Lee
                    wrote on last edited by
                    #10

                    Hans Dietrich wrote:

                    "No, that's a false positive; a loop executes at least once."

                    I like that one. In some languages, they have "DO UNTIL..." where that is absolutely true and in one sense it's true here as well, as long as this code is reached, it'll execute once. It will execute i = 1 and it will evaluate i < 0. Of course, the developer here probably mixed up his languages and really thought the body of the loop was executed once. I have to admit I wasn't sure if this loop was a do until or do while loop until I tested it to find out. Maybe I read that, but taking the effort to do a test is more memorable for me than reading it in a book.

                    1 Reply Last reply
                    0
                    • H Hans Dietrich

                      The folks at Coverity (www.coverity.com wrote up their commercial static analysis tool in the CACM (A Few Billion Lines of Code Later: Using Static Analysis to Find Bugs in the Real World). Very interesting and enjoyable read. They describe in detail the pitfalls in building such a tool, and give examples of some sales situations they encountered. These include:

                      User: "How do I run your tool?"

                      Coverity: "Oh, it's easy. Just type 'cov-build' before your build command."

                      User: "Build command? I just push this [GUI] button..."

                      Upon seeing an error report saying the following loop body was dead code

                      for(i = 1; i < 0; i++)
                          ...dead code...
                      

                      Programmer: "No, that's a false positive; a loop executes at least once."

                      For this memory corruption error (32-bit machine)

                      int a\[2\], b;
                      memset(a, 0, 12);
                      

                      Programmer: "No, I meant to do that; they are next to each other."

                      For this use-after-free

                      free(foo);
                      foo->bar = ...;
                      

                      Programmer: "No, that's OK; there is no malloc call between the free and use."

                      And my personal favorite:

                      A buffer overflow checker flagged a bunch of errors of the form

                      unsigned p\[4\];
                      p\[4\] = 1;
                      

                      Programmer: "No, ANSI lets you write 1 past the end of the array."

                      See more discussion at Lambda the Ultimate.

                      Best wishes, Hans


                      [Hans Dietrich Software]

                      G Offline
                      G Offline
                      Gary R Wheeler
                      wrote on last edited by
                      #11

                      The Coverity folks are outrageously expensive. Some yahoo 3-4 steps up in the food chain wanted to have them analyze our source code, which covers five products ranging from 800K to 1.7M lines. Rumor has it their quote was for over $100,000.

                      Software Zen: delete this;
                      Fold With Us![^]

                      H 1 Reply Last reply
                      0
                      • G Gary R Wheeler

                        The Coverity folks are outrageously expensive. Some yahoo 3-4 steps up in the food chain wanted to have them analyze our source code, which covers five products ranging from 800K to 1.7M lines. Rumor has it their quote was for over $100,000.

                        Software Zen: delete this;
                        Fold With Us![^]

                        H Offline
                        H Offline
                        Hans Dietrich
                        wrote on last edited by
                        #12

                        That doesn't surprise. Any web site that doesn't list prices is going to be astronomical; that's a given. Have you looked at any other static analysis tools?

                        Best wishes, Hans


                        [Hans Dietrich Software]

                        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