polling tcp socket leads to Fatal exception 28(LoadProhibitedCause) on v1.10-23-g1fa8f977f

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
jmi2
Posts: 21
Joined: Mon Oct 01, 2018 9:31 pm

polling tcp socket leads to Fatal exception 28(LoadProhibitedCause) on v1.10-23-g1fa8f977f

Post by jmi2 » Tue Jan 29, 2019 1:16 pm

Hi,

following tcp server leads to Fatal exception 28 on esp8266:

Code: Select all

import uselect # same with select
import usocket # same with socket
import time

time.sleep(5) # dirty wait to get wifi connection (as station)

server_address = usocket.getaddrinfo('0.0.0.0', 80)[0][-1]
server = usocket.socket()
server.bind(server_address)
server.listen(1) # same with 0

poller = uselect.poll()
poller.register(server, uselect.POLLIN)

events = poller.poll(0) # same with ipoll, or with -1 or 100 args
It fails on events = poller.poll(0).
Tried several adaptations as noted in comment, nothing helped.
Came out of ideas. Do you have any?
thanks

Code: Select all

OSError: [Errno 2] ENOENT

MicroPython v1.10-23-g1fa8f977f on 2019-01-28; ESP module with ESP8266
Type "help()" for more information.
>>> scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 1
cnt

connected with jmi-svetla2, channel 13
dhcp client start...
ip:10.99.0.25,mask:255.255.255.0,gw:10.99.0.1

>>> pm open,type:2 0

paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== import uselect # same with select
=== import usocket # same with socket
=== import time
===
=== time.sleep(5) # dirty wait to get wifi connection (as station)
===
=== server_address = usocket.getaddrinfo('0.0.0.0', 80)[0][-1]
=== server = usocket.socket()
=== server.bind(server_address)
=== server.listen(1) # same with 0
===
=== poller = uselect.poll()
=== poller.register(server, uselect.POLLIN)
===
=== events = poller.poll(0) # same with ipoll, or with -1 or 100 args
===
Fatal exception 28(LoadProhibitedCause):
epc1=0x40266000, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000

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

load 0x40100000, len 30964, room 16
tail 4
chksum 0x23
load 0x3ffe8000, len 1080, room 4
tail 4
chksum 0x8a
load 0x3ffe8440, len 808, room 4
tail 4
chksum 0xee
csum 0xee
FW looks fine

Code: Select all

import esp
>>> esp.check_fw()
size: 587620
md5: 58d3cf2c75e069af579179f26e261c90
True
Last edited by jmi2 on Thu Jan 31, 2019 7:34 am, edited 1 time in total.

jmi2
Posts: 21
Joined: Mon Oct 01, 2018 9:31 pm

Re: polling tcp socket leads to Fatal exception 28(LoadProhibitedCause) on v1.10-23-g1fa8f977f

Post by jmi2 » Tue Jan 29, 2019 1:54 pm

with stable version v1.10-8-g8b7039d7d it's also error:

Code: Select all

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

load 0x40100000, len 31020, room 16
tail 12
chksum 0xd2
ho 0 tail 12 room 4
load 0x3ffe8000, len 1100, room 12
tail 0
chksum 0x9a
load 0x3ffe8450, len 824, room 8
tail 0
chksum 0xbd
csum 0xbd

jmi2
Posts: 21
Joined: Mon Oct 01, 2018 9:31 pm

Re: polling tcp socket leads to Fatal exception 28(LoadProhibitedCause) on v1.10-23-g1fa8f977f

Post by jmi2 » Tue Jan 29, 2019 2:29 pm

tested with few more version:

v1.9.4-762-gfa50047bb -> fatal exception 28(LoadProhibitedCause)

v1.9.4-272-g46091b8a on 2018-07-18 -> OK

v1.9.4-8-ga9a3caad0 on 2018-05-11 -> OK

jmi2
Posts: 21
Joined: Mon Oct 01, 2018 9:31 pm

Re: polling tcp socket leads to Fatal exception 28(LoadProhibitedCause) on v1.10-23-g1fa8f977f

Post by jmi2 » Tue Sep 27, 2022 8:35 pm

i came back to micropython and tried to find FW, which works ... and came back also to this issue.

I just found it crashes even with latest esp8266 fw v1.10-45-g67689bfd7
https://micropython.org/resources/firmw ... 1.19.1.bin

but found a reason/"workaround"

Difference is, if i do
server.listen(1)
or
server.listen(2)

where 0 and 1 lead to "Fatal exception 28(LoadProhibitedCause)" ...
while 2+ are working fine.

... could someone perhaps confirm, i'm not doing anything stupid and this is a real bug to be reported?

todays test code (simple extract):

Code: Select all

import select
import socket
import network
import gc
from machine import Timer
import time

sta_if = network.WLAN(network.STA_IF);
sta_if.active(True);
sta_if.connect("xxxx", "xxx"); # provide your credentials

while not sta_if.isconnected():
    print(".", end="")
    time.sleep(1)

print('')
print('Network config:', sta_if.ifconfig())    
    

# Create a TCP/IP socket
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setblocking(0)

# Bind the socket to the port
server_address = ('', 80)
print('starting up on %s port %s' % server_address)
server.bind(server_address)

# Listen for incoming connections
server.listen(1) # Crashes with 0 or 1 ..... but works with 2+

# Commonly used flag setes
READ_ONLY = select.POLLIN | select.POLLHUP | select.POLLERR 

# Set up the poller
poller = select.poll()
poller.register(server, READ_ONLY)

events = poller.poll(100) # here it fails
tested some other FWs with esp8266 and different argumet for server.listen(...) call:
# v1.9.4-8-ga9a3caad0 on 2018-05-11; - works with 0, 1, 2
# v1.9.4-272-g46091b8a - works with 0, 1, 2
# v1.9.4-762-gfa50047bb (2018-12-29) - crashes on 0, 1 and works with 2

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: polling tcp socket leads to Fatal exception 28(LoadProhibitedCause) on v1.10-23-g1fa8f977f

Post by scruss » Wed Sep 28, 2022 12:09 am

dev team have moved to github discussions, there's nobody here

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: polling tcp socket leads to Fatal exception 28(LoadProhibitedCause) on v1.10-23-g1fa8f977f

Post by jimmo » Wed Sep 28, 2022 10:15 am

Can you raise this as a bug over at https://github.com/micropython/micropyt ... new/choose? Looks like you have a pretty clear and minimal repro, and it definitely should not cause a hard crash like this.

jmi2
Posts: 21
Joined: Mon Oct 01, 2018 9:31 pm

Re: polling tcp socket leads to Fatal exception 28(LoadProhibitedCause) on v1.10-23-g1fa8f977f

Post by jmi2 » Wed Sep 28, 2022 1:26 pm

While writing bug report i realized it works. As i see in my previous post, i have inconsistent version and firmware link ...probably i messed up a test boards.

Seems it works again with 1.19.1 https://micropython.org/resources/firmw ... 1.19.1.bin

Actually already with v1.11-8-g48dcbbe60 https://micropython.org/resources/firmw ... -v1.11.bin it started to work.

with 1.10 it's crashing.

Just for documentation:

Code: Select all

# v1.9.4-8-ga9a3caad0 on 2018-05-11; - works with 0, 1, 2
# v1.9.4-272-g46091b8a  - works with 0, 1, 2
# v1.9.4-762-gfa50047bb (2018-12-29) - crashes with 0, 1 and works with 2
# MicroPython v1.10-8-g8b7039d7d on 2019-01-26 - crashes with 1 (0 not tested)
# MicroPython v1.10-45-g67689bfd7 on 2019-02-01; ESP module with ESP8266 ---- crashes with 0 (1 not tested)
# MicroPython v1.11-8-g48dcbbe60 on 2019-05-29; WORKS AGAIN with 0 and 1
# MicroPython v1.19.1 on 2022-06-18; WORKS AGAIN with 0 and 2
thank you.

Post Reply