Author Topic: Macro expansion infinite loop.  (Read 42579 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Macro expansion infinite loop.
« Reply #15 on: January 30, 2015, 08:24:03 am »
I'm testing it for a second day and I don't see major problems (crashes, infinite loops).
I can't comment much about the quality of the parser.
I found it still has some problems to handling "#undef" and other conditional directives.
I will fix them those days.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Macro expansion infinite loop.
« Reply #16 on: January 31, 2015, 03:57:40 pm »
I'm testing it for a second day and I don't see major problems (crashes, infinite loops).
I can't comment much about the quality of the parser.
I found it still has some problems to handling "#undef" and other conditional directives.
I will fix them those days.
Fixed by the V3 patches(you can apply V3 after applying V2, which means it can apply on https://github.com/obfuscated/codeblocks_sf/tree/ollydbg/cc_macro)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Macro expansion infinite loop.
« Reply #17 on: January 31, 2015, 04:05:13 pm »
Still no test cases are added!
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Macro expansion infinite loop.
« Reply #18 on: January 31, 2015, 04:15:22 pm »
Still no test cases are added!
Will be done tomorrow. It is midnight now...
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Macro expansion infinite loop.
« Reply #19 on: February 01, 2015, 04:04:52 am »
Still no test cases are added!
Will be done tomorrow. It is midnight now...
Here is the test case, which cause cctest to infinite loop in our CC trunk, but it works OK after applying my patch serials.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Macro expansion infinite loop.
« Reply #20 on: February 01, 2015, 01:02:09 pm »
OK, what about the test for all the other bugs/cases you've fixed?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Macro expansion infinite loop.
« Reply #21 on: February 01, 2015, 01:49:31 pm »
Fixed by the V3 patches(you can apply V3 after applying V2, which means it can apply on https://github.com/obfuscated/codeblocks_sf/tree/ollydbg/cc_macro)
...can I get them there? They won't apply otherwise.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Macro expansion infinite loop.
« Reply #22 on: February 01, 2015, 03:18:54 pm »
Morten: Check again...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Macro expansion infinite loop.
« Reply #23 on: February 01, 2015, 03:32:59 pm »
OK, what about the test for all the other bugs/cases you've fixed?
There many tests file under src\plugins\codecompletion\testing, but running the cctest don't seem to improve much. ;)
Code
--- C:/before-patch.txt	Sun Feb 01 22:09:43 2015
+++ C:/after-patch.txt Sun Feb 01 22:00:48 2015
@@ -77,15 +77,15 @@
 Total 1 tests, 1 PASS, 0 FAIL
 --------------------------------------------------------
 ********************************************************
   Testing in file: F:\cb_sf_git\trunk\src\plugins\codecompletion\testing\cc_mfc_expand_event_table.cpp
 ********************************************************
-*FAIL:  mymiss  mymissingfunc1
-*FAIL:  mymiss  mymissingfunc2
-*FAIL:  mymiss  mymissingfunc3
+-PASS:  mymiss  mymissingfunc1
+-PASS:  mymiss  mymissingfunc2
+-PASS:  mymiss  mymissingfunc3
 --------------------------------------------------------
-Total 3 tests, 0 PASS, 3 FAIL
+Total 3 tests, 3 PASS, 0 FAIL
 --------------------------------------------------------
 ********************************************************
   Testing in file: F:\cb_sf_git\trunk\src\plugins\codecompletion\testing\cc_namespaces.cpp
 ********************************************************
 -PASS: my_namespace.nested_namespace.  variable

Look, it only fixes three Fails.

But please note that checking every token in the Tokenizer level is the only correct way to handle all the C-preprocessor directives and macro expansions, currently the higher level(Parserthread) class has many hacks to do this. If you look at the ParserThread.cpp, there are many code to check a token to see whether it is a macro usage or not. My patch serials just do all the macro expansion in the Tokenizer level, and it will make Parserthread's code much clean and simple.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Macro expansion infinite loop.
« Reply #24 on: February 01, 2015, 05:42:33 pm »
Ok, so your changes fix already failing tests.  ;D

For me writing parsers is a task, when test-driven-development can be applied with great success.
The idea is simple:
1. first write a test that fails
2. then write the code to fix the failure.
3. repeat 1

Always make sure that no change is made if there is not test for it.
And of course make sure that after a change is made all test pass.
Doing this prevents introducing changes that break already working cases/features.

p.s. CC code is one place of C::B I have no intention to dig in and make myself familiar with, so I cannot comment if the changes you're making are good
p.p.s. This is the reason I'm asking you to add tests. It is an easy way to check if everything is working :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Macro expansion infinite loop.
« Reply #25 on: February 05, 2015, 01:51:24 pm »
FYI: I've just upgraded my work build to one that includes the latest patches and a crash I was seeing with the old build now doesn't happen.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Macro expansion infinite loop.
« Reply #26 on: February 06, 2015, 02:20:35 pm »
FYI: I've just upgraded my work build to one that includes the latest patches and a crash I was seeing with the old build now doesn't happen.
Good to hear, thanks for the testing.

Ok, so your changes fix already failing tests.  ;D
p.p.s. This is the reason I'm asking you to add tests. It is an easy way to check if everything is working :)
I will see if I can add more tests.

Question:
If I pick some commits in my patch serials, and commit them to the official SVN, is it possible(easy) to rebase the github cc_macro branch? I mean maybe all the commits need to be changed.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Macro expansion infinite loop.
« Reply #27 on: February 06, 2015, 03:28:44 pm »
If I pick some commits in my patch serials, and commit them to the official SVN, is it possible(easy) to rebase the github cc_macro branch? I mean maybe all the commits need to be changed.
Yes, interactive rebase is designed exactly for this purpose.  (Although, if you have never used it before, you may want to practice on a copy first.)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Macro expansion infinite loop.
« Reply #28 on: February 06, 2015, 03:43:34 pm »
Yes, I can rebase the branch, the history will be rewritten and might cause problems for people has commits that are not in the branch. But I doubt this is the case, so I think it is safe to rebase it.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Macro expansion infinite loop.
« Reply #29 on: March 03, 2015, 11:28:28 pm »
Any progress with this branch?
Do you plan committing fixes any time soon?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]