Author Topic: Bug in 'source code formatter (AStyle)'  (Read 5578 times)

Offline mushakk

  • Multiple posting newcomer
  • *
  • Posts: 54
Bug in 'source code formatter (AStyle)'
« on: June 19, 2007, 12:35:11 pm »
When I try to format generated code (gcc -E) sometimes the plugin crashes :(

Some of the lines in these files are up to 2840 chars!

Thx for your work!

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: Bug in 'source code formatter (AStyle)'
« Reply #1 on: June 19, 2007, 01:50:57 pm »
Hi !

I think your description is light...
Nightly ? OS? GCC version ? Bug report (*.RPT) ? File that made AStyle crash ?

It would be useful to debug. Don't forget to put the bug on BerliOS !

Dje

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Bug in 'source code formatter (AStyle)'
« Reply #2 on: June 19, 2007, 05:17:43 pm »
It would be great if you could provide a sample file that causes the plugin to crash.

Offline mushakk

  • Multiple posting newcomer
  • *
  • Posts: 54
Re: Bug in 'source code formatter (AStyle)'
« Reply #3 on: June 20, 2007, 12:09:36 pm »
Sorry I'm using yesterday version (20 jun)

With this example file the app crashes.

Quote
Don't forget to put the bug on BerliOS
I'm new here. How can I do that? url for bugs?

[attachment deleted by admin]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9604
Re: Bug in 'source code formatter (AStyle)'
« Reply #4 on: June 20, 2007, 01:21:26 pm »
With this example file the app crashes.
That's the culprit (asstreamiterator.h):
Code: [Select]
  wxChar buffer[2048];
It will result in crashing at line 47 in asstreamiterator.cpp:
Code: [Select]
  *filterPtr++ = *m_In;
(Notice that filterPtr equals buffer.)
So - you might want to just increase the value in the header to e.g. 4096 and that's basically it.

With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Bug in 'source code formatter (AStyle)'
« Reply #5 on: June 20, 2007, 07:37:10 pm »
Dynamic allocation seems to be a better choice :)

Fixed and committed :wink:

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Bug in 'source code formatter (AStyle)'
« Reply #6 on: June 20, 2007, 08:24:58 pm »
Thanks, Cen! Yes, dynamic allocation is the way to go. Otherwise we'd be hitting buffer overflows everytime someone ends up with a weird file, and we'd do the resizing to 4096,8192, blah blah blah :-P

Thumbs up.

Offline mushakk

  • Multiple posting newcomer
  • *
  • Posts: 54
Re: Bug in 'source code formatter (AStyle)'
« Reply #7 on: June 25, 2007, 02:32:23 pm »
Thx!

 :D