Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add errors on invalid/missing function return #5321

Closed
wants to merge 1 commit into from

Conversation

dok-net
Copy link
Contributor

@dok-net dok-net commented Jun 24, 2021

Adaptation of esp8266/Arduino#8165 for the ESP32.
@me-no-dev Please inform me of how to handle the Platformio related files properly.

@me-no-dev
Copy link
Member

best to ask platformio guys :) @ivankravets @valeros

@valeros
Copy link
Contributor

valeros commented Jun 24, 2021

Hi @dok-net, simply add it to CCFLAGS in all three build scripts:

@dok-net
Copy link
Contributor Author

dok-net commented Jun 24, 2021

@valeros, that's funny, because in #5310 @me-no-dev opined about patches to tools/platformio-build-esp32.py etc. that

all of the changes that you have made are to files that are auto generated by the lib builder. They will not stick. The lib builder get's the flags from IDF's compile process.

and

The proper way to do something like that is to have it configured at build time of the IDF libs in the lib-builder repo, so that when it builds IDF, it will do it with those same flags, which will then carry over to here :)

But I don't know anything about that. With definitive guidance I would love to go ahead.

@me-no-dev
Copy link
Member

@valeros flags are generated by the lib builder and as I explained to @dok-net , changes need to be done in the lib builder for them to work in arduino

@valeros
Copy link
Contributor

valeros commented Jun 25, 2021

TBH I'm not sure how we can help then, @dok-net please add that flag directly to the lib builder.

Copy link
Member

@igrr igrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not required until we update to GCC 10.x, is that correct?

@dok-net
Copy link
Contributor Author

dok-net commented Jul 17, 2021

@igrr No, that's not a correct conclusion. There is only a warning with the current compiler in master:

void setup() {
	Serial.begin(115200);
	while (!Serial) delay(500);
	Serial.println("noret");
}

int f() {
	Serial.println("f()");
}

void loop() {
	auto x = f();
}
noret.ino: 9:1: warning: no return statement in function returning non-void [-Wreturn-type]

But the generated code is undefined and crashes:

04:20:08:197 -> noret
f()
[...]
f()
04:20:08:337 -> f()
f()
f()
f()
f()
f()
f()
f()
f()
f()
f()
f()
f()
f()
f()
f()
f()
f()
f()
f()Guru Meditation Error: Core  1 panic'ed (Unhandled debug exception). 
Debug exception reason: Stack canary watchpoint triggered (loopTask) 
Core  1 register dump:
PC      : 0x40089b42  PS      : 0x00060936  A0      : 0x80089523  A1      : 0x3ffb08c0  
A2      : 0x3ffbee88  A3      : 0x00060923  A4      : 0x400d0f8c  A5      : 0xffffffff  
A6      : 0x00000001  A7      : 0x00000001  A8      : 0x800d0e62  A9      : 0x3ffb09e0  
A10     : 0x00000002  A11     : 0x3f401788  A12     : 0x00000002  A13     : 0x0000ff00  
A14     : 0x00ff0000  A15     : 0xff000000  SAR     : 0x00000009  EXCCAUSE: 0x00000001  
EXCVADDR: 0x00000000  LBEG    : 0x40085bf5  LEND    : 0x40085c05  LCOUNT  : 0xfffffffe  


Backtrace:0x40089b3f:0x3ffb08c00x40089520:0x3ffb0900 0x40087105:0x3ffb0920 0x40087632:0x3ffb0940 0x400d218a:0x3ffb0980 0x400d0f95:0x3ffb09a0 0x400d122f:0x3ffb09c0 0x400d0e59:0x3ffb09e0 0x400d0e5f:0x3ffb0a00 0x400d0e59:0x3ffb0a20 0x400d0e5f:0x3ffb0a40 0x400d0e59:0x3ffb0a60 0x400d0e5f:0x3ffb0a80 0x400d0e59:0x3ffb0aa0 0x400d0e5f:0x3ffb0ac0 0x400d0e59:0x3ffb0ae0 0x400d0e5f:0x3ffb0b00 0x400d0e59:0x3ffb0b20 0x400d0e5f:0x3ffb0b40 0x400d0e59:0x3ffb0b60 0x400d0e5f:0x3ffb0b80 0x400d0e59:0x3ffb0ba0 0x400d0e5f:0x3ffb0bc0 0x400d0e59:0x3ffb0be0 0x400d0e5f:0x3ffb0c00 0x400d0e59:0x3ffb0c20 0x400d0e5f:0x3ffb0c40 0x400d0e59:0x3ffb0c60 0x400d0e5f:0x3ffb0c80 0x400d0e59:0x3ffb0ca0 0x400d0e5f:0x3ffb0cc0 0x400d0e59:0x3ffb0ce0 0x400d0e5f:0x3ffb0d00 0x400d0e59:0x3ffb0d20 0x400d0e5f:0x3ffb0d40 0x400d0e59:0x3ffb0d60 0x400d0e5f:0x3ffb0d80 0x400d0e59:0x3ffb0da0 0x400d0e5f:0x3ffb0dc0 0x400d0e59:0x3ffb0de0 0x400d0e5f:0x3ffb0e00 0x400d0e59:0x3ffb0e20 0x400d0e5f:0x3ffb0e40 0x400d0e59:0x3ffb0e60 0x400d0e5f:0x3ffb0e80 0x400d0e59:0x3ffb0ea0 0x400d0e5f:0x3ffb0ec0 0x400d0e59:0x3ffb0ee0 0x400d0e5f:0x3ffb0f00 0x400d0e59:0x3ffb0f20 0x400d0e5f:0x3ffb0f40 0x400d0e59:0x3ffb0f60 0x400d0e5f:0x3ffb0f80 0x400d0e59:0x3ffb0fa0 0x400d0e5f:0x3ffb0fc0 0x400d0e59:0x3ffb0fe0 0x400d0e5f:0x3ffb1000 0x400d0e59:0x3ffb1020 0x400d0e5f:0x3ffb1040 0x400d0e59:0x3ffb1060 0x400d0e5f:0x3ffb1080 0x400d0e59:0x3ffb10a0 0x400d0e5f:0x3ffb10c0 0x400d0e59:0x3ffb10e0 0x400d0e5f:0x3ffb1100 0x400d0e59:0x3ffb1120 0x400d0e5f:0x3ffb1140 0x400d0e59:0x3ffb1160 0x400d0e5f:0x3ffb1180 0x400d0e59:0x3ffb11a0 0x400d0e5f:0x3ffb11c0 0x400d0e59:0x3ffb11e0 0x400d0e5f:0x3ffb1200 0x400d0e59:0x3ffb1220 0x400d0e5f:0x3ffb1240 0x400d0e59:0x3ffb1260 0x400d0e5f:0x3ffb1280 0x400d0e59:0x3ffb12a0 0x400d0e5f:0x3ffb12c0 0x400d0e59:0x3ffb12e0 0x400d0e5f:0x3ffb1300 0x400d0e59:0x3ffb1320 0x400d0e5f:0x3ffb1340 0x400d0e59:0x3ffb1360 0x400d0e5f:0x3ffb1380 0x400d0e59:0x3ffb13a0 0x400d0e5f:0x3ffb13c0 0x400d0e59:0x3ffb13e0 0x400d0e5f:0x3ffb1400 0x400d0e59:0x3ffb1420 0x400d0e5f:0x3ffb1440 0x400d0e59:0x3ffb1460 0x400d0e5f:0x3ffb1480 0x400d0e59:0x3ffb14a0 0x400d0e5f:0x3ffb14c0 0x400d0e59:0x3ffb14e0 0x400d0e5f:0x3ffb1500 0x400d0e59:0x3ffb1520 0x400d0e5f:0x3ffb1540 0x400d0e59:0x3ffb1560 0x400d0e5f:0x3ffb1580  |<-CONTINUES




ELF file SHA256: 0000000000000000

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1100
ho 0 tail 12 room 4
load:0x40078000,len:12752
load:0x40080400,len:3092
entry 0x400805e4

@dok-net
Copy link
Contributor Author

dok-net commented Jul 17, 2021

No matter what, this PR doesn't fix the underlying issue, the chance alone is not relevant to the build process as it stands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants