Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 06 Dec 2022 23:24:54 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 268076] dc(1): crash on window size change
Message-ID:  <bug-268076-227-kxt5hNp7nb@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-268076-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-268076-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D268076

--- Comment #14 from Marcin Cie=C5=9Blak <saper@saper.info> ---
I have set a breakpoint on the signal handler and single-stepped it a bit:

+b bc_vm_sig
Note: breakpoint 1 also set at pc 0x23a66b.
Breakpoint 2 at 0x23a66b: file ./src/vm.c, line 123.
+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"?

Breakpoint 1, bc_vm_sig (sig=3D28) at ./src/vm.c:123
123             if (vm->status =3D=3D (sig_atomic_t) BC_STATUS_QUIT || vm->=
sig !=3D
0)
+p *vm
$2 =3D {status =3D 0, sig_pop =3D 0, prs =3D {l =3D {buf =3D 0x0, i =3D 0, =
line =3D 1, len =3D 0,=20
      t =3D BC_LEX_EOF, last =3D BC_LEX_EOF, str =3D {v =3D 0x800a2a0e0 '\2=
45' <repeats
32 times>,=20
        len =3D 0, cap =3D 32, size =3D 1, dtor =3D 0}, mode =3D BC_MODE_EX=
PRS}, flags =3D
{
      v =3D 0x800a43040 "", len =3D 1, cap =3D 32, size =3D 2, dtor =3D 0},=
 exits =3D {
      v =3D 0x800a5d300 '\245' <repeats 200 times>..., len =3D 0, cap =3D 3=
2, size =3D
24,=20
      dtor =3D 0}, conds =3D {v =3D 0x800a50700 '\245' <repeats 200 times>.=
.., len =3D
0, cap =3D 32,=20
      size =3D 8, dtor =3D 0}, ops =3D {v =3D 0x800a09000 '\245' <repeats 1=
28 times>,
len =3D 0,=20
      cap =3D 32, size =3D 4, dtor =3D 0}, buf =3D {v =3D 0x800a2a0c0 '\245=
' <repeats 64
times>,=20
      len =3D 0, cap =3D 32, size =3D 1, dtor =3D 0}, prog =3D 0x23ea00 <vm=
_data+288>,=20
    func =3D 0x800a47000, fidx =3D 0, auto_part =3D false}, prog =3D {globa=
ls =3D {10,
10, 0, 10},=20
    globals_v =3D {{v =3D 0x800a50000 "\n", len =3D 1, cap =3D 32, size =3D=
 8, dtor =3D 0},
{
        v =3D 0x800a50100 "\n", len =3D 1, cap =3D 32, size =3D 8, dtor =3D=
 0}, {v =3D
0x800a50200 "",=20
        len =3D 1, cap =3D 32, size =3D 8, dtor =3D 0}, {v =3D 0x800a50300 =
"\n", len =3D 1,
cap =3D 32,=20
        size =3D 8, dtor =3D 0}}, rng =3D {v =3D {v =3D 0x800a54000 "", len=
 =3D 1, cap =3D
32, size =3D 32,=20
        dtor =3D 0}}, results =3D {v =3D 0x800a57000 '\245' <repeats 200 ti=
mes>...,
len =3D 0,=20
      cap =3D 32, size =3D 48, dtor =3D 6}, stack =3D {v =3D 0x800a5d000 ""=
, len =3D 1, cap
=3D 32,=20
      size =3D 24, dtor =3D 0}, consts =3D {v =3D 0x800a60000 '\245' <repea=
ts 200
times>...,=20
      len =3D 0, cap =3D 32, size =3D 56, dtor =3D 5}, const_map =3D {
      v =3D 0x800a44c00 '\245' <repeats 200 times>..., len =3D 0, cap =3D 3=
2, size =3D
16,=20
      dtor =3D 0}, strs =3D {v =3D 0x800a50600 '\245' <repeats 200 times>..=
., len =3D
0, cap =3D 32,=20
      size =3D 8, dtor =3D 0}, str_map =3D {v =3D 0x800a44e00 '\245' <repea=
ts 200
times>...,=20
      len =3D 0, cap =3D 32, size =3D 16, dtor =3D 0}, fns =3D {v =3D 0x800=
a47000
"\200\240\242",=20
      len =3D 2, cap =3D 32, size =3D 120, dtor =3D 3}, fn_map =3D {v =3D 0=
x800a44200 "",
len =3D 2,=20
      cap =3D 32, size =3D 16, dtor =3D 0}, vars =3D {v =3D 0x800a54400 '\2=
45' <repeats
200 times>...,=20
      len =3D 0, cap =3D 32, size =3D 32, dtor =3D 1}, var_map =3D {
      v =3D 0x800a44800 '\245' <repeats 200 times>..., len =3D 0, cap =3D 3=
2, size =3D
16,=20
      dtor =3D 0}, arrs =3D {v =3D 0x800a54800 '\245' <repeats 200 times>..=
., len =3D
0, cap =3D 32,=20
      size =3D 32, dtor =3D 1}, arr_map =3D {v =3D 0x800a44a00 '\245' <repe=
ats 200
times>...,=20
      len =3D 0, cap =3D 32, size =3D 16, dtor =3D 0}, tail_calls =3D {v =
=3D 0x0, len =3D 0,
cap =3D 0,=20
      size =3D 0, dtor =3D 0}, strmb =3D {num =3D 0x23ecd8 <vm_data+1016>, =
rdx =3D 0,
scale =3D 0,=20
      len =3D 1, cap =3D 8}, asciify =3D {num =3D 0x800a2a040, rdx =3D 0, s=
cale =3D 0, len
=3D 0,=20
      cap =3D 8}, last =3D {num =3D 0x800a2a060, rdx =3D 0, scale =3D 0, le=
n =3D 0, cap =3D
8},=20
    strmb_num =3D {256, 0, 0, 0, 0, 0, 0, 0}}, line_buf =3D {v =3D 0x800a2a=
800 "",
len =3D 1,=20
    cap =3D 32, size =3D 1, dtor =3D 0}, buffer =3D {v =3D 0x800a2a100 "", =
len =3D 1, cap =3D
32,=20
    size =3D 1, dtor =3D 0}, read_prs =3D {l =3D {buf =3D 0x0, i =3D 0, lin=
e =3D 0, len =3D 0,=20
      t =3D BC_LEX_EOF, last =3D BC_LEX_EOF, str =3D {v =3D 0x0, len =3D 0,=
 cap =3D 0, size
=3D 0,=20
        dtor =3D 0}, mode =3D BC_MODE_EXPRS}, flags =3D {v =3D 0x0, len =3D=
 0, cap =3D 0,
size =3D 0,=20
      dtor =3D 0}, exits =3D {v =3D 0x0, len =3D 0, cap =3D 0, size =3D 0, =
dtor =3D 0}, conds
=3D {v =3D 0x0,=20
      len =3D 0, cap =3D 0, size =3D 0, dtor =3D 0}, ops =3D {v =3D 0x0, le=
n =3D 0, cap =3D 0,
size =3D 0,=20
      dtor =3D 0}, buf =3D {v =3D 0x0, len =3D 0, cap =3D 0, size =3D 0, dt=
or =3D 0}, prog =3D
0x0,=20
    func =3D 0x0, fidx =3D 0, auto_part =3D false}, read_buf =3D {v =3D 0x0=
, len =3D 0, cap
=3D 0,=20
    size =3D 0, dtor =3D 0}, jmp_bufs =3D {v =3D 0x800a32000 "!\250!", len =
=3D 2, cap =3D
32, size =3D 96,=20
    dtor =3D 0}, temps_len =3D 0, file =3D 0x20ab00 <bc_program_stdin_name>
"<stdin>",=20
  sigmsg =3D 0x20a120 <bc_sig_msg> "\ninterrupt (type \"quit\" to exit)\n",
sig_lock =3D 1,=20
  sig =3D 0, siglen =3D 33 '!', read_ret =3D 77 'M', flags =3D 15808, nchar=
s =3D 0,
line_len =3D 69,=20
  no_exprs =3D false, exit_exprs =3D false, eof =3D false, mode =3D 2 '\002=
',
no_redefine =3D false,=20
  files =3D {v =3D 0x0, len =3D 0, cap =3D 0, size =3D 0, dtor =3D 0}, expr=
s =3D {v =3D 0x0,
len =3D 0, cap =3D 0, size =3D 0, dtor =3D 0}, name =3D 0x7fffffffea8b "bc"=
, help =3D
0x2059b0 <bc_help> "usage: %s [options] [file...]\n\nbc is a command-line,
arbitrary-precision calculator with a Turing-complete\nlanguage. For detail=
s,
use `man %s` or see the online documentation at\nhttps://git.yzena.com/"...,
history =3D {el =3D 0x800a6a000, hist =3D 0x800a67000, badTerm =3D false}, =
next =3D
0x2113a0 <bc_lex_token>, parse =3D 0x2126c0 <bc_parse_parse>, expr =3D 0x21=
3430
<bc_parse_expr>, func_header =3D 0x80027f32c "Function:", err_ids =3D {0x80=
027f336
"Math error:", 0x80027f342 "Parse error:", 0x80027f34f "Runtime error:",
0x80027f35e "Fatal error:", 0x80027f36b "Warning:"}, err_msgs =3D {0x80027f=
374
"negative number", 0x80027f384 "non-integer number", 0x80027f397 "overflow:
number does not fit into a hardware number", 0x80027f3cc "divide by 0",
0x80027fa7c "memory allocation failed", 0x80027fa95 "I/O error", 0x80027fa9f
"cannot open file: %s", 0x80027fab4 "file is not text: %s", 0x80027fac9 "pa=
th
is a directory: %s", 0x80027fae1 "invalid command-line option: \"%s\"",
0x80027fb03 "option requires an argument: '%c' (\"%s\")", 0x80027fb2c "opti=
on
takes no arguments: '%c' (\"%s\")", 0x80027fb53 "invalid command-line option
argument: \"%s\"", 0x80027f901 "invalid ibase: must be [%lu, %lu]", 0x80027=
f923
"invalid obase: must be [%lu, %lu]", 0x80027f945 "invalid scale: must be [%=
lu,
%lu]", 0x80027f967 "invalid read() expression", 0x80027f981 "recursive read=
()
call", 0x80027f997 "variable or array element is the wrong type", 0x80027f9=
c3
"stack has too few elements", 0x80027f9de "stack for register \"%s\" has too
few elements", 0x80027fa0b "wrong number of parameters; need %zu, have %zu",
0x80027fa3a "undefined function: %s()", 0x80027fa53 "cannot use a void valu=
e in
an expression", 0x80027f3d8 "end of file", 0x80027f3e4 "invalid character
'%c'", 0x80027f3fb "string end cannot be found", 0x80027f416 "comment end
cannot be found", 0x80027f432 "invalid token", 0x80027f440 "invalid
expression", 0x80027f453 "empty expression", 0x80027f464 "invalid print or
stream statement", 0x80027f486 "invalid function definition", 0x80027f4a2
"invalid assignment: left side must be scale, ibase, obase, seed, last, var=
, or
array element", 0x80027f4ff "no auto variable found", 0x80027f516 "function
parameter or auto \"%s%s\" already exists", 0x80027f547 "block end cannot be
found", 0x80027f561 "cannot return a value from void function: %s()",
0x80027f590 "var cannot be a reference: %s", 0x80027f5ae "POSIX does not al=
low
names longer than 1 character: %s", 0x80027f5e5 "POSIX does not allow '#'
script comments", 0x80027f60e "POSIX does not allow the following keyword: =
%s",
0x80027f63d "POSIX does not allow a period ('.') as a shortcut for the last
result", 0x80027f683 "POSIX requires parentheses around return expressions",
0x80027f6b8 "POSIX does not allow the following operator: %s", 0x80027f6e8
"POSIX does not allow comparison operators outside if statements or loops",
0x80027f731 "POSIX requires 0 or 1 comparison operators per condition",
0x80027f76a "POSIX requires all 3 parts of a for loop to be non-empty",
0x80027f7a3 "POSIX requires a newline between a semicolon and a function
definition", 0x80027f7ea "POSIX does not allow exponential notation",
0x80027f814 "POSIX does not allow array references as function parameters",
0x80027f851 "POSIX does not allow void functions", 0x80027f875 "POSIX requi=
res
the left brace be on the same line as the function header", 0x80027f8be "PO=
SIX
does not allow strings to be assigned to variables or arrays"}, locale =3D
0x8004a9380 "pl_PL.UTF-8/pl_PL.UTF-8/pl_PL.UTF-8/pl_PL.UTF-8/pl_PL.UTF-8/C",
maxes =3D {36, 1000000000, 18446744073709551614, 18446744073709551615, 0},
last_base =3D 0, last_pow =3D 0, last_exp =3D 0, last_rem =3D 0, env_args_b=
uffer =3D 0x0,
env_args =3D {v =3D 0x0, len =3D 0, cap =3D 0, size =3D 0, dtor =3D 0}, zer=
o =3D {num =3D
0x23f27c <vm_data+2460>, rdx =3D 0, scale =3D 0, len =3D 0, cap =3D 1}, one=
 =3D {num =3D
0x23f278 <vm_data+2456>, rdx =3D 0, scale =3D 0, len =3D 1, cap =3D 1}, max=
 =3D {num =3D
0x23f238 <vm_data+2392>, rdx =3D 0, scale =3D 0, len =3D 3, cap =3D 8}, max=
2 =3D {num =3D
0x23f258 <vm_data+2424>, rdx =3D 0, scale =3D 0, len =3D 5, cap =3D 8}, max=
_num =3D
{709551616, 446744073, 18, 0, 0, 0, 0, 0}, max2_num =3D {768211456, 3746074=
31,
938463463, 282366920, 340, 0, 0, 0}, one_num =3D {1}, zero_num =3D {0}, fou=
t =3D {f =3D
0x8004a1b08}, ferr =3D {f =3D 0x8004a1c40}, catalog =3D 0x800a42000, buf =
=3D 0x2402f0
<output_bufs> "", buf_len =3D 0, slabs =3D {v =3D 0x800a44000 "", len =3D 1=
, cap =3D 32,
size =3D 16, dtor =3D 4}, redefined_kws =3D {false <repeats 37 times>}, tem=
ps_buf =3D
{0x0 <repeats 512 times>}}
+p errno
$3 =3D 2
+n
131             if (sig =3D=3D SIGWINCH)
+n
133                     if (BC_TTY)
+n
135                             el_resize(vm->history.el);
+n
136                     }
+n
144                     return;
+n
198     }
+n
_read () at _read.S:4
4       _read.S: No such file or directory.
+n
cerror () at /usr/src/lib/libc/amd64/sys/cerror.S:52
52              pushq   %rax
+n
cerror () at /usr/src/lib/libc/amd64/sys/cerror.S:53
53              call    PIC_PLT(CNAME(__error))
+bt
#0  cerror () at /usr/src/lib/libc/amd64/sys/cerror.S:53
#1  0x0000000000000004 in ?? ()
#2  0x00000008002a4365 in read_char (el=3D0x800a6a000,=20
    cp=3D0x7fffffffe294
L"\b\xffffe334=E7=BF=BF\x86587f0\x9d83834d\xffffe6a0=E7=BF=BF\xffffe688=E7=
=BF=BF")
    at /usr/src/contrib/libedit/read.c:287
#3  0x00000008002a47af in el_wgetc (el=3Del@entry=3D0x800a6a000,=20
    cp=3Dcp@entry=3D0x7fffffffe294
L"\b\xffffe334=E7=BF=BF\x86587f0\x9d83834d\xffffe6a0=E7=BF=BF\xffffe688=E7=
=BF=BF") at
/usr/src/contrib/libedit/read.c:406
#4  0x00000008002a49ab in read_getcmd (el=3D<optimized out>, cmdnum=3D<opti=
mized
out>,=20
    ch=3D<optimized out>) at /usr/src/contrib/libedit/read.c:233
#5  el_wgets (el=3D0x800a6a000, nread=3D0x7fffffffe334) at
/usr/src/contrib/libedit/read.c:519
#6  0x000000080029b199 in el_gets (el=3D0x0, nread=3D0x7fffffffe18a)
    at /usr/src/contrib/libedit/eln.c:75
#7  0x00000000002187e2 in bc_history_line (h=3D0x23ef10 <vm_data+1584>,=20
    vec=3D0x23ecf8 <vm_data+1048>, prompt=3D0x201cbd ">>> ") at ./src/histo=
ry.c:259
#8  0x0000000000235870 in bc_read_line (vec=3D0x23ecf8 <vm_data+1048>,
prompt=3D0x201cbd ">>> ")
    at ./src/read.c:250
#9  0x0000000000238d3e in bc_vm_readLine (clear=3Dtrue) at ./src/vm.c:1123
#10 0x000000000023b6f0 in bc_vm_stdin () at ./src/vm.c:1174
#11 0x000000000023a64d in bc_vm_exec () at ./src/vm.c:1510
#12 0x000000000023996e in bc_vm_boot (argc=3D1, argv=3D0x7fffffffe690) at
./src/vm.c:1700
#13 0x000000000021138c in bc_main (argc=3D1, argv=3D0x7fffffffe690) at
./src/bc.c:62
#14 0x000000000021a8c9 in main (argc=3D1, argv=3D0x7fffffffe690) at
./src/main.c:108
+q


What happens here is that the signal handler does not do too much, it tells
libedit to resize and then exits with an early "return". Since we are in a
read() system call, it will be interrupted.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-268076-227-kxt5hNp7nb>