Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_Py_DumpASCII() writes characters one by one leading to corrupted tracebacks #89989

Closed
ambv opened this issue Nov 17, 2021 · 7 comments
Closed
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@ambv
Copy link
Contributor

ambv commented Nov 17, 2021

BPO 45831
Nosy @vstinner, @ambv, @miss-islington
PRs
  • bpo-45831: _Py_DumpASCII() uses a single write() call if possible #29596
  • [3.9] bpo-45831: _Py_DumpASCII() uses a single write() call if possible (GH-29596) #29597
  • [3.10] bpo-45831: _Py_DumpASCII() uses a single write() call if possible (GH-29596) #29598
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-11-17.22:00:22.958>
    created_at = <Date 2021-11-17.17:59:55.587>
    labels = ['interpreter-core', 'type-bug', '3.9', '3.10', '3.11']
    title = '_Py_DumpASCII() writes characters one by one leading to corrupted tracebacks'
    updated_at = <Date 2021-11-18.12:54:34.895>
    user = 'https://github.com/ambv'

    bugs.python.org fields:

    activity = <Date 2021-11-18.12:54:34.895>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-11-17.22:00:22.958>
    closer = 'lukasz.langa'
    components = ['Interpreter Core']
    creation = <Date 2021-11-17.17:59:55.587>
    creator = 'lukasz.langa'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45831
    keywords = ['patch']
    message_count = 7.0
    messages = ['406480', '406481', '406489', '406499', '406500', '406501', '406534']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'lukasz.langa', 'miss-islington']
    pr_nums = ['29596', '29597', '29598']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue45831'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @ambv
    Copy link
    Contributor Author

    ambv commented Nov 17, 2021

    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
    ...

    @ambv ambv added 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Nov 17, 2021
    @vstinner
    Copy link
    Member

    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.

    @ambv
    Copy link
    Contributor Author

    ambv commented Nov 17, 2021

    New changeset b919d81 by Victor Stinner in branch 'main':
    bpo-45831: _Py_DumpASCII() uses a single write() call if possible (GH-29596)
    b919d81

    @ambv
    Copy link
    Contributor Author

    ambv commented Nov 17, 2021

    New changeset 4ffde90 by Miss Islington (bot) in branch '3.10':
    bpo-45831: _Py_DumpASCII() uses a single write() call if possible (GH-29596) (GH-29598)
    4ffde90

    @ambv
    Copy link
    Contributor Author

    ambv commented Nov 17, 2021

    New changeset ac89f8c by Miss Islington (bot) in branch '3.9':
    bpo-45831: _Py_DumpASCII() uses a single write() call if possible (GH-29596) (GH-29597)
    ac89f8c

    @ambv ambv closed this as completed Nov 17, 2021
    @ambv ambv closed this as completed Nov 17, 2021
    @ambv
    Copy link
    Contributor Author

    ambv commented Nov 17, 2021

    Thanks, Victor! ✨ 🍰 ✨

    @vstinner
    Copy link
    Member

    Thanks, Victor! ✨ 🍰 ✨

    I'm curious to know if the traceback became a little more readable than msg406480 with this minor enhancement ;-)

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants