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-----------------------------------------------------------------------------
3This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2012 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
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* |___2___|3|_________5__________|__6__|
39* ^ ^
40* 1 4
41*
42* 1 -> Pointer to start of the block allocated by new.
43* 2 -> Gap used to get 4 aligned on given alignment
44* 3 -> Byte offset between 1 and 4
45* 4 -> Pointer to the start of data block.
46* 5 -> Data block.
47* 6 -> Wasted memory at rear of data block.
48*/
49
50namespace 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];
2
Memory is allocated
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

Reply via email to