Does anyone know why System.err.println is stuck at write? Issue happen during monkey test, check the code, it is stuck at System.err.println(s); here is calling stack:
"main" prio=10 tid=1 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x12c01e18 self=0x793e45ea00
| sysTid=14489 nice=-8 cgrp=default sched=0/0 handle=0x79c34989a8
| state=S schedstat=( 893730957 58891353 263 ) utm=66 stm=23 core=1 HZ=100
| stack=0x7ff175a000-0x7ff175c000 stackSize=8MB
| held mutexes=
kernel: __switch_to+0xa4/0xd8
kernel: pipe_wait+0x6c/0xb8
kernel: pipe_write+0x1dc/0x444
kernel: new_sync_write+0xd8/0x124
kernel: vfs_write+0x15c/0x1d0
kernel: SyS_write+0x60/0xc0
kernel: __sys_trace+0x4c/0x4c
native: #00 pc 000000000007afb4 /system/lib64/libc.so (write+4)
native: #01 pc 0000000000032e14 /system/lib64/libjavacore.so (???)
native: #02 pc 0000000000237194 /system/framework/arm64/boot-core-libart.oat (Java_libcore_io_Linux_writeBytes__Ljava_io_FileDescriptor_2Ljava_lang_Object_2II+196)
at libcore.io.Linux.writeBytes(Native method)
at libcore.io.Linux.write(Linux.java:288)
at libcore.io.BlockGuardOs.write(BlockGuardOs.java:345)
at libcore.io.IoBridge.write(IoBridge.java:553)
at java.io.FileOutputStream.write(FileOutputStream.java:326)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
- locked <0x0ee2596f> (a java.io.BufferedOutputStream)
at java.io.PrintStream.write(PrintStream.java:505)
- locked <0x087a167c> (a java.io.PrintStream)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
at sun.nio.cs.StreamEncoder.flushBuffer(StreamEncoder.java:104)
- locked <0x0ebd8b05> (a java.io.OutputStreamWriter)
at java.io.OutputStreamWriter.flushBuffer(OutputStreamWriter.java:185)
at java.io.PrintStream.write(PrintStream.java:554)
- locked <0x087a167c> (a java.io.PrintStream)
at java.io.PrintStream.print(PrintStream.java:698)
at java.io.PrintStream.println(PrintStream.java:835)
- locked <0x087a167c> (a java.io.PrintStream)
at com.android.commands.monkey.Logger$2.println(Logger.java:37)
at com.android.commands.monkey.Monkey.commandLineReport(Monkey.java:510)
Most likely what ever is reading System.err
isn't consuming the data. Once the buffer fills up, the program will wait until there is space in the buffer to write more.