<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Malloc error "pointer being freed was not allocated"."
   href="http://llvm.org/bugs/show_bug.cgi?id=18109">18109</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Malloc error "pointer being freed was not allocated".
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Static Analyzer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>kremenek@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>hr.deepak@tcs.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=11642" name="attach_11642" title="PluginChecker.cpp: Source code of plugin. .so: plugin build, example.c: C code on which test is to done error.txt: dump on the terminal run, failure folder built by clang.">attachment 11642</a> <a href="attachment.cgi?id=11642&action=edit" title="PluginChecker.cpp: Source code of plugin. .so: plugin build, example.c: C code on which test is to done error.txt: dump on the terminal run, failure folder built by clang.">[details]</a></span>
PluginChecker.cpp: Source code of plugin. .so: plugin build, example.c: C code
on which test is to done error.txt: dump on the terminal run, failure folder
built by clang.

I was trying to build a simple plugin for static analyzer of clang. The plugin
will simply report all the printf function call in a given .c file. It may not
do anything fruitful, but a simple start for me.

I was able to build a dynamic library with the following command.
    g++ -share -fPIC -I~/static_plugin/llvm/include
-I~static_plugin/build/include  -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -g -fvisibility-inlines-hidden
-fno-exceptions -fno-rtti -fno-common -Woverloaded-virtual -Wcast-qual 
-I~/static_plugin/llvm/tools/clang/include
-I~/static_plugin/build/tools/clang/include
-L~/static_plugin/build/Debug+Asserts/lib -lz -lpthread -lcurses -lm -undefined
dynamic_lookup -o PrintfChecker.so PrintfChecker.cpp

When I tested it on a sample C code containing a printf call, a runtime error
is generated. I have attached the error message dumped on terminal as
error.txt. I have also attached the failure folder as zip and the C code as
example.c. I used the following cmd to test the  C code.
    ./static_plugin/llvm/tools/clang/tools/scan-build/scan-build
--use-analyzer=~/static_plugin/build/Debug+Asserts/bin/clang -load-plugin
./PrintfChecker.so -enable-checker security.PrintfChecker gcc -c example.c</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>