Hi all,
Currently managed to launch the analyzer only on the Ogre
(http://www.ogre3d.org/download/source) codebase using different hacks
and tricks. The analyzer found a single leak - a known type of
false-positives related to the bit mangling. Attached is the report from
the analyzer. I think it's a good result as Ogre extensively allocates
memory in different ways and we haven't got tons of false-positives. To
ensure that the analyzer works correctly I injected a leaky code in the
Ogre codebase and the analyzer successfully found it.
The last weeks I'm trying to launch the analyzer on the QT5 codebase.
Currently found at least 4 defects in the scan-build/ccc-analyzer
scripts preventing me from successful run. Also tried to launch the
analyzer over several small projects but failed. The scan-build is far
from being production-quality. Currently working on the defects.
Anton,
Have you tested this on any C++ codebase other than LLVM? It would be really
great to confirm the results by testing this on a different project.
http://reviews.llvm.org/D5313
--
Anton
Title: ../../OgreMain/src/OgreAlignedAllocator.cpp
Bug Summary
| File: | f:\---OGRE\ogre_src_v1-8-1\-Build-\OgreMain/../../OgreMain/src/OgreAlignedAllocator.cpp |
| Location: | line 61, column 20 |
| Description: | Potential leak of memory pointed to by 'p' |
Annotated Source Code
| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 | #include "OgreStableHeaders.h"
|
| 29 |
|
| 30 | #include "OgrePrerequisites.h"
|
| 31 | #include "OgreAlignedAllocator.h"
|
| 32 |
|
| 33 | #include "OgrePlatformInformation.h"
|
| 34 | #include "OgreBitwise.h"
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 | namespace Ogre {
|
| 51 |
|
| 52 |
|
| 53 | void* AlignedMemory::allocate(size_t size, size_t alignment)
|
| 54 | {
|
| 55 | assert(0 < alignment && alignment <= 128 && Bitwise::isPO2(alignment))((void)0);
|
| 56 |
|
| 57 | unsigned char* p = new unsigned char[size + alignment];
|
| |
| 58 | size_t offset = alignment - (size_t(p) & (alignment-1));
|
| 59 |
|
| 60 | unsigned char* result = p + offset;
|
| 61 | result[-1] = (unsigned char)offset;
|
| 3 | | Potential leak of memory pointed to by 'p' |
|
| 62 |
|
| 63 | return result;
|
| 64 | }
|
| 65 |
|
| 66 | void* AlignedMemory::allocate(size_t size)
|
| 67 | {
|
| 68 | return allocate(size, OGRE_SIMD_ALIGNMENT16);
|
| 1 | Calling 'AlignedMemory::allocate' | |
|
| 69 | }
|
| 70 |
|
| 71 | void AlignedMemory::deallocate(void* p)
|
| 72 | {
|
| 73 | if (p)
|
| 74 | {
|
| 75 | unsigned char* mem = (unsigned char*)p;
|
| 76 | mem = mem - mem[-1];
|
| 77 | delete [] mem;
|
| 78 | }
|
| 79 | }
|
| 80 |
|
| 81 | }
|
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits