Investigating Preprocessor-Based Syntax Errors

Flávio Medeiros, Márcio Ribeiro, and Rohit Gheyi

Overview

In this paper, we define a technique based on TypeChef to find syntax errors in releases and commits of program families. We use it to investigate syntax errors in 41 program families releases, and more than 51 thousand commits of 8 program families. We find 7 and 20 syntax errors in releases and commits of program families, respectively. They are related to complete and incomplete directives.

Table I: Releases Results

   PROJECT       VERSION       DESCRIPTION       LOC       FILES       SYNTAX ERRORS       SOURCE   
apache 2.4.3 web server 144768 362 - Download
atlantis 0.0.2.1 operating system 2681 103 - Download
bash 4.2 command language interpreter 102978 355 getcppsyms.c | execute_cmd.c Download
bc 1.03 calculator 5177 27 - Download
berkeley 4.7.25 database system 185111 580 - Download
bison 2.0 parser generator 24325 129 - Download
cherokee 1.2.101 web server 63109 346 - Download
clamav 0.97.6 antivirus 107548 377 - Download
cvs 1.11.21 version control system 76125 236 buffer.c Download
dia 0.97.2 diagramming software 19106 551 - Download
expat 2.1.0 XML library 17103 54 - Download
flex 2.5.37 lexical analyzer 17954 45 - Download
fvwm 2.4.15 windows manager 102301 270 - Download
gawk 3.1.4 GAWK interpreter 43070 140 - Download
ghostscript 9.05 postscript interpreter 1536979 3230 - Download
gnuchess 5.06 chess player 9293 37 - Download
gnuplot 4.6.1 plotting tool 79557 152 - Download
gzip 1.2.4 file compressor 5809 36 - Download
irssi 0.8.15 IRC client 51356 308 - Download
kin db 0.5 database system 64120 119 - Download
libieee 0.2.11   IEEE standards for VHDL library   5323 27 - Download
libdsmcc 0.6 DVB library 5453 30 - Download
libpng 1.6.0 PNG library 44828 61 pngvalid.c Download
libsoup 2.41.1 SOUP library 40061 178 - Download
libssh 0.5.3 SSH library 28015 125 dh.c | keyfiles.c | keys.c (1) | keys.c (2) Download
libxml2 2.9.0 XML library 234934 162 - Download
lighttpd 1.4.30 web server 38847 132 - Download
lua 5.2.1 programming language 14503 59 - Download
lynx 2.8.7 web browser 80334 117 - Download
m4 1.4.4 macro expander 10469 26 - Download
mpsolve 2.2 mathematical software 10278 41 - Download
mptris 1.9 game 4988 29 - Download
prc-tools 2.3    C/C++ library for palm OS    14371 142 - Download
privoxy 3.0.19 proxy server 29021 67 - Download
sendmail 8.14.6 mail transfer agent 91288 243 - Download
sqlite 3.7.15.2 database system 94113 134 - Download
sylpheed 3.3.0 e-mail client 83528 218 - Download
rcs 5.7 revision control system 11916 28 - Download
vim 7.3 text editor 288654 178 memfile.c | os_unix.c | if_mzsch.c | netbeans.c Download
xfig 3.2.4 vector graphics editor 70493 192 w_cmdpanel.c Download
xterm 2.4.3 terminal emulator 50830 58 main.c (1) | main.c (2) Download

Table II: Commits Results

   PROJECT       COMMITS       DEVELOPERS       SYNTAX ERRORS       SYNTAX ERRORS SOURCE       SOURCE   
apache 24719 108 3 ab.c | mod_include.c | ssl_util_ssl.c Download
bash 68 2 2 getcppsyms.c | execute_cmd.c Download
dia 5397 217 2 app_procs.c | preferences.c Download
gnuplot 7611 16 5 plot.c | Util.c | parse.c | Graph3d.c | datafile.c Download
libpng 2179 5 2 pngtest.c | pngtrans.c Download
libssh 2569 26 7        dh.c | keyfiles.c | keys.c (1) | keys.c (2) | channels.c | server.c | client.c        Download
libxml2 4179 169 2 xmlregexp.c | xpath.c Download
vim 4313 2 4 memfile.c | os_unix.c | if_mzsch.c | netbeans.c Download



Contact

This work has been developed at the Federal University of Campina Grande (UFCG), Brazil. If you have any question, please contact the researcher:

Flávio Medeiros
Email: flaviomedeiros at copin.ufcg.edu.br.

Basic Use:

You can replicate this study by downloading the source of the project and executing the following steps:

1. Download our plugin (SyntaxErrorAnalyzer) here. It is an Eclipse plug-in that executes the three first steps of our technique. Add this project to your Eclipse platform and run the plug-in.
2. Download the Eclipse project here and add it to your Eclipse runtime workspace. This project contains a file (test.c) with a preprocessor-based syntax error when we define MACRO.
3. Run the plug-in in your Eclipse runtime by clicking at the button the plug-in adds to your Eclipse runtime. It will generate some files, including the typechef-checker.sh script.
4. Run this script to call TypeChef and identify preprocessor-based syntax errors.

Example 1. Analyzing the CProject example you download in Step 2:
  
prompt> chmod +x typechef-checker.sh
prompt> ./typechef-checker.sh

File: test.c
parsing.

def(MACRO)	failed: found "printf", but expected "}" at file analysis/test.c:300:1 (List())
!def(MACRO)	succeeded

	

To analyze a real project release or commits, execute the following steps:

1. Download the source code of the project release at Table 1. For instance, you can download the apache.zip file.
2. Decompressing this file will generate a folder with name (apache).
3. Add the lib folder you can download here to this folder (apache). The lib folder contains the TypeChef.jar. So, you can run the typechef-checker.sh script.


SPG - Software Productivity Group