<div dir="ltr"><div>Here's more info:</div><div><br></div><div>RenameMethod: /home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/Rewrite/Core/RewriteRope.cpp:377: void {anonymous}::RopePieceBTreeLeaf::erase(unsigned int, unsigned int): Assertion `getPiece(StartPiece).size() > NumBytes' failed.<br>
</div><div><br></div><div style>stack:</div><div style><br></div><div>Program received signal SIGABRT, Aborted.</div><div>0x00002aaaab4b2f45 in raise () from /lib64/libc.so.6</div><div>(gdb) where</div><div>#0 0x00002aaaab4b2f45 in raise () from /lib64/libc.so.6</div>
<div>#1 0x00002aaaab4b4340 in abort () from /lib64/libc.so.6</div><div>#2 0x00002aaaab4ac486 in __assert_fail () from /lib64/libc.so.6</div><div>#3 0x0000000000f66751 in (anonymous namespace)::RopePieceBTreeLeaf::erase (this=0x3675550, Offset=50490, NumBytes=4294951421)</div>
<div> at /home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/Rewrite/Core/RewriteRope.cpp:377</div><div>#4 0x0000000000f67114 in (anonymous namespace)::RopePieceBTreeNode::erase (this=0x3675550, Offset=50490, NumBytes=4294951421)</div>
<div> at /home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/Rewrite/Core/RewriteRope.cpp:652</div><div>#5 0x0000000000f6764d in clang::RopePieceBTree::erase (this=0x64a8480, Offset=50490, NumBytes=4294951421)</div>
<div> at /home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/Rewrite/Core/RewriteRope.cpp:755</div><div>#6 0x0000000000f6a5bb in clang::RewriteRope::erase(unsigned int, unsigned int) ()</div><div>#7 0x0000000000f684fb in clang::RewriteBuffer::ReplaceText (this=0x64a8478, OrigOffset=50501, OrigLength=4294951421, NewStr=...)</div>
<div> at /home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/Rewrite/Core/Rewriter.cpp:111</div><div>#8 0x0000000000f692ab in clang::Rewriter::ReplaceText (this=0x7fffffffc3b0, Start=..., OrigLength=4294951421, NewStr=...)</div>
<div> at /home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/Rewrite/Core/Rewriter.cpp:309</div><div>#9 0x0000000000f5db27 in clang::tooling::Replacement::apply (this=0x63ea2c0, Rewrite=...)</div><div> at /home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/Tooling/Refactoring.cpp:69</div>
<div>#10 0x0000000000f5dfc4 in clang::tooling::applyAllReplacements (Replaces=..., Rewrite=...)</div><div> at /home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/Tooling/Refactoring.cpp:130</div><div>#11 0x0000000000f5e2c0 in clang::tooling::RefactoringTool::applyAllReplacements (this=0x7fffffffcc98, Rewrite=...)</div>
<div> at /home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/Tooling/Refactoring.cpp:166</div><div>#12 0x0000000000f5e1fa in clang::tooling::RefactoringTool::runAndSave (this=0x7fffffffcc98, ActionFactory=0x1c50af0)</div>
<div> at /home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/Tooling/Refactoring.cpp:158</div><div>#13 0x0000000000421305 in main (argc=2, argv=0x7fffffffcfd8) at RenameMethod.cpp:341</div><div style><br></div>
<div style>The sizes being compared:</div><div style><br><div>#3 0x0000000000f66761 in (anonymous namespace)::RopePieceBTreeLeaf::erase (this=0x3675550, Offset=50490, NumBytes=4294951421)</div><div> at /home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/Rewrite/Core/RewriteRope.cpp:377</div>
<div>377 assert(getPiece(StartPiece).size() > NumBytes);</div><div>(gdb) p NumBytes</div><div>$1 = 4294951421</div><div>(gdb) p /x NumBytes</div><div>$2 = 0xffffc1fd</div><div>(gdb) p getPiece(StartPiece).size()</div>
<div>$3 = 10836</div><div><br></div><div style>Looks like some code somewhat allows NumBytes is effectively negative. That goes back to the object creation:</div><div style><br></div><div style><div>(gdb) frame 9</div><div>
#9 0x0000000000f5db37 in clang::tooling::Replacement::apply (this=0x63ea2c0, Rewrite=...)</div><div> at /home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/Tooling/Refactoring.cpp:69</div><div>69 bool RewriteSucceeded = !Rewrite.ReplaceText(Start, Length, ReplacementText);</div>
<div>(gdb) p *this</div><div>$7 = {FilePath = {static npos = <optimized out>,</div><div> _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},</div>
<div> _M_p = 0x4ac9cb8 "/view/peeterj_clang8/vbs/engn/include/sqloOSResourceTrack.h"}}, Offset = 50501, Length = 4294951421, ReplacementText = {</div><div> static npos = <optimized out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},</div>
<div> _M_p = 0x6466b98 "&g_pOSResourceTracked"}}}</div><div><br></div><div><br></div><div style>I'm assuming that this Length isn't the replacement length, but is the source range of the text to replace. That's calculated in this code as:</div>
<div style><br></div><div style><div> virtual void run(const MatchFinder::MatchResult &Result) {</div><div> const CallExpr *M = Result.Nodes.getStmtAs<CallExpr>("x");</div><div> const Expr * a = M->getArg( 3 ) ;</div>
<div><br></div><div> if ( const CStyleCastExpr * v = dyn_cast<CStyleCastExpr>( a ) )</div><div> {</div><div> const Expr * theCastedValue = v->getSubExprAsWritten() ;</div><div><br></div><div> if ( theCastedValue )</div>
<div> {</div><div> std::string replacement = decl2str( theCastedValue, Result.SourceManager ) ;</div><div><br></div><div> if ( replacement.length() )</div><div> {</div><div> SourceLocation start = v->getLocStart() ;</div>
<div> SourceLocation end = v->getLocEnd() ;</div><div> CharSourceRange range = CharSourceRange::getTokenRange( SourceRange(start, end) ) ;</div><div><br></div><div> Replace->insert(</div><div>
Replacement(*Result.SourceManager,</div><div> range,</div><div> replacement));</div><div> }</div><div> }</div><div><br></div><div style>somehow this has led to a negative length in the Replacement() object.</div>
</div></div><div style><br></div></div><div class="gmail_extra">-- <br>Peeter
</div></div>