code8825 / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

Stack overflow error compiling code with backslashes, Linux and Windows only #962

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Compile program in forum thread: 
http://arduino.cc/forum/index.php/topic,111262
2. Note, code has a long char string continued over multiple lines with 
backslashes at the end of each line

What is the expected output? What do you see instead?

I expect a clean compile.

I get:

Exception in thread "Thread-3" java.lang.StackOverflowError
    at java.util.regex.Pattern$Loop.match(Pattern.java:4312)
    at java.util.regex.Pattern$GroupTail.match(Pattern.java:4244)
    at java.util.regex.Pattern$BranchConn.match(Pattern.java:4095)
    at java.util.regex.Pattern$CharProperty.match(Pattern.java:3362)
    at java.util.regex.Pattern$Branch.match(Pattern.java:4131)
    at java.util.regex.Pattern$GroupHead.match(Pattern.java:4185)
    at java.util.regex.Pattern$Loop.match(Pattern.java:4312)
    at java.util.regex.Pattern$GroupTail.match(Pattern.java:4244)
    at java.util.regex.Pattern$BranchConn.match(Pattern.java:4095)
    at java.util.regex.Pattern$CharProperty.match(Pattern.java:3362)
    at java.util.regex.Pattern$Branch.match(Pattern.java:4131)
    at java.util.regex.Pattern$GroupHead.match(Pattern.java:4185)
    at java.util.regex.Pattern$Loop.match(Pattern.java:4312)
    at java.util.regex.Pattern$GroupTail.match(Pattern.java:4244)
    at java.util.regex.Pattern$BranchConn.match(Pattern.java:4095)
    at java.util.regex.Pattern$CharProperty.match(Pattern.java:3362)
...

What version of the Arduino software are you using? On what operating
system?  Which Arduino board are you using?

Version 1.0.1 on Ubuntu.
Version 1.0 on Windows.
Version 1.0.1 on OS/X.  

The error does not occur on OS/X.

Board: Uno

Please provide any additional information below.

Problem part of code:

const char progdata[] PROGMEM = 
":100000000EC015C014C013C012C011C010C00FC064\
:100010000EC00DC00CC00BC00AC009C008C011241E\
:100020001FBECFE5D2E0DEBFCDBF02D02AC0E8CFF1\
:100030000F931F93DF93CF9300D0CDB7DEB787E345\
:1000400090E021E0FC01208388E390E021E0FC01C6\
:10005000208388E390E028E330E0F901308121E05B\
:100060002327FC0120838FEF9FEF9A838983898167\
:100070009A818C01C8010197F1F78C011A830983D9\
:06008000E8CFF894FFCF69\
:00000001FF";

Fixed by changing to:

const char progdata[] PROGMEM = 
":100000000EC015C014C013C012C011C010C00FC064"
":100010000EC00DC00CC00BC00AC009C008C011241E"
":100020001FBECFE5D2E0DEBFCDBF02D02AC0E8CFF1"
":100030000F931F93DF93CF9300D0CDB7DEB787E345"
":1000400090E021E0FC01208388E390E021E0FC01C6"
":10005000208388E390E028E330E0F901308121E05B"
":100060002327FC0120838FEF9FEF9A838983898167"
":100070009A818C01C8010197F1F78C011A830983D9"
":06008000E8CFF894FFCF69"
":00000001FF";

Original issue reported on code.google.com by n...@gammon.com.au on 23 Jun 2012 at 10:59

GoogleCodeExporter commented 9 years ago
Hi I'm the one having the problem, I tried to isolate the issue, but a sketch 
with ONLY this string in it does compile OK. The error must be a combination of 
the progdata string and the rest of the sketch as shown in the forum.

this compiles OK :
const char progdata[] PROGMEM = 
":100000000EC015C014C013C012C011C010C00FC064\
:100010000EC00DC00CC00BC00AC009C008C011241E\
:100020001FBECFE5D2E0DEBFCDBF02D02AC0E8CFF1\
:100030000F931F93DF93CF9300D0CDB7DEB787E345\
:1000400090E021E0FC01208388E390E021E0FC01C6\
:10005000208388E390E028E330E0F901308121E05B\
:100060002327FC0120838FEF9FEF9A838983898167\
:100070009A818C01C8010197F1F78C011A830983D9\
:06008000E8CFF894FFCF69\
:00000001FF";

void setup () {
}

void loop () {
}

please note that apart from this specific issue I wanted to draw attention to 
the fact that the preprocessor output in case of a regex error is *not* 
helpful, please consider improving that output with an indication of the bit of 
data (or line number) the regex complains about. 

Original comment by raa...@gmail.com on 24 Jun 2012 at 9:34

GoogleCodeExporter commented 9 years ago
I have found this can occur if I forget to end a string correctly.

// EXAMPLE:
Serial.print("This string is missing the closing quotation);

Thus the rest of the code becomes a massive string, overfilling the maximum 
string size for the compiler.

Original comment by Finchron...@gmail.com on 16 Mar 2013 at 1:59

GoogleCodeExporter commented 9 years ago
To: #2 Finchron, Thank You for your IP, as you stated (and it was true for me 
too), that a String was not structured properly.  The program would not 
compile, even though it had many times previously.  I must of bumped the 
keyboard or something because a whole section was messed up.

Original comment by 4johnl...@gmail.com on 13 May 2014 at 4:29

GoogleCodeExporter commented 9 years ago
Please give a try to the IDEs linked at the bottom of this email on the dev list
https://groups.google.com/a/arduino.cc/forum/#!msg/developers/4X2T3rCxXWM/YNJl6P
ZuDucJ
We're testing a new preprocessor and it compiles that sketch just fine.

Original comment by federico...@gmail.com on 28 Jan 2015 at 4:12

GoogleCodeExporter commented 9 years ago
New preprocessor tracked at https://github.com/arduino/Arduino/pull/2636. 
Builds for testing it are available

Original comment by federico...@gmail.com on 13 Feb 2015 at 6:48

GoogleCodeExporter commented 9 years ago

Original comment by federico...@gmail.com on 26 May 2015 at 3:27