Pages: [1] 2   Go Down
Author Topic: Arduino Compiler doesn't compile a particular sketch.  (Read 3057 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 38
Don't eat yellow snow.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

I'm relatively new to everything here, but I've been spending a lot of time developing some sketches, and, until now, everything's been working fine.

For some reason the attached sketch cannot finish compiling. The little progress bar only gets to about 20%, and the compiler gives an error that starts with "Exception in thread "Thread-4256" java.lang.StackOverflowError", and is followed by hundreds of lines starting with "at java.util.regex.Pattern$".

It looks like this:
Exception in thread "Thread-4256" java.lang.StackOverflowError
   at java.util.regex.Pattern$CharProperty.match(Pattern.java:3344)
   at java.util.regex.Pattern$Branch.match(Pattern.java:4114)
   at java.util.regex.Pattern$GroupHead.match(Pattern.java:4168)
   at java.util.regex.Pattern$Loop.match(Pattern.java:4295)
   at java.util.regex.Pattern$GroupTail.match(Pattern.java:4227)
   at java.util.regex.Pattern$BranchConn.match(Pattern.java:4078)
   at java.util.regex.Pattern$CharProperty.match(Pattern.java:3345)
   at java.util.regex.Pattern$Branch.match(Pattern.java:4114)
   at java.util.regex.Pattern$GroupHead.match(Pattern.java:4168)
   at java.util.regex.Pattern$Loop.match(Pattern.java:4295)
... and it goes on and on and.

Please take a look and see if I'm missing something. I lack experience smiley-fat
Please note: a lot of the code is copied from previous sketches.
Oh, and it's still a work in progress, not a polished piece of machinery

Thanks, and forgive the newbie tendencies smiley-razz

* RemoteCallLogger_v1e0.ino (12.44 KB - downloaded 34 times.)
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nicely written code.

The compiler barfs here too, in the same way.  Smells like an interesting bug.

I think it would be a good thing to open an issue at:

    https://github.com/arduino/Arduino/issues

-br
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 38
Don't eat yellow snow.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Cool, I'll do that.
Thanks
Logged

0
Offline Offline
Shannon Member
****
Karma: 130
Posts: 10454
:(){:|:&};:
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

as written in the issue, the IDE bug is triggered by a code bug in the two line:
Code:
#include // required to send and receive AT commands from the GPRS Shield
#include // required for I2C communication with the RTC

those include are just wrong

edit: removing include doesn't solve the problem. possible duplicate: http://code.google.com/p/arduino/issues/detail?id=962
« Last Edit: January 25, 2013, 08:26:16 am by lesto » Logged

sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hold on a minute.  The includes are not wrong in the attachment to this forum thread.  They _look_ wrong in the github issue because they contain angle brackets which github markdown doesn't like.

If you re-test using the code enclosure above I believe you will see some of the most unusual output you've ever seen come out of the IDE.  At least it was for me.

Best,

-br


Logged

0
Offline Offline
Shannon Member
****
Karma: 130
Posts: 10454
:(){:|:&};:
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i think the error is in the process where that .ino is secretly translated into a .cpp adding some code (main etc..), but your (and others) code break some regex somewhere... also the stack is unuseful to anderstand where this happen, so i'm downloading arduino's source, adding a lot of system.out.println("until here all good"); and find out where this happen, and work out a solution.  But i'm at work and this weekend i'll have no time for this, so i hope to solve it soon.
Logged

sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Offline Offline
Newbie
*
Karma: 0
Posts: 38
Don't eat yellow snow.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, appreciate it smiley
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you comment out line 117, it compiles.

Something about this code:

Code:
  temp[ 25 ] = '\"';

You may be able to get going again by using a different means to assign the ascii quote character to temp[25]...

-br
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 38
Don't eat yellow snow.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, so I kind of started over, and compiled the sketch after every action I took, to check where the problem started. I didn't solve the mystery, but I might have learnt something new.

Before I can explain what exactly happened, the reader needs to understand how I'm structuring this program.

I have two separate sketches I copy from: one that contains all the code necessary for control over the onboard real time clock (RTC), and one containing all the code necessary for control over the GPRS Shield I'm using.

My main objective is to log the times the Shield receives calls, and use the Shield to send data via text message at a predetermined time.
For this I simply need to combine my two aforementioned sketches, and add a few bits and bobs.

