Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
cc-branch crashes on linux
Loaden:
--- Quote from: MortenMacFly on August 23, 2010, 08:03:53 am ---
--- Quote from: jens on August 22, 2010, 10:27:12 pm ---The following patch avoids that problem, but it seems to change the behaviou alittle bit (for a simple hello-world project one file more is parsed, but less tokens are found).
--- End quote ---
Ooops - sounds weired. You mean for a single file "Hello World" project?! :shock:
@Loaden: What could be the reason for this?!
--- End quote ---
I am a little busy, will comment later.
Jenna:
--- Quote from: jens on August 22, 2010, 10:27:12 pm ---Another approach would be to leave everything as it is, but do it only if p is greater than buffer and if it is not (buffer has already been appended to str), remove the trailing spaces from str.
--- End quote ---
Next patch, this time it generates the exactly same tokens-tree, -list, include-dirs and file-list:
--- Code: ---Index: src/plugins/codecompletion/parser/tokenizer.cpp
===================================================================
--- src/plugins/codecompletion/parser/tokenizer.cpp (Revision 6508)
+++ src/plugins/codecompletion/parser/tokenizer.cpp (Arbeitskopie)
@@ -410,14 +410,34 @@
break;
else
{
- while (*(--p) <= _T(' ') && p > buffer)
- ;
+ // only work with p if the buffer is not just appended (p==buffer)
+ // otherwise remove the traling spaces from str (avoid segfault on linux in rare cases)
+ if(p > buffer)
+ {
+ while (*(--p) <= _T(' ') && p > buffer)
+ ;
+ }
+ else
+ {
+ while(!str.IsEmpty() && str.Last() <= _T(' '))
+ str.RemoveLast();
+ }
MoveToNextChar();
}
}
- while (*(p - 1) <= _T(' ') && --p > buffer)
- ;
+ // only work with p if the buffer is not just appended (p==buffer)
+ // otherwise remove the traling spaces from str (avoid segfault on linux in rare cases)
+ if(p > buffer)
+ {
+ while (*(p - 1) <= _T(' ') && --p > buffer)
+ ;
+ }
+ else
+ {
+ while(!str.IsEmpty() && str.Last() <= _T(' '))
+ str.RemoveLast();
+ }
str.Append(buffer, p - buffer);
TRACE(_T("ReadToEOL(): (END) We are now at line %d, CurrentChar='%c', PreviousChar='%c', NextChar='%c'"),
--- End code ---
[attachment deleted by admin]
Loaden:
--- Quote from: jens on August 22, 2010, 10:27:12 pm ---The following patch avoids that problem, but it seems to change the behaviou alittle bit (for a simple hello-world project one file more is parsed, but less tokens are found).
--- End quote ---
I'm back.
Need changed to:
--- Quote ---- while (*(p - 1) <= _T(' ') && --p > buffer)
- ;
+ while (p > buffer && *(p - 1) <= _T(' '))
+ --p;
--- End quote ---
This patch fixed crash in ReadParentheses too.
And do some simple optimization.
Jenna:
Tested and confirmed, no crash and identical tokens-list etc. for test-project.
Thank you for the quick fix !
killerbot:
I don't know if it is related, or already fixed by above mentioned patch, but for me CB is crashing also a lot.
Whenever I have method call for example, and just before the closing ')' of the call I press comma (,) CB dies on me (well never comes back and I have to kill it).
x.foo(1,2,3); --> before the ) and after the 3 press comma and it crashes.
Other way to reproduce. Have CB create a console application,
Go to the line of void main(), and try to type "int argc," , once the "," has been typed --> crash.
Can the above path be committed to cc branch.
PS : I am on linux
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version