Skip to content

Use loop instead of recursion

Alexey Min requested to merge (removed):fix-screenshot-crash into master

This fixes crash when clicking "screenshot" button in the top panel on postmarketOS.

stacktrace of crash:

Thread 11 "Thread (pooled)" received signal SIGSEGV, Segmentation fault.
[Switching to LWP 3328]
0x0000ffffad3f2ea4 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:44
44      /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp: No such file or directory.
(gdb) bt
#0  0x0000ffffad3f2ea4 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:44
#1  0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#2  0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#3  0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#4  0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#5  0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#6  0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#7  0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#8  0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#9  0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#10 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#11 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#12 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#13 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#14 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#15 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#16 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#17 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#18 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#19 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#20 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#21 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#22 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#23 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#24 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#25 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#26 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61
#27 0x0000ffffad3f2f38 in readData (theFile=theFile@entry=32, theDataOut=...)
    at /home/pmos/build/src/plasma-phone-components-5.20.90/containments/panel/phonepanel.cpp:61

The default stack size in musl is 128 Kb, which will be fully consumed in ~30 recursions by a function with 4 Kb buffer.

See https://wiki.musl-libc.org/functional-differences-from-glibc.html#Thread-stack-size

Edited by Alexey Min

Merge request reports

Loading