Skip to content

Problem with int function which doesn't return a value  #8421

Closed
@thierry7100

Description

@thierry7100

----------------------------- Delete below -----------------------------

If your issue is a general question, starts similar to "How do I..", is related to 3rd party libs, or is related to hardware, please discuss at a community forum like esp8266.com.

INSTRUCTIONS

If you do not follow these instructions, your issue may be dismissed.

  1. Follow the checklist under Basic Infos and fill in the [ ] spaces with an X.
  2. Fill in all the fields under Platform and Settings in IDE marked with [ ] (pick the correct option for you in each case, delete the others).
  3. If you haven't already done so, test your issue against current master branch (aka latest git), because it may have been already fixed.
  4. Describe your problem.
  5. If you have a STACK DUMP decode it:

https://arduino-esp8266.readthedocs.io/en/latest/Troubleshooting/stack_dump.html

  1. Include a Minimal Complete Reproducible Example sketch that shows your issue. Do not include your entire project, or a huge piece of code.
  2. Include debug messages:

https://arduino-esp8266.readthedocs.io/en/latest/Troubleshooting/debugging.html

  1. Use markup (buttons above) and the Preview tab to check what the issue will look like.
  2. Delete these instructions from the above to the below marker lines before submitting this issue.

----------------------------- Delete above -----------------------------

Basic Infos

  • [ X] This issue complies with the issue POLICY doc.
  • [ ]X I have read the documentation at readthedocs and the issue is not addressed there.
  • [ X] I have tested that the issue is present in current master branch (aka latest git).
  • [ X] I have searched the issue tracker for a similar issue.
  • [ X] If there is a stack dump, I have decoded it.
  • [ X] I have filled out all fields below.

Platform

  • Hardware: [ESP-12]
  • Core Version: [3.0.2]
  • Development Env: [Arduino IDE]
  • Operating System: [Ubuntu]

Settings in IDE

  • Module: [Wemos D1 mini r2]
  • Flash Mode: [?]
  • Flash Size: [4MB]
  • lwip Variant: [v2 Lower Memory]
  • Reset Method: [nodemcu]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [80Mhz]
  • Upload Using: [SERIAL]
  • Upload Speed: [115200] (serial upload only)

Problem Description

I have build a function returning an int but I forgot to return a value. This error is NOT detected by the IDE and worse the function doesn't not exist properly. In fact, the function doesn't exit and resume the loop (see below)

In the simple example provided, I got an exception, but in the complete program, nothing at all, the loop doesn't stop running after the limit was reached without error on the console.

MCVE Sketch

int TestFunction()
{
long int val = 1;
for ( int r = 0; r < 10; r++ )
{
for ( int c = 0; c < 10; c++)
{
val = val + 5;
}
}
}

void setup() {

Serial.begin(115200);
delay(500);
Serial.println("Starting and calling TestFunction");
TestFunction();
Serial.println("Done.\n");

}

void loop() {
// put your main code here, to run repeatedly:

}

Debug Messages

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3460, room 16
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4
tail 4
chksum 0xc9
csum 0xc9
v00042760
~ld

SDK:2.2.2-dev(38a443e)/Core:3.0.2=30002000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-48-g7421258/BearSSL:6105635
Starting and calling TestFunction
Fatal exception 9(LoadStoreAlignmentCause):
epc1=0x40201050, epc2=0x00000000, epc3=0x00000000, excvaddr=0x0000003b, depc=0x00000000

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (9):
epc1=0x40201050 epc2=0x00000000 epc3=0x00000000 excvaddr=0x0000003b depc=0x00000000

stack>>>

ctx: cont
sp: 3ffffe00 end: 3fffffc0 offset: 0190
3fffff90: 3fffdad0 00000000 3ffee568 40201050
3fffffa0: feefeffe feefeffe 3ffee5bc 40201cb4
3fffffb0: feefeffe feefeffe 3ffe85d8 40100ea9
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions