Archived issue #0023284
Using 'memcpy' on class that contains a virtual method
Description
The 'memcpy' function is used to copy the fields of 'MemBlock' class. Virtual method table will be damaged by this.
Warning issued by PVS-Studio in NCollection_Vector.cxx, line 296:
memcpy (aData, aSource, aSize * sizeof(MemBlock));
This might lead to a crash but I haven't tested it.
Warning issued by PVS-Studio in NCollection_Vector.cxx, line 296:
memcpy (aData, aSource, aSize * sizeof(MemBlock));
This might lead to a crash but I haven't tested it.
Public activity
11 archived notes
Participants are labeled by their role within this record.
Dear kgv,
I've implemented a fix into branch CR23284.
Please, review.
I've implemented a fix into branch CR23284.
Please, review.
Patch was reviewed without remarks.
Ready for testing in CR23284_1 branch.
Ready for testing in CR23284_1 branch.
Dear BugMaster,
Branch CR23284_1 was rebased on the current master.
Branch CR23284_1 (and products from GIT master) was compiled on Linux and Windows platforms and tested.
[revision removed]
There are following compilation errors:
http://jenkins-test-01.nnov.opencascade.com/user/mnt/my-views/view/CR23284_1/job/mnt-CR23284_1-master_build_occt_products_linux/1/parsed_console/?
../../../inc/QMData_BgrNode.hxx:120: error:
'QMData_BgrNode::QMData_BgrNode(const QMData_BgrNode&)' is protected
dn60/WOKLOC/wok_entities/LOC/dev/CR23284-1-master-occt/inc/NCollection_Vector.hxx:92:
error: within this context
Number of compiler warnings:
occt component :
Linux: 3 (3 on master)
Windows: 39 (39 on master)
Regressions:
http://occt-tests/CR23284-1-master-occt/Mandriva2010/summary.html
bugs step(007) bug55 bug272_5 bug16351
Improvements:
No improvements
Testing cases:
Not needed
Branch CR23284_1 was rebased on the current master.
Branch CR23284_1 (and products from GIT master) was compiled on Linux and Windows platforms and tested.
[revision removed]
There are following compilation errors:
http://jenkins-test-01.nnov.opencascade.com/user/mnt/my-views/view/CR23284_1/job/mnt-CR23284_1-master_build_occt_products_linux/1/parsed_console/?
../../../inc/QMData_BgrNode.hxx:120: error:
'QMData_BgrNode::QMData_BgrNode(const QMData_BgrNode&)' is protected
dn60/WOKLOC/wok_entities/LOC/dev/CR23284-1-master-occt/inc/NCollection_Vector.hxx:92:
error: within this context
Number of compiler warnings:
occt component :
Linux: 3 (3 on master)
Windows: 39 (39 on master)
Regressions:
http://occt-tests/CR23284-1-master-occt/Mandriva2010/summary.html
bugs step(007) bug55 bug272_5 bug16351
Improvements:
No improvements
Testing cases:
Not needed
Dear SZV,
I've implemented a fix into branch CR23284_2.
Please, review.
I've implemented a fix into branch CR23284_2.
Please, review.
Dear omy,
could you please consider conversion of NCollection_BaseVector::MemBlock class to POD structure (remove myAlloc field, destructor and custom constructors)? I don't see any usage of NCollection_Vector::~MemBlock in code at all since elements destroyed by NCollection_Vector::Reinit and allocated only within NCollection_Vector::FuncDataInit.
Also this is preferred to rebase your patch before sending it to review since NCollection_Vector sources are out-dated in your branch.
could you please consider conversion of NCollection_BaseVector::MemBlock class to POD structure (remove myAlloc field, destructor and custom constructors)? I don't see any usage of NCollection_Vector::~MemBlock in code at all since elements destroyed by NCollection_Vector::Reinit and allocated only within NCollection_Vector::FuncDataInit.
Also this is preferred to rebase your patch before sending it to review since NCollection_Vector sources are out-dated in your branch.
Dear kgv,
I've implemented a fix into branch CR23284_2 and rebased it onto current master.
Please, review.
I've implemented a fix into branch CR23284_2 and rebased it onto current master.
Please, review.
Patch is ready for testing in CR23284_3 branch.
Dear BugMaster,
Branch CR23284_3 (and products from GIT master) was compiled on Linux and Windows platforms.
There are following compilation errors:
http://jenkins-test-01.nnov.opencascade.com:8080/user/mnt/my-views/view/CR23284_3/job/mnt-CR23284_3-master_build_occt_linux/1/consoleFull
/bin/sh ../../../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I../../.. -I../../../inc -I../../../drv/math -I../../../src/math -I../../../drv/ElCLib -I../../../src/ElCLib -I../../../drv/ElSLib -I../../../src/ElSLib -I../../../drv/BSplCLib -I../../../src/BSplCLib -I../../../drv/BSplSLib -I../../../src/BSplSLib -I../../../drv/PLib -I../../../src/PLib -I../../../drv/Precision -I../../../src/Precision -I../../../drv/GeomAbs -I../../../src/GeomAbs -I../../../drv/Poly -I../../../src/Poly -I../../../drv/CSLib -I../../../src/CSLib -I../../../drv/Convert -I../../../src/Convert -I../../../drv/Bnd -I../../../src/Bnd -I../../../drv/gp -I../../../src/gp -I../../../drv/TColgp -I../../../src/TColgp -I../../../drv/TopLoc -I../../../src/TopLoc -I/dn48/PRODUCTS/salome/6.x/opt/MANDRIVA.2010/6.6.0/jdk1.6.0/include -I/dn48/PRODUCTS/salome/6.x/opt/MANDRIVA.2010/6.6.0/jdk1.6.0/include/linux -DNDEBUG -DNo_Exception -DCSFDB -DOCC_CONVERT_SIGNALS -DLIN -DLININTEL -D_GNU_SOURCE=1 -O2 -MT Poly_MakeLoops.lo -MD -MP -MF .deps/Poly_MakeLoops.Tpo -c -o Poly_MakeLoops.lo `test -f '../../../src/Poly/Poly_MakeLoops.cxx' || echo './'`../../../src/Poly/Poly_MakeLoops.cxx
In file included from ../../../inc/Poly_CoherentTriangulation.hxx:29,
from ../../../src/Poly/Poly_CoherentTriangulation.cxx:21:
../../../inc/NCollection_Vector.hxx: In constructor 'NCollection_Vector<TheItemType>::NCollection_Vector(Standard_Integer, const Handle_NCollection_BaseAllocator&)':
../../../inc/NCollection_Vector.hxx:117: error: 'myAllocator' was not declared in this scope
../../../inc/NCollection_Vector.hxx: In copy constructor 'NCollection_Vector<TheItemType>::NCollection_Vector(const NCollection_Vector<TheItemType>&)':
../../../inc/NCollection_Vector.hxx:122: error: 'myAllocator' was not declared in this scope
../../../inc/NCollection_Vector.hxx: In destructor 'NCollection_Vector<TheItemType>::~NCollection_Vector()':
../../../inc/NCollection_Vector.hxx:134: error: 'myAllocator' was not declared in this scope
../../../inc/NCollection_Vector.hxx: In member function 'TheItemType& NCollection_Vector<TheItemType>::Append(const TheItemType&)':
../../../inc/NCollection_Vector.hxx:203: error: 'myAllocator' was not declared in this scope
../../../inc/NCollection_Vector.hxx: In member function 'TheItemType& NCollection_Vector<TheItemType>::SetValue(Standard_Integer, const TheItemType&)':
../../../inc/NCollection_Vector.hxx:259: error: 'myAllocator' was not declared in this scope
../../../inc/NCollection_Vector.hxx: In member function 'void NCollection_Vector<TheItemType>::Assign(const NCollection_Vector<TheItemType>&, Standard_Boolean)':
../../../inc/NCollection_Vector.hxx:343: error: 'myAllocator' was not declared in this scope
Branch CR23284_3 (and products from GIT master) was compiled on Linux and Windows platforms.
There are following compilation errors:
http://jenkins-test-01.nnov.opencascade.com:8080/user/mnt/my-views/view/CR23284_3/job/mnt-CR23284_3-master_build_occt_linux/1/consoleFull
/bin/sh ../../../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I../../.. -I../../../inc -I../../../drv/math -I../../../src/math -I../../../drv/ElCLib -I../../../src/ElCLib -I../../../drv/ElSLib -I../../../src/ElSLib -I../../../drv/BSplCLib -I../../../src/BSplCLib -I../../../drv/BSplSLib -I../../../src/BSplSLib -I../../../drv/PLib -I../../../src/PLib -I../../../drv/Precision -I../../../src/Precision -I../../../drv/GeomAbs -I../../../src/GeomAbs -I../../../drv/Poly -I../../../src/Poly -I../../../drv/CSLib -I../../../src/CSLib -I../../../drv/Convert -I../../../src/Convert -I../../../drv/Bnd -I../../../src/Bnd -I../../../drv/gp -I../../../src/gp -I../../../drv/TColgp -I../../../src/TColgp -I../../../drv/TopLoc -I../../../src/TopLoc -I/dn48/PRODUCTS/salome/6.x/opt/MANDRIVA.2010/6.6.0/jdk1.6.0/include -I/dn48/PRODUCTS/salome/6.x/opt/MANDRIVA.2010/6.6.0/jdk1.6.0/include/linux -DNDEBUG -DNo_Exception -DCSFDB -DOCC_CONVERT_SIGNALS -DLIN -DLININTEL -D_GNU_SOURCE=1 -O2 -MT Poly_MakeLoops.lo -MD -MP -MF .deps/Poly_MakeLoops.Tpo -c -o Poly_MakeLoops.lo `test -f '../../../src/Poly/Poly_MakeLoops.cxx' || echo './'`../../../src/Poly/Poly_MakeLoops.cxx
In file included from ../../../inc/Poly_CoherentTriangulation.hxx:29,
from ../../../src/Poly/Poly_CoherentTriangulation.cxx:21:
../../../inc/NCollection_Vector.hxx: In constructor 'NCollection_Vector<TheItemType>::NCollection_Vector(Standard_Integer, const Handle_NCollection_BaseAllocator&)':
../../../inc/NCollection_Vector.hxx:117: error: 'myAllocator' was not declared in this scope
../../../inc/NCollection_Vector.hxx: In copy constructor 'NCollection_Vector<TheItemType>::NCollection_Vector(const NCollection_Vector<TheItemType>&)':
../../../inc/NCollection_Vector.hxx:122: error: 'myAllocator' was not declared in this scope
../../../inc/NCollection_Vector.hxx: In destructor 'NCollection_Vector<TheItemType>::~NCollection_Vector()':
../../../inc/NCollection_Vector.hxx:134: error: 'myAllocator' was not declared in this scope
../../../inc/NCollection_Vector.hxx: In member function 'TheItemType& NCollection_Vector<TheItemType>::Append(const TheItemType&)':
../../../inc/NCollection_Vector.hxx:203: error: 'myAllocator' was not declared in this scope
../../../inc/NCollection_Vector.hxx: In member function 'TheItemType& NCollection_Vector<TheItemType>::SetValue(Standard_Integer, const TheItemType&)':
../../../inc/NCollection_Vector.hxx:259: error: 'myAllocator' was not declared in this scope
../../../inc/NCollection_Vector.hxx: In member function 'void NCollection_Vector<TheItemType>::Assign(const NCollection_Vector<TheItemType>&, Standard_Boolean)':
../../../inc/NCollection_Vector.hxx:343: error: 'myAllocator' was not declared in this scope
Dear kgv,
I've fixed the mentioned compilation errors.
Please, review.
I've fixed the mentioned compilation errors.
Please, review.
No remarks, please test.
Dear BugMaster,
Branch CR23284_3 (and products from GIT master) was compiled on Linux and Windows platforms and tested without rebase.
[revision removed]
Number of compiler warnings:
occt component :
Linux: 3 (3 on master)
Windows: 11 (11 on master)
products component :
Linux: 0 (0 on master)
Windows: 50 (50 on master)
Regressions:
No regressions
Improvements:
No improvements
Testing cases:
Not needed
Testing on Linux:
Total MEMORY difference: 242475480 / 243421460
Total CPU difference: 17395.4600000001 / 15475.660000000038
Testing on Windows:
Total MEMORY difference: 345678912 / 346233352
Total CPU difference: 17723.0625 / 21620.5
There are not serious differences in images found by testdiff.
Branch CR23284_3 (and products from GIT master) was compiled on Linux and Windows platforms and tested without rebase.
[revision removed]
Number of compiler warnings:
occt component :
Linux: 3 (3 on master)
Windows: 11 (11 on master)
products component :
Linux: 0 (0 on master)
Windows: 50 (50 on master)
Regressions:
No regressions
Improvements:
No improvements
Testing cases:
Not needed
Testing on Linux:
Total MEMORY difference: 242475480 / 243421460
Total CPU difference: 17395.4600000001 / 15475.660000000038
Testing on Windows:
Total MEMORY difference: 345678912 / 346233352
Total CPU difference: 17723.0625 / 21620.5
There are not serious differences in images found by testdiff.
Related records