{"action":"created","issue":{"url":"https://api.github.com/repos/esp8266/Arduino/issues/2181","repository_url":"https://api.github.com/repos/esp8266/Arduino","labels_url":"https://api.github.com/repos/esp8266/Arduino/issues/2181/labels{/name}","comments_url":"https://api.github.com/repos/esp8266/Arduino/issues/2181/comments","events_url":"https://api.github.com/repos/esp8266/Arduino/issues/2181/events","html_url":"https://github.com/esp8266/Arduino/issues/2181","id":161808258,"number":2181,"title":"WifiClient.connect() crashes when connect fails and  in the mean time an io interrupt occured.","user":{"login":"pgScorpio","id":9221087,"avatar_url":"https://avatars.githubusercontent.com/u/9221087?v=3","gravatar_id":"","url":"https://api.github.com/users/pgScorpio","html_url":"https://github.com/pgScorpio","followers_url":"https://api.github.com/users/pgScorpio/followers","following_url":"https://api.github.com/users/pgScorpio/following{/other_user}","gists_url":"https://api.github.com/users/pgScorpio/gists{/gist_id}","starred_url":"https://api.github.com/users/pgScorpio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgScorpio/subscriptions","organizations_url":"https://api.github.com/users/pgScorpio/orgs","repos_url":"https://api.github.com/users/pgScorpio/repos","events_url":"https://api.github.com/users/pgScorpio/events{/privacy}","received_events_url":"https://api.github.com/users/pgScorpio/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/esp8266/Arduino/labels/type:%20troubleshooting","name":"type: troubleshooting","color":"bfdadc"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2016-06-22T23:18:49Z","updated_at":"2016-06-26T19:47:56Z","closed_at":null,"body":"### Basic Infos\r\n\r\n#### Hardware\r\nHardware:\t\t\tESP-12\r\nCore Version:      \t2.2.0\r\n\r\n### Description\r\n\r\nProblem description\r\n\r\n1: An io interrupt handler is attached to an io pin, (in my case RcSwitch, but any io interrupt on any pin causes the same problem) \r\n\r\n2: Trying to connect a WiFiClient to a non existing server (server is unreachable/off-line)\r\n\r\nProblem: \r\nIf during the connect attemp any io interrupt(s) occur the esp crashes at the moment the connect attempt times-out.\r\n\r\n```\r\nFatal exception 0(IllegalInstructionCause):\r\nepc1=0x40216b74, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000\r\n\r\nException (0):\r\nepc1=0x40216b74 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000\r\n\r\nctx: sys \r\nsp: 3ffffc10 end: 3fffffb0 offset: 01a0\r\n```\r\n\r\nepc1=0x40216b74 ==> Is digitalRead (called from io interrupt).\r\n\r\n(I did not yet check if any other interrupts, like a timer, causes the same problem, but what i noticed is that it always crashes on a digitalRead called from the interrupt.)\r\n\r\n\r\nAnd also when the connect is succesfull it doesn't crash (but in this case the time interval is much shorter and so the change of having an interrupt during the connect is also smaller..., but even with a remote pressed during successful connecting, interrupting almost ten thousand times a second, I couldn't get it to crash... )\r\n\r\n```\r\n   if (_client.connect(host.c_str(), hostPort)) //crashes when interrupted AND connect fails....\r\n   {\r\n   }\r\n\r\n```\r\n\r\nWhen during the connect attempt IO interrupts are disabled it won't crash...\r\n\r\n```\r\nETS_GPIO_INTR_DISABLE();\r\n    _client.connect(host.c_str(), hostPort);    //no crash.\r\nETS_GPIO_INTR_ENABLE();\r\n   if (_client.connected())\r\n   {\r\n   }\r\n\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/esp8266/Arduino/issues/comments/228618858","html_url":"https://github.com/esp8266/Arduino/issues/2181#issuecomment-228618858","issue_url":"https://api.github.com/repos/esp8266/Arduino/issues/2181","id":228618858,"user":{"login":"pgScorpio","id":9221087,"avatar_url":"https://avatars.githubusercontent.com/u/9221087?v=3","gravatar_id":"","url":"https://api.github.com/users/pgScorpio","html_url":"https://github.com/pgScorpio","followers_url":"https://api.github.com/users/pgScorpio/followers","following_url":"https://api.github.com/users/pgScorpio/following{/other_user}","gists_url":"https://api.github.com/users/pgScorpio/gists{/gist_id}","starred_url":"https://api.github.com/users/pgScorpio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgScorpio/subscriptions","organizations_url":"https://api.github.com/users/pgScorpio/orgs","repos_url":"https://api.github.com/users/pgScorpio/repos","events_url":"https://api.github.com/users/pgScorpio/events{/privacy}","received_events_url":"https://api.github.com/users/pgScorpio/received_events","type":"User","site_admin":false},"created_at":"2016-06-26T19:47:56Z","updated_at":"2016-06-26T19:47:56Z","body":"Sorry iggr, but that 'junk' in memory is **below** the current stackpointer and does not show in the stackdump ! What you see in the stackdump is what is currently pending. (return addresses and local function data). So, since the return address of the handler->fn() call in wiring_digital interrupt_handler (40106f44) is twice on stack, and I even recognise my interruptHandlers local data, recursive interrupt calls **are happening** in this case.\r\n\r\nAlso i don't agree on that a compiler may ignore inline, unless you tell it explicitly to ignore or optimize inlining  and in the last case it should only change inline code to functions if 1: the inline code is substantial and 2: it is called multiple times. Both are not the case here....\r\nThe ignore is apparently also not the case since some inlines are actual inlined....\r\nSo it could be that optimization is enabled (-Os),  but in this case the compiler does not do a great job since creating a function just to call a function makes no sense, it generates **more** code....\r\nMoreover it generates and calls a function in FLASH while both caller and callee are in RAM !\r\nAnd if I look at the sizes of the functions I even get the idea it generates a FLASH **copy** of digitalRead instead of just calling it. (getIput is 0x35 bytes, digitalRead is 0x34 bytes, just a call would be far less bytes)\r\n\r\n\r\n\r\nAnyway I will try __attribute__((always_inline))....\r\n\r\nThanks for your advice,\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"pgScorpio"}}