Shadowsocks-android: libtun2socks tcp_free_acked_segments: lwip assertion failure: tcp_receive: valid queue length

Created on 12 Aug 2019  路  14Comments  路  Source: shadowsocks/shadowsocks-android

Please read contributing guidelines. Thanks.

Describe the bug

I check /data/tombstones today, find out a lot of "out of UDP buffer" error produced by shadowsocks libtun2sock.so. Since it happened several days ago, I have no idea how to reproduce it.

Expected behavior
A clear and concise description of what you expected to happen.
No errors.

Smartphone (please complete the following information):

  • Android/Chrome OS version: official lineage os 16.
  • Device: mi 6
  • Version: latest beta
  • Last version that did not exhibit the issue: [not applicable]
bug

All 14 comments

might relate to ambrop72/badvpn#41

Please post full tombstones here. The link you post relates to an error log and should not cause a crash.

Memory near stack: tcp_free_acked_segments: lwip assertion failure: tcp_receive: valid queue length

https://github.com/shadowsocks/badvpn/blob/6e14849aa213cbb028aeb0c75905438260fd867c/lwip/src/core/tcp_in.c#L1093

@madeye What do you think?

It looks kind of out of memory error?

@madeye some useful information http://lwip.100.n7.nabble.com/memory-leak-td24546.html

"Hi,

PROBLEM SOLVED :-)

As mentioned earlier by Sergio we should not call LwIP code from within
other threads.

I must call tcp_write and other functions from a separate thread. This
is the implementation.

My TCP stack has the highest task priority in the system. As a result
calling tcp_write or any other
LwIP function may cause unpredictable LwIP internal code problems.

I added taskENTER_CRITICAL(); and taskEXIT_CRITICAL();
Function calls to the portion of code that call tcp_write etc.. this
synchronizes the threads
Interaction and solved the problem I faced completely. "

Indeed I seem to find a similar tombstone on my device as well (1 out of 10 crash is from tun2socks, and the other 9 is from Pokemon Go :fitness). It seems like a rare race condition or sort. We should probably report this to upstream.

This seems to be an issue with MI 6. My project encountered a similar issue. After the VPN service was started, the VPN descriptor received a large number of UDP packets sent to the router. The IP of each packet is incremented, such as from 192.168.1.1-192.168.1.254 and the port is 137.

@madeye According to Crashlytics, this issue occurs across virtually any device (~10k events daily now), including Google Pixels, but (somehow) more frequently in Xiaomi. Unfortunately, 89dee85762512386b55aba0f36210dbf65fd209d is only set up since v4.8.1 so I cannot be sure which version introduced this bug but I suspect that it exists a long time ago.

We should probably report this to upstream.

I've been running with this patch for a few hours now and it seems fine. (however, my last tombstone from this crash was ~40 hours ago)

EDIT: Another 25 hours passed. Still good.

@madeye I think it should be fixed. Why don't we just do a new release and look at Crashlytics? 馃槃

Sure, I'll schedule a release today.

Seems to be fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kuaihou2012 picture kuaihou2012  路  6Comments

zhangchunsheng picture zhangchunsheng  路  3Comments

mahdiG picture mahdiG  路  4Comments

mcmxciv picture mcmxciv  路  3Comments

sakuranagashi picture sakuranagashi  路  5Comments