So everything I'm doing kind of happens in two halves: GPRS and RTC.
For my own sanity's sake, I keep the two devices' code separate.

Also, the function gprsListen() is the only GPRS function called directly from void loop(), and it's location actually made a difference, see below.

In the first sketch I attached, the order of all the parts were as follows:
  includes for both devices
  #defines for RTC
  variable declarations for GPRS
  variable declarations for RTC
  GPRS functions (including the function gprsListen)
  RTC functions
  setup
  loop (calls the gprsListen() function and updates the time)

The above structure made the compiler go all stupid. Now for the new structure (attached file):
  #includes for both devices
  #defines for RTC
  variable declarations for GPRS
  variable declarations for RTC
  RTC functions
  GPRS functions
  setup
  loop (calls the gprsListen() function and updates the time)
  gprsListen()

Ok, so there are 2 major changes, and 1 very weird thing:
  change 1: I had to swap the GPRS and RTC function bundles
  change 2: I had to put the gprsListen() function somewhere below setup. Anywhere above setup, and the compiler goes all stupid again.
  Very weird thing: In void setup() there is a Serial.println(""); indicated with a comment. If you comment it out, the sketch still compiles. If you delete the command, or only the quotes, the compiler goes all stupid with the same error.

Remember, effectively there is almost no difference between the sketches. They contain all the same functions and variables, I just pasted them in different places.

I don't know what any of this means, maybe you guys do.
Thanks so far

* RemoteCallLoggerV0.ino (12.76 KB - downloaded 16 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 38
Don't eat yellow snow.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks billroy
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 38
Don't eat yellow snow.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So in the original sketch I changed " temp[ 25 ] = '\"'; " to " temp[ 25 ] = char(34); "
It compiles now, and should work, but I'd still like to know what the problem was (is?). Technically there is nothing wrong with the way it was.
Logged

0
Offline Offline
Shannon Member
****
Karma: 130
Posts: 10454
:(){:|:&};:
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i think the error is in the process where that .ino is secretly translated into a .cpp adding some code (main etc..), but your (and others) code break some regex somewhere... also the stack is unuseful to anderstand where this happen, so i'm downloading arduino's source, adding a lot of system.out.println("until here all good"); and find out where this happen, and work out a solution.  But i'm at work and this weekend i'll have no time for this, so i hope to solve it soon.

i've spoken smiley-razz, we will see.
btw if you don't know what is a regex: http://en.wikipedia.org/wiki/Regular_expression
Logged

sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48569
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The \" construct is not how to embed a double quote in a string. You use two double quotes, instead. On line 117, using '\"' to describe what to store in the array element is wrong. It should be '"' (a single quote, a double quote, and a single quote). One line 114, the \" needs to be changed to "" (Two double quotes). That will result in the line ending with three double quotes and a semicolon. Then, the code compiles.

There is no bug that needs to be dealt with in the IDE.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 38
Don't eat yellow snow.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, I understand now. The only thing that puzzles me is that I copied the code from another sketch, and that sketch worked just fine. I'll go read up on this stuff on my own time. Thanks everybody smiley
Logged

0
Offline Offline
Shannon Member
****
Karma: 130
Posts: 10454
:(){:|:&};:
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The \" construct is not how to embed a double quote in a string. You use two double quotes, instead. On line 117, using '\"' to describe what to store in the array element is wrong. It should be '"' (a single quote, a double quote, and a single quote). One line 114, the \" needs to be changed to "" (Two double quotes). That will result in the line ending with three double quotes and a semicolon. Then, the code compiles.

There is no bug that needs to be dealt with in the IDE.

Code:
#include <stdio.h>

int main(void *args[]){
  char c= '\"';
  printf("%c", c);
  c='"';
  printf("%c", c);
  return 0;
}

work perfectly with gcc (GCC) 4.7.2 .
Also this is a STACK OVERFLOW from java, not an error or a warning from the compiler. So the IDE is broken, it is not a big problem because it can be worked-around, but there still a big fault in the IDE; also this bug is duplicate: http://code.google.com/p/arduino/issues/detail?id=962
Code:
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";

as you see this IS a bug, as the multiline is legitimate.

I don't say that the ide/compiler should permit this, but at least give a good error and not a "stack overflow"
Logged

sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Pages: [1] 2   Go Up
Jump to: