The scenario is pretty simple:
- application opens socket0 and connects to the registration server
- application sends an auth message (1Kb or so)
- registration server replies with an ip:port of a data server
- application closes socket0
- application opens socket1 and connects to the data server
- application sends data
- TCP stack crashes.
It happened that the app was (erroneously) configured with just 10 network buffers. The connect at step 5 failed with a timeout (errno 60), and a wrapping routine returned INVALID_SOCKET. A caller didn't test the return value, and passed INVALID_SOCKET to send(), which immediately crashed (DFSR 0x0b).
As far as I understand the NDK API (and a TCP spec in general), passing INVALID_SOCKET is OK (it should fail with EBADF, but not crash).
I strongly suspect that the crash is caused by the absence of network buffers (still held by the socket0 maybe?). Could somebody confirm/deny my suspicions?
In case it matters, ti-rtos 2-10-01-38, ndk 2-24-01-18