classification
Title: _Py_DumpASCII() writes characters one by one leading to corrupted tracebacks
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: lukasz.langa, miss-islington, vstinner
Priority: normal Keywords: patch

Created on 2021-11-17 17:59 by lukasz.langa, last changed 2021-11-18 12:54 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 29596 merged vstinner, 2021-11-17 18:00
PR 29597 merged miss-islington, 2021-11-17 20:12
PR 29598 merged miss-islington, 2021-11-17 20:13
Messages (7)
msg406480 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-11-17 17:59
This is also a performance issue but I'm mostly concerned about the stdout corruption aspect. When more than one thread aborts at the same time, output ends up looking like the example below on the terminal. Unless you understand the issue is output written out byte-by-byte, you might get misled into seeing memory corruption.


Fatal Python error: Aborted

Fatal Python error: Fatal Python error: Fatal Python error: AbortedAborted



AbortedCurrent thread 0x

0000000110cf4dc0 (most recent call first):
Current thread 0xCurrent thread 0x  File 0000000110cf4dc0Current thread 0x (most recent call first):
0000000110cf4dc00000000110cf4dc0 (most recent call first):
 (most recent call first):
"  File   File   File /tmp"""////tctmtmppmpyp//tcchppoy/nytc-hptrohyonoton-t-rh-ormooaoontt-i--rnmomo/aatiLi-nni/m/baLLriiinbab/rrLraayirr/byyr//FFaFrrrayam/mrFeearwmaowermwoeorkrwkkossr//kPPsyy/ttPhsyo/tnhP.hyotnoh.nof.nrff.arfmarreaammwmeeoewwrowkro/orVrkkek///rVVseVierorsesnirsioson/ns3si.//o331.n1s.111///l13il.bi1/b1//pl/ypiltybht/ihopbno/n3yp3.t.1hy11o1/n/m3mu.tul1lth1ti/oipmnrpu3ol.rc1toe1cs/esmsiunsliignt/pigspr/yorncocscehysnrseocsihnsnirigoz/nesi.yzpnyen."cgph/yrs"oy, line nn95i, line  in c95z_ in e__h.e_pnertnyoet"ernr_i__z_
, line
e  File   File .95p in y_""_//"ttemmnppt//, line ccepp95yy in ttr_h_ho_on_-ner-nr
ooto  File ote-rm"_a/_ti
nm  File p//Lcitbp"yr-ta/hrtym/pFm/racaipmnye/owLtoihbrokrnnas-r/-Pyry/rtFoohooorttn-a.mfma-eirmnwaamoiernwk/osL//rikPL/yiVtbherroansrb.iyfo/nrFasr/ma3emw.e1owr1o/kr/lkiVsbe/r/Pspyyittohhnoosnn/.33f..r11a11m//elmwiuolbrt/kpi/pyVtrehorocsenis3os.n1is1n//g3/m.uq1ul1te/iulpeirsb.o/cppeyys"ts, line h102io in nng3g/.qe1utr
e1u  File a/"rme/uytsl/.mtppFi/yrpc"rpa, line yomt102ehcw in eosgnose-rirtnk
gs  File o//o"Pt/qty-mumpea/ticunpey/hLtosih.bopnrnya-".rr, line yfo/r102oF in argtaemm-temew
woaor  File rikkns/"L//Pi/ybtVtrmhapeor/nyc/.pFfyrrtaahmmoerwensow-rorkorsok/t/Pi-Vymoetarhisonnin.o/sfnLrs//ai33mb.er.1w11o1ar/rk/l/lyViieb/brF/srp/aipyomntyhseo/tn3w3.ho1.r11o1/k/lsnic3ob//n.cpPu1yr1yrt/ehmntuothl/otfinup.rtfourrcaeenss3s/.ip1nr1gom/c/qecusoesne.uwpceyuosr."rp, line ry236ke in /"_nVpt, line re/o102fcr in sueitgsuesr_toewn
...
msg406481 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-11-17 18:08
> This is also a performance issue

Yep. On Windows, it already happened to me to see characters written one by one when the machine and the terminal was super slow. I expect faster dump if an ASCII string can be written at once.
msg406489 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-11-17 20:12
New changeset b919d8105c4d77f00509b6d3ab2073f09db640de by Victor Stinner in branch 'main':
bpo-45831: _Py_DumpASCII() uses a single write() call if possible (GH-29596)
https://github.com/python/cpython/commit/b919d8105c4d77f00509b6d3ab2073f09db640de
msg406499 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-11-17 22:00
New changeset 4ffde90dccd741b04a448f2e44f0b82a41b6fe96 by Miss Islington (bot) in branch '3.10':
bpo-45831: _Py_DumpASCII() uses a single write() call if possible (GH-29596) (GH-29598)
https://github.com/python/cpython/commit/4ffde90dccd741b04a448f2e44f0b82a41b6fe96
msg406500 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-11-17 22:00
New changeset ac89f8cab79800195687dd141de472f90c626ec3 by Miss Islington (bot) in branch '3.9':
bpo-45831: _Py_DumpASCII() uses a single write() call if possible (GH-29596) (GH-29597)
https://github.com/python/cpython/commit/ac89f8cab79800195687dd141de472f90c626ec3
msg406501 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-11-17 22:00
Thanks, Victor! ✨ 🍰 ✨
msg406534 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-11-18 12:54
> Thanks, Victor! ✨ 🍰 ✨

I'm curious to know if the traceback became a little more readable than  msg406480 with this minor enhancement ;-)
History
Date User Action Args
2021-11-18 12:54:34vstinnersetmessages: + msg406534
2021-11-17 22:00:36lukasz.langasetmessages: + msg406501
2021-11-17 22:00:22lukasz.langasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-11-17 22:00:03lukasz.langasetmessages: + msg406500
2021-11-17 22:00:02lukasz.langasetmessages: + msg406499
2021-11-17 20:13:01miss-islingtonsetpull_requests: + pull_request27841
2021-11-17 20:12:58miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request27840
2021-11-17 20:12:26lukasz.langasetmessages: + msg406489
2021-11-17 18:08:06vstinnersetmessages: + msg406481
2021-11-17 18:00:31vstinnersetkeywords: + patch
nosy: + vstinner
pull_requests: + pull_request27839
2021-11-17 17:59:55lukasz.langacreate