Commit 3d3b818
committed
Fix segfault on exit when update check is enabled
Before this patch, the script could often crash with segfaults on Debian
12/Python 3.11. It apparently when processing small files.
In that case, there was likely a race condition where Python tried to
terminate the update thread while it was already dead.
It was easy to reproduce with:
```sh
for i in {1..100}; do
./MCE.py -skip -exit /lib/firmware/amd-ucode/microcode_amd_fam16h.bin >& /dev/null || echo failed at iteration $i
done
```
GDB showed:
```
Thread 1 "python3" received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
44 ./nptl/pthread_kill.c: No such file or directory.
[Thread debugging using libthread_db enabled]
```
Using multiprocessing with daemon=True, there are no more crashes.
Processes are probably easier to kill properly. The result of the
update check is now shared using a queue.1 parent e3e73ef commit 3d3b818
1 file changed
Lines changed: 17 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | 132 | | |
143 | 133 | | |
144 | 134 | | |
| |||
688 | 678 | | |
689 | 679 | | |
690 | 680 | | |
691 | | - | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
692 | 689 | | |
693 | 690 | | |
694 | 691 | | |
| |||
804 | 801 | | |
805 | 802 | | |
806 | 803 | | |
807 | | - | |
| 804 | + | |
808 | 805 | | |
809 | 806 | | |
810 | 807 | | |
| |||
843 | 840 | | |
844 | 841 | | |
845 | 842 | | |
846 | | - | |
| 843 | + | |
847 | 844 | | |
848 | 845 | | |
849 | 846 | | |
| |||
1028 | 1025 | | |
1029 | 1026 | | |
1030 | 1027 | | |
1031 | | - | |
1032 | | - | |
1033 | | - | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
1034 | 1033 | | |
1035 | 1034 | | |
1036 | 1035 | | |
| |||
0 commit comments