From nobody Wed Nov 30 16:04:49 2022 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NMkYZ2JJnz4htSD for ; Wed, 30 Nov 2022 16:04:50 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NMkYY6z3mz40DS for ; Wed, 30 Nov 2022 16:04:49 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669824290; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q8civGl3WNNbcdHPuMS6CFraXLIB3jBrSqIYYPzXZm4=; b=NlBmC0S8WDI4FkBplcd6ah24oag4EYH4Img3H6TSR1QHNpRZVD3gyMeI762S729A/LSYey 2w7sv5xewcoH0PwegQ1nOWozTi15UJTDATEsr9wtkUmuECGy2iSkUiEZPDVI4QNIggQPE1 ubCPlUCl0zPbnEh3BDw99PshnS3BlqvZEFW3PL4hrzqFTE9buIUTyY0RAyHkrtBsqByVru 3buxtgzb4KhfAMiRvh9tVHh/jddoUva3UZGLTHMjhKHPxzNGr/suuITBXBDO0t8lPYkvjG ufzUIBq3J1gEFHhRUH2WB1BoIn3ijhALhY5W1ah54Edbry7ep00ns4qgDSCuhg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669824290; a=rsa-sha256; cv=none; b=iT7Uk6L37fsZYQo9NXUME3/hvAkiSYosimfhioUIAkhRDCOVXFiuJ/W8qc308/cT5/ZKyb uT2Yyw0v0rl7TQorVkgcXlxTDCnzVUYbHo+TcSrGB+ynSua+3UMbmivWb1CYc3OV/4/lXK Xg+f8cYeqZso9voalqIfABJLTtwSkeZy9fPTiLvwUDwhG6S90730IxLQf0nd7qeNuD9AV0 P1UY3dIZu8Gxwv1uyQtySCA3c9bDCGkUnsAhYI/bWuNmx860CzdnVGi3V7WM6W3TzZFIY0 xqbbjJuC4/K699cFSsrW4ixU6zp+dV+8IeIlqselNuyVIZgyX0a/FTlpECzYOg== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NMkYY5lftz12Y7 for ; Wed, 30 Nov 2022 16:04:49 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 2AUG4nst035806 for ; Wed, 30 Nov 2022 16:04:49 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 2AUG4nfR035805 for bugs@FreeBSD.org; Wed, 30 Nov 2022 16:04:49 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 268076] dc(1): crash on window size change Date: Wed, 30 Nov 2022 16:04:49 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: saper@saper.info X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D268076 --- Comment #4 from Marcin Cie=C5=9Blak --- Thank you for a very quick response, here is how it looks now: dc(1) prints "ready for more input" every time I resize the window, but does not crash at all radziecki> ./bin/dc=20=20=20=20=20=20=20=20=20=20=20=20=20=20 2 2 + p 4 ready for more input 5 # resize ready for more input ready for more input ready for more input bc(1) exists as before radziecki> ./bin/bc >>> 2 + 2=20 4 >>>=20 Fatal error: I/O error Function: (main) This is your software and I fully respect your right to design its features= as you see fit, especially given the maintenance burden is mostly on you. I think classic "perror()" would be slighly better here (of course without = all the i18n goodies). diff --git a/src/history.c b/src/history.c index bc15da5b..15e6e25b 100644 --- a/src/history.c +++ b/src/history.c @@ -264,8 +264,7 @@ bc_history_line(BcHistory* h, BcVec* vec, const char* prompt) // If this is true, there was an error. Otherwise, it's just EOF. if (len =3D=3D -1) { - if (errno =3D=3D ENOMEM) bc_err(BC_ERR_FATAL_ALLOC_= ERR); - bc_err(BC_ERR_FATAL_IO_ERR); + perror("reading next input line failed"); } else { Maybe it could be helpful to tell you how I approached the problem. This is just my personal story and certainly not a case for everyone approaching unknown software: 1. First I did=20 git grep "Fatal error" to find out there is i18n system in place and it looks like "I/O Error" is = an error number 5 (counted by hand in "bc_err_msgs") 2. Then I did git grep bc_err_msgs to learn that the whole i18n thing is initialized via bc_vm_defaultMsgs() but still no clue regarding what might have caused it 3. Then tried my luck to git grep bc_err_ids that reveals there is bc_vm_handleError() and the name looks promising 4. Having learned that it was easier: (gdb) b bc_vm_handleError Breakpoint 1 at 0x2372f8: file ./src/vm.c, line 351. (gdb) run Starting program: /usr/home/saper/src/bc/bin/bc=20 warning: Could not load shared library symbols for [vdso]. Do you need "set solib-search-path" or "set sysroot"? >>>=20 Breakpoint 1, bc_vm_handleError (e=3DBC_ERR_FATAL_IO_ERR, line=3D0) at ./src/vm.c:351 351 uchar id =3D bc_err_ids[e]; (gdb) bt #0 bc_vm_handleError (e=3DBC_ERR_FATAL_IO_ERR, line=3D0) at ./src/vm.c:351 #1 0x0000000000218169 in bc_history_line ( h=3D0x23e440 , vec=3D0x23e228 ,=20 prompt=3D0x201ca5 ">>> ") at ./src/history.c:268 #2 0x0000000000234e10 in bc_read_line ( vec=3D0x23e228 , prompt=3D0x201ca5 ">>> ") at ./src/read.c:236 #3 0x000000000023827e in bc_vm_readLine (clear=3Dtrue) at ./src/vm.c:1114 #4 0x000000000023ac20 in bc_vm_stdin () at ./src/vm.c:1165 #5 0x0000000000239b7d in bc_vm_exec () at ./src/vm.c:1501 #6 0x0000000000238eae in bc_vm_boot (argc=3D1, argv=3D0x7fffffffe6b0) at ./src/vm.c:1691 #7 0x000000000021131c in bc_main (argc=3D1, argv=3D0x7fffffffe6b0) at ./src/bc.c:62 #8 0x000000000021a199 in main (argc=3D1, argv=3D0x7fffffffe6b0) at ./src/main.c:108 (gdb) down Bottom (innermost) frame selected; you cannot go down. (gdb) up #1 0x0000000000218169 in bc_history_line (h=3D0x23e440 ,=20 vec=3D0x23e228 , prompt=3D0x201ca5 ">>> ") at ./src/history.c:268 268 bc_err(BC_ERR_FATAL_IO_ERR); (gdb) list - 263 { 264 // If this is true, there was an error. Otherwise, = it's just EOF. 265 if (len =3D=3D -1) 266 { 267 if (errno =3D=3D ENOMEM) bc_err(BC_ERR_FATAL_ALLOC_ERR); 268 bc_err(BC_ERR_FATAL_IO_ERR); 269 } 270 else 271 { 272 bc_file_printf(&vm->fout, "\n"); (gdb)=20 253 } 254 } 255 else bc_history_prompt =3D bc_vm_strdup(prompt); 256 } 257=20=20=20=20=20 258 // Get the line. 259 line =3D el_gets(h->el, &len); 260=20=20=20=20=20 261 // If there is no line... 262 if (BC_ERR(line =3D=3D NULL)) (gdb) p line $1 =3D 0x0 (gdb) p h->el $2 =3D (EditLine *) 0x800a6a000 (gdb) p len $3 =3D -1 What certainly would help is some unique identification of the position of = the error in the code (be it __FILE__, __LINE__ if need be). BC_ERR_FATAL_IO_ER= R is thrown in dozen or so places so I can't quickly tell where did it fail. Since FreeBSD runs optimized binaries, but with debug symbols available, it= was frustrating to see all local variables optimized out, only errno was there: (gdb) p len $1 =3D (gdb) p line $2 =3D (gdb) p h->el value has been optimized out (gdb) p errno $3 =3D 4 (feel free to move this conversation somewhere else, sadly could not regist= er at https://git.yzena.com/gavin/bc/) But again, thank you for building this software for us. --=20 You are receiving this mail because: You are the assignee for the bug.=