Commit 2e6a571
committed
_sim_debug_flush(): Use fsync().
Fix race condition in _debug_fwrite_all() where the FILE *f output
file can be permanently NULL, causing fwrite() to permanently return
zero and resulting in an infinite loop on mulithreaded SIMH. This
pathology primarily occurs when main thread calls flush_svc() and
one of the Ethernet threads (reader, writer) emits debugging output.
Linux and macOS platforms invoke fsync() to synchronize file data to
disk. Windows has a fsync() wrapper calling _commit() providing the
same semantics.
Issue traced to _sim_debug_flush() calling sim_set_deboff(0, NULL) to
simulate fsync().1 parent b036821 commit 2e6a571
1 file changed
Lines changed: 27 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
256 | 269 | | |
257 | 270 | | |
258 | 271 | | |
| |||
13611 | 13624 | | |
13612 | 13625 | | |
13613 | 13626 | | |
| 13627 | + | |
| 13628 | + | |
| 13629 | + | |
| 13630 | + | |
| 13631 | + | |
| 13632 | + | |
| 13633 | + | |
| 13634 | + | |
| 13635 | + | |
| 13636 | + | |
| 13637 | + | |
| 13638 | + | |
13614 | 13639 | | |
13615 | 13640 | | |
13616 | 13641 | | |
| |||
13755 | 13780 | | |
13756 | 13781 | | |
13757 | 13782 | | |
13758 | | - | |
13759 | | - | |
13760 | | - | |
13761 | | - | |
13762 | | - | |
13763 | | - | |
13764 | 13783 | | |
13765 | 13784 | | |
13766 | 13785 | | |
13767 | 13786 | | |
| 13787 | + | |
| 13788 | + | |
13768 | 13789 | | |
13769 | | - | |
13770 | | - | |
13771 | | - | |
13772 | | - | |
13773 | | - | |
13774 | | - | |
13775 | | - | |
13776 | | - | |
13777 | | - | |
13778 | | - | |
13779 | | - | |
13780 | | - | |
13781 | | - | |
13782 | | - | |
13783 | | - | |
13784 | | - | |
13785 | 13790 | | |
13786 | 13791 | | |
13787 | 13792 | | |
| |||
0 commit comments