scrcpy: Stack corruption detected when using version 1.21

  • I have read the FAQ.
  • I have searched in existing issues.

Environment

Describe the bug

I was using for some time scrcpy 1.17 in order to retrieve frames from the device, and decided today to update to the last version. In the previous version, I was able in Python3, following a code a bit like this one https://github.com/DawningW/swy-bot/blob/main/scrcpy.py to:

  • Push the server on my phone
  • Launch the server
  • Forward server port :
  • Then get from the video socket the dummy byte, the device name, and the screen resolution

After that, I was able to receive all my frames from the video socket, and it was working perfectly fine.

In 1.21, I saw that the method to launch the server changed. In 1.17, I was using :

subprocess.Popen(
                ['adb', '-s', device_id, 'shell',
                 'CLASSPATH=/data/local/tmp/scrcpy-server',
                 'app_process', '/', 'com.genymobile.scrcpy.Server 1.17 verbose {} {} {} -1 true - false false 0 false false - -'.format(max_width, bitrate, max_fps)],

But in 1.21, there are now named parameters, and also new one, based on what I saw in the Server.java src code. I modified my code to something like :

['adb', '-s', device_id, 'shell',
                 'CLASSPATH=/data/local/tmp/scrcpy-server',
                 'app_process', '/',
                 'com.genymobile.scrcpy.Server {} log_level=verbose max_size=0 bit_rate=8000000 max_fps=0 lock_video_orientation=-1 tunnel_forward=true send_frame_meta=false control=false display_id=0 show_touches=false stay_awake=false power_off_on_close=false clipboard_autosync=false'], 
                 cwd=SERVER_ROOT)

After launching the server, I’m still able to get access to the dummy byte, the device name, and the screen resolution from the socket, but then I don’t receive any frame anymore. I have this error happening :

stack corruption detected (-fstack-protector) Aborted

My question is, is it still possible to retrieve frames this way ? And if it is the case, is there a parameter that is not working like that anymore, and that would explain why I have a problem retrieving the frames from the video socket now ?

Thanks a lot for your time.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 22 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Also got this issue on Samsung Galaxy S9 (Android 10), the same crash stack trace.

01-08 21:10:48.983  8338  8355 I ACodec  : reconfigEncoder4OtherApps
01-08 21:10:48.983  8338  8355 F libc    : stack corruption detected (-fstack-protector)
01-08 21:10:48.984  8338  8355 F libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 8355 (CodecLooper), pid 8338 (main)
01-08 21:10:49.039  8364  8364 E crash_dump64: unknown process state: t
01-08 21:10:49.069  8364  8364 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
01-08 21:10:49.070  1292  1292 I /system/bin/tombstoned: received crash request for pid 8355
01-08 21:10:49.071  8364  8364 I crash_dump64: performing dump of process 8338 (target tid = 8355)
01-08 21:10:49.082  8364  8364 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-08 21:10:49.083  8364  8364 F DEBUG   : Build fingerprint: 'samsung/starqltezh/starqltechn:10/QP1A.190711.020/G9600ZHU9FUK5:user/release-keys'
01-08 21:10:49.083  8364  8364 F DEBUG   : Revision: '14'
01-08 21:10:49.083  8364  8364 F DEBUG   : ABI: 'arm64'
01-08 21:10:49.083  8364  8364 F DEBUG   : Timestamp: 2022-01-08 21:10:49+0800
01-08 21:10:49.083  8364  8364 F DEBUG   : pid: 8338, tid: 8355, name: CodecLooper  >>> app_process <<<
01-08 21:10:49.083  8364  8364 F DEBUG   : uid: 2000
01-08 21:10:49.083  8364  8364 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
01-08 21:10:49.084  8364  8364 F DEBUG   : Abort message: 'stack corruption detected (-fstack-protector)'
01-08 21:10:49.084  8364  8364 F DEBUG   :     x0  0000000000000000  x1  00000000000020a3  x2  0000000000000006  x3  0000007a0ab81000
01-08 21:10:49.084  8364  8364 F DEBUG   :     x4  0000000000808080  x5  0000000000808080  x6  0000000000808080  x7  0000000000000030
01-08 21:10:49.084  8364  8364 F DEBUG   :     x8  00000000000000f0  x9  dd30231179e08b19  x10 0000000000000001  x11 0000000000000000
01-08 21:10:49.084  8364  8364 F DEBUG   :     x12 fffffff0fffffbdf  x13 0000000061d98d58  x14 0039d9d0f049221a  x15 0000ca169e7eb4e6
01-08 21:10:49.084  8364  8364 F DEBUG   :     x16 0000007aad5548c0  x17 0000007aad530ff0  x18 0000007a0a5ce000  x19 0000000000002092
01-08 21:10:49.084  8364  8364 F DEBUG   :     x20 00000000000020a3  x21 00000000ffffffff  x22 0000007a0ab82020  x23 0000007aad13b6a8
01-08 21:10:49.084  8364  8364 F DEBUG   :     x24 0000007a0ab82020  x25 0000007a0ab812c8  x26 0000007aad13b6a8  x27 0000007a0ab82020
01-08 21:10:49.084  8364  8364 F DEBUG   :     x28 0000007aacd92c70  x29 0000007a0ab810a0
01-08 21:10:49.084  8364  8364 F DEBUG   :     sp  0000007a0ab80fe0  lr  0000007aad4e227c  pc  0000007aad4e22a8
01-08 21:10:49.095  8364  8364 F DEBUG   : 
01-08 21:10:49.095  8364  8364 F DEBUG   : backtrace:
01-08 21:10:49.096  8364  8364 F DEBUG   :       #00 pc 00000000000832a8  /apex/com.android.runtime/lib64/bionic/libc.so (abort+160) (BuildId: d00c50b4798c95f2447d684ed3ea7dcb)
01-08 21:10:49.096  8364  8364 F DEBUG   :       #01 pc 00000000000d13b8  /apex/com.android.runtime/lib64/bionic/libc.so (__stack_chk_fail+20) (BuildId: d00c50b4798c95f2447d684ed3ea7dcb)
01-08 21:10:49.096  8364  8364 F DEBUG   :       #02 pc 00000000000e5240  /system/lib64/libstagefright.so (android::ACodec::reconfigEncoder4OtherApps(android::sp<android::AMessage> const&)+536) (BuildId: 626521096d23fe4ab1fdf19c7b93f835)
01-08 21:10:49.096  8364  8364 F DEBUG   :       #03 pc 00000000000e2c04  /system/lib64/libstagefright.so (android::ACodec::setupAVCEncoderParameters(android::sp<android::AMessage> const&)+2800) (BuildId: 626521096d23fe4ab1fdf19c7b93f835)
01-08 21:10:49.096  8364  8364 F DEBUG   :       #04 pc 00000000000ddd34  /system/lib64/libstagefright.so (android::ACodec::setupVideoEncoder(char const*, android::sp<android::AMessage> const&, android::sp<android::AMessage>&, android::sp<android::AMessage>&)+2832) (BuildId: 626521096d23fe4ab1fdf19c7b93f835)
01-08 21:10:49.096  8364  8364 F DEBUG   :       #05 pc 00000000000d8cf8  /system/lib64/libstagefright.so (android::ACodec::configureCodec(char const*, android::sp<android::AMessage> const&)+7312) (BuildId: 626521096d23fe4ab1fdf19c7b93f835)
01-08 21:10:49.096  8364  8364 F DEBUG   :       #06 pc 00000000000d4868  /system/lib64/libstagefright.so (android::ACodec::LoadedState::onConfigureComponent(android::sp<android::AMessage> const&)+180) (BuildId: 626521096d23fe4ab1fdf19c7b93f835)
01-08 21:10:49.096  8364  8364 F DEBUG   :       #07 pc 00000000000d4688  /system/lib64/libstagefright.so (android::ACodec::LoadedState::onMessageReceived(android::sp<android::AMessage> const&)+540) (BuildId: 626521096d23fe4ab1fdf19c7b93f835)
01-08 21:10:49.096  8364  8364 F DEBUG   :       #08 pc 00000000000f3a20  /system/lib64/libstagefright.so (android::AHierarchicalStateMachine::handleMessage(android::sp<android::AMessage> const&)+260) (BuildId: 626521096d23fe4ab1fdf19c7b93f835)
01-08 21:10:49.096  8364  8364 F DEBUG   :       #09 pc 000000000001a930  /system/lib64/libstagefright_foundation.so (android::AHandler::deliverMessage(android::sp<android::AMessage> const&)+48) (BuildId: 8a68c0993367e3faa25f7ac444fb6770)
01-08 21:10:49.097  8364  8364 F DEBUG   :       #10 pc 000000000001e6e0  /system/lib64/libstagefright_foundation.so (android::AMessage::deliver()+100) (BuildId: 8a68c0993367e3faa25f7ac444fb6770)
01-08 21:10:49.097  8364  8364 F DEBUG   :       #11 pc 000000000001b378  /system/lib64/libstagefright_foundation.so (android::ALooper::loop()+560) (BuildId: 8a68c0993367e3faa25f7ac444fb6770)
01-08 21:10:49.097  8364  8364 F DEBUG   :       #12 pc 00000000000135ec  /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+224) (BuildId: 1d07ca01e00872ed0674078cbbbd979b)
01-08 21:10:49.097  8364  8364 F DEBUG   :       #13 pc 00000000000e6f20  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36) (BuildId: d00c50b4798c95f2447d684ed3ea7dcb)
01-08 21:10:49.097  8364  8364 F DEBUG   :       #14 pc 00000000000850c8  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: d00c50b4798c95f2447d684ed3ea7dcb)
01-08 21:10:49.102 11224 11224 I io_stats: !@   8,0 r 18764611 582299792 w 3709924 67961352 d 280626 39638872 f 1863602 1872900 iot 7953350 6767499 th 102400 0 0 pt 0 inp 0 0 322520.116

Searched through Android source code and Google, looks like the reconfigEncoder4OtherApps function only exists on Samsung devices, and I can’t find the source code for it.


In my test it only happens to OMX.qcom.video.encoder.avc encoder, the other two (c2.android.avc.encoder, OMX.google.h264.encoder) on my device doesn’t crash even with a much longer command (>300 characters)


And the character limit of 255 starts from app_process part, for example

> 'app_process / com.genymobile.scrcpy.Server 1.21 log_level=debug max_size=1080 bit_rate=40000 max_fps=0 crop= send_frame_meta=true control=true display_id=0 show_touches=false stay_awake=true encoder_name=OMX.qcom.video.encoder.avc clipboard_autosync=true'.length
< 254

doesn’t crash.

> 'app_process / com.genymobile.scrcpy.Server 1.21 log_level=debug max_size=1080 bit_rate=400000 max_fps=0 crop= send_frame_meta=true control=true display_id=0 show_touches=false stay_awake=true encoder_name=OMX.qcom.video.encoder.avc clipboard_autosync=true'.length
< 255

crashes.

I have also encountered this problem on a samsung device. After I shorten the app_process options, the error of stack corruption detected (-fstack-protector) is gone.

Consider simplifying parameter names? There seems to be a limit to the parameter length on Samsung devices