Review Request: Add some crash safety in templateresolver.cpp

Olivier Jean de Gaalon olivier.jg at gmail.com
Fri Nov 2 15:56:28 UTC 2012


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/107175/#review21355
-----------------------------------------------------------


matchTemplateParameterTypesInternal() was designed to only be called with a valid argumentType and parameterType.
Based on the backtrace, the baseType() of some PointerType is null. As far as I know, this should never be the case and points to a bug in the CPP TypeBuilder. I'd like to see what KDevelop is trying to parse when this crashes.

If it's possible under normal circumstances for TypeBuilder to create PointerType/ReferenceType/... objects with invalid baseTypes, then the correct check would be something like:
===========
if (!argumentType || !parameterType)
{
  kWarning() << "Invalid Type Encountered";
  res.valid = false;
  return;
}
===========
At the beginning of matchTemplateParameterTypesInternal().

But again, I'd like to see what is being parsed when this happens, if you could provide a test case that shows this behavior.
Thanks for reporting/fixing.

- Olivier Jean de Gaalon


On Nov. 2, 2012, 11:06 a.m., Kevin Funk wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/107175/
> -----------------------------------------------------------
> 
> (Updated Nov. 2, 2012, 11:06 a.m.)
> 
> 
> Review request for KDevelop.
> 
> 
> Description
> -------
> 
> Add some crash safety in templateresolver.cpp
> 
> Backtrace:
> 5  KDevelop::AbstractType::d_func (this=0x0) at
> /home/krf/devel/src/kdevplatform/language/duchain/types/abstracttype.h:284
> 6  0x00007f2bf466b4f9 in KDevelop::AbstractType::modifiers
> (this=<optimized out>) at
> /home/krf/devel/src/kdevplatform/language/duchain/types/abstracttype.cpp:52
> 7  0x00007f2bc646663b in isConstBased (type=...) at
> /home/krf/devel/src/kdevelop/languages/cpp/cppduchain/templateresolver.cpp:47
> 8  0x00007f2bc6466e03 in
> Cpp::TemplateResolver::matchTemplateParameterTypesInternal
> (this=this at entry=0x7f2b651ce6f0, argumentType=..., parameterType=...,
> instantiatedTypes=..., res=...) at
> /home/krf/devel/src/kdevelop/languages/cpp/cppduchain/templateresolver.cpp:277
> 9  0x00007f2bc6467365 in
> Cpp::TemplateResolver::templateHandlePointerType (this=0x7f2b651ce6f0,
> argumentType=..., parameterType=..., instantiatedTypes=..., res=...) at
> /home/krf/devel/src/kdevelop/languages/cpp/cppduchain/templateresolver.cpp:151
> 10 0x00007f2bc6466d80 in
> Cpp::TemplateResolver::matchTemplateParameterTypesInternal
> (this=this at entry=0x7f2b651ce6f0, argumentType=..., parameterType=...,
> instantiatedTypes=..., res=...) at
> /home/krf/devel/src/kdevelop/languages/cpp/cppduchain/templateresolver.cpp:270
> 11 0x00007f2bc646762c in
> Cpp::TemplateResolver::matchTemplateParameterTypes (this=0x7f2b651ce6f0,
> argumentType=..., parameterType=..., instantiatedTypes=...) at
> /home/krf/devel/src/kdevelop/languages/cpp/cppduchain/templateresolver.cpp:38
> (...)
> 
> 
> Diffs
> -----
> 
>   languages/cpp/cppduchain/templateresolver.cpp 246bd31049d6a94e76f9188a827bc503c869923a 
> 
> Diff: http://git.reviewboard.kde.org/r/107175/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Kevin Funk
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20121102/1036a8f8/attachment.html>


More information about the KDevelop-devel mailing list