espressif / esp-lwip

Fork of lwIP (https://savannah.nongnu.org/projects/lwip/) with ESP-IDF specific patches
Other
85 stars 129 forks source link

Assertion failed: sockets[i].select_waiting == 0 (IDFGH-3019) #13

Closed pschlang closed 4 years ago

pschlang commented 4 years ago

In situations where the max number of sockets is close to the number of actually used sockets, the chance of hitting a race condition in lwIP increases which causes a system reset due to an assertion:

Assertion failed: sockets[i].select_waiting == 0

This has been fixed upstream in https://savannah.nongnu.org/bugs/?57445 / http://git.savannah.nongnu.org/cgit/lwip.git/commit/?id=8d7e436a9d24a2a1ee35aac72a7055e80330e994 and it would be useful to merge it here as well.

Alvin1Zhang commented 4 years ago

@pschlang Thanks for reporting.

freakyxue commented 4 years ago

hi @pschlang I've met this problem before. I think PR is a better solution

freakyxue commented 4 years ago

hi @pschlang I think there's another solution。 You can add this patch for testing. lwip commit id :dd3b301750f19c9f15248ac32d366cd41c6b3225

pschlang commented 4 years ago

Thanks @freakyxue, but I think it is better to merge the upstream patch as it will solve the root cause and not just hide the symptom.

MightyPork commented 4 years ago

Is there any work-around we can use before this is merged/fixed?

The use case is simple and I would dare say common:

  1. select waiting on a socket
  2. in another thread, the socket FD is closed
  3. lwip assert
pschlang commented 4 years ago

This is very easy to patch / backport, I don't really understand why there's no activity here from ESP side.

We currently have to patch this manually every time we update the esp-idf SDK.

freakyxue commented 4 years ago

hi @pschlang I'm sorry I didn't reply in time, This patch has been added to IDF, and we will merge it as soon as possible