-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Does ESP8266WebServer and ESP8266WiFi now require non32xfer to be enabled? #7928
Comments
@blue-wind-25 Thanks for reporting ! |
@d-a-v You are welcome! Yes, #7935 fix the exception 3 problem. However, it seems that secure web server still does not work properly. It does enter the on() handler because I can see my debugging message on the UART, however By my observation, the new ESP8266WiFi library also use the new Stream, so I do not think the problem is in the new Stream anymore because if I use the old ESP8266WebServer library (with the new ESP8266WiFi and #7935), secure web server works. On the other hand, if I use only the new ESP8266WebServer (or both the new ESP8266WebServer and the new ESP8266WiFi), SSL does not work. Maybe somehow the timeout mechanism has changed and does not work with SSL? About:
As far as I know the PGM function can be used both to read from RAM and flash because ESP8266 flash and RAM are in one address space, the difference is that reading from flash must be 32-bit alligned. So, how much overhead does the PGM function when used for reading for RAM? If it is negligible, then I guess always using pgm_read_byte() will be fine. I'll try to help finding why the new ESP8266WebServer does not work with SSL. However, because I customized the core and the whole build system, I may not be able to produce MCVE that will compile using Arduino. But I will update my customized web sever library bit by bit to follow the Arduino GIT, maybe I can find which function that cause SSL to block. Thank you for your help. |
@d-a-v I found another bug. In library ESP8266WiFi In line 534 there is Then in line 549 When I handle the form for POST request and then using In my case, I can do something like this to fix:
Of course this line must be commented-out: But I am not sure if doing that is a good idea because we are allocating and deallocating memory for every function call. |
Hello, I have an additional information. The problem with SSL seems originating from I still not able to find which function actually block SSL, however, I does get WDT reset the last time (using my modified code not Arduino). I will try to narrow down the problem tomorrow. |
@d-a-v I think the error is not inside ESP8266WebServer-impl.h. After some tracing, I found that for secure web server, in StreamSend.cpp, in function The reason is because in WiFiClient.cpp, function However if I change the content of
All work fine. This does not make sense, until I found out that I think might has something to do with how browser negotiate SSL which cause
thinks that no more data can be written because Commenting-out the block above also does not work because I think when inside It become make sense because SSL handshake is somehow got completed in I tried to add |
@blue-wind-25 I'll check on your other reports, there are interesting insights, thanks for digging this up ! |
@d-a-v No problem, you are welcome! Yes, now secure web server works in my case. Thank you! |
Reopening because of @blue-wind-25 's findings in ClientContext and flash/iram input Stream |
Note: copied from my comment in #6979 as per @earlephilhower suggestion.
Hello, I would like to confirm my founding. It seems that the updated ESP8266WebServer (and maybe ESP8266WiFi) relies on the non32xfer service because:
template <typename ServerType>
void ESP8266WebServerTemplate<ServerType>::send_P(int code, PGM_P content_type, PGM_P content) {
StreamConstPtr ref(content, strlen_P(content));
return send(code, String(content_type).c_str(), &ref);
}
Then, because
PGM_P
isconst char*
then this CTOR will be called:StreamConstPtr(const char* buffer, size_t size)
: _buffer(buffer), _size(size), _byteAddressable(__byteAddressable(buffer)) { }
which mean that the buffer will be read using non PGM method.
Also, there is another CTOR:
StreamConstPtr(const __FlashStringHelper* text)
: _buffer(reinterpret_cast<const char*>(text)), _size(strlen_P((PGM_P)text)), _byteAddressable(false) { }
It casts
__FlashStringHelper
toconst char*
. Whilestrln_P()
is correctly called, the buffer will be read using non PGM method.Then
pgmspace.h
still definesPSTR
as:#ifndef PSTRN
#define PSTRN(s,n) (__extension__({static const char __pstr__[] __attribute__((__aligned__(n))) __attribute__((section( "\".irom0.pstr." __FILE__ "." __STRINGIZE(__LINE__) "." __STRINGIZE(__COUNTER__) "\", \"aSM\", @progbits, 1 #"))) = (s); &__pstr__[0];}))
#endif
#ifndef PSTR
#define PSTR(s) PSTRN(s,PSTR_ALIGN)
#endif
So it seems that PSTR strings still need to be accessed using the
_P()
functions.I found that if I do not enable/include the non32xfer service then calls to web server
send_P()
will cause exception 3 (EXCCAUSE_LOAD_STORE_ERROR) inside the Arduino String class when copying the characters.It seems also the case for SSL web server (even with non32xfer enabled, my SSL web server failed to send anything to the browser despite it does not cause exception 3). I am still unsure why this behavior with SSL happened.
I want to ask if this was by design (non32xfer must be enabled/included)?
I need to inform you that until at least the new official Arduino package is released, I will not be able to produce a test sketch because like I said to @earlephilhower in my other discussion, I do not use the Arduino build system.
Because I also follow updates from Arduino ESP8266 GIT and then modify the cores a bit to match my need and style, my application code will not compile using Arduino's original core. Therefore, I am also not sure if my comment about this is actually valid when using the original core and Arduino IDE. Thank you!
The text was updated successfully, but these errors were encountered: