Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
[Bug report] CodeBlocks crash when adding file to the project
AdrianB:
Glad to hear this.
Also I have some random crashes (which I didn't catch them) but the situation is like trying to type something like printf(""); and CB is crashing.
I think is related to the same issue, not 100%.
Initially I thought that is a Debian issue with their 5 patches, but rebuilding from the scratch directly from the sources I notice the same behavior.
I hope you will find the issue and fix it 8).
Kind regards,
Adrian
ollydbg:
OK, I correctly locate the bug, and please test this patch, I think it should fix the crash issue.
--- Code: ---From 06b24abc0710e6befcbcbb18ad353aa8ae8a334f Mon Sep 17 00:00:00 2001
From: asmwarrior <asmwarrior@gmail.com>
Date: Wed, 7 Sep 2016 14:46:48 +0800
Subject: * CC: fix a endless loop crash bug when parsing C99 designated
initializer
Forum discussion is here:
http://forums.codeblocks.org/index.php/topic,21417.0.html
When parsing
struct AAA a1 = {.x = 1, .y=2}; // first line
struct AAA a2 = {.x = 1, .y=2}; // second line
When we see a "dot", we need to skip to "}", thus the close brace is
skipped, and the open brace is just start a function call of DoParse().
If we goes to the second line, we will call another DoParse(), so there
is recursive calls, and finally goes to crash.
Also, a cc test case is added
diff --git a/src/plugins/codecompletion/parser/parserthread.cpp b/src/plugins/codecompletion/parser/parserthread.cpp
index fc00985..3d81acf 100644
--- a/src/plugins/codecompletion/parser/parserthread.cpp
+++ b/src/plugins/codecompletion/parser/parserthread.cpp
@@ -2197,6 +2197,21 @@ void ParserThread::HandleClass(EClassType ct)
break;
}
// -------------------------------------------------------------------
+ else if(next == ParserConsts::equals)
+ // -------------------------------------------------------------------
+ {
+ // some patterns like: struct AAA a = {.x = 1, .y=2};
+ // In (ANSI) C99, you can use a designated initializer to initialize a structure
+ if (!lastCurrent.IsEmpty() )
+ {
+ m_Str << lastCurrent << ParserConsts::space_chr;
+ DoAddToken(tkVariable, current, m_Tokenizer.GetLineNumber());
+ }
+ // so we have to eat the brace pair
+ SkipToOneOfChars(ParserConsts::semicolon, /* supportNesting*/ true, /*singleCharToken*/ true);
+ break;
+ }
+ // -------------------------------------------------------------------
else
// -------------------------------------------------------------------
{
diff --git a/src/plugins/codecompletion/testing/cc_structs.cpp b/src/plugins/codecompletion/testing/cc_structs.cpp
new file mode 100644
index 0000000..82cd85a
--- /dev/null
+++ b/src/plugins/codecompletion/testing/cc_structs.cpp
@@ -0,0 +1,13 @@
+
+// parsing C99 designated initializer of struct
+// http://forums.codeblocks.org/index.php/topic,21417.0.html
+struct AAA
+{
+ int x;
+ float y;
+};
+
+struct AAA a1 = {.x = 1, .y=0.2}; // first line
+struct AAA a2 = {.x = 1, .y=0.2}; // second line
+
+//a //a1,a2
\ No newline at end of file
--- End code ---
AdrianB:
Hi ollydbg,
The patch seems to work ok. I will do some intensive tests those days.
Kind regards,
Adrian
AdrianB:
Hi ollydbg,
The issue is not more present, but I still have random crashes when I'm starting to type something and I believe is also related to code parser.
Do you want to open another thread or I can send you the debug information here?
Kind regards,
Adrian
ollydbg:
--- Quote from: AdrianB on September 07, 2016, 11:33:05 pm ---Hi ollydbg,
The issue is not more present, but I still have random crashes when I'm starting to type something and I believe is also related to code parser.
Do you want to open another thread or I can send you the debug information here?
Kind regards,
Adrian
--- End quote ---
Thanks for the test.
For the crash issue, I would like you to report it to our Ticket system. If the problem is easy to fix, then post it in our forum is OK, but if the bug is hard to fix(usually it takes a lot of time to debug a multiply thread issue), the best place is the ticket system. Someone has already report similar crash issue here, is it the same as yours? See here: Code::Blocks / Tickets / #402 Segmentation Fault crash when code completion parsing
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version