buglwIP - A Lightweight TCP/IP stack - Bugs: bug #59182, Fresh socket does not raise...


You are not allowed to post comments on this tracker with your current authentication level.

bug #59182: Fresh socket does not raise ENOTCONN

Submitter:  Gisle Vanem <gvanem>
Submitted:  Sat 26 Sep 2020 07:50:22 AM UTC
Category:  sockets/netconn Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
lwIP version:  git head

Sat 26 Sep 2020 07:50:22 AM UTC, original submission:  

I have patched MicroPython [1] with LwIP support on Windows.
And running some tcp/ip related test shows a funny behaviour in LwIP.
E.g. from:

  # recv() on a fresh socket should raise ENOTCONN
  s = socket.socket()
  except OSError as er:

    print("ENOTCONN:", er.args[0] == errno.ENOTCONN)

The trace in LwIP shows:
  src/api/sockets.c(1754): lwip_socket(PF_INET, SOCK_STREAM, 0) = 0
  src/api/sockets.c(1243): lwip_recvfrom(0, 0E88A030, 1, 0x0, ..)
  src/api/sockets.c(976): lwip_recv_tcp: top while sock->lastdata=00000000

Now the MicroPython test hangs forever. Nothing happens
with this socket 0. It's unconnected, so how could this socket
ever receive a single byte?

Using the same .py-test in the real CPython 3.6, it immediately
returns the expected:
  py -3 extmod\usocket_tcp_basic.py

Also not that the sock-fd == 0. Rebuilding LwIP with:

to force a sock-fd to start at 100, does not make any change
to the hang.

[1] https://github.com/micropython/micropython

Gisle Vanem <gvanem>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by gvanem (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.


    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-ee12.
    Corresponding source code