Re: segfault on initial word completion
On Wed, Apr 19, 2023, 10:23 Chet Ramey wrote: > On 4/18/23 6:15 PM, Grisha Levit wrote: > > $ bash --rcfile <(echo 'complete -C: -I') -i <<<$'; \cA\t' > > bash-5.2$ bash: xmalloc: cannot allocate 18446744073709551615 bytes > > $ bash --rcfile <(echo 'complete -C: -I') -i <<<$';\cA \t' > > bash-5.2$ Segmentation fault: 11 > > > > Thanks for the report. > One more issue after the fix, the start can end up being further than pcomp_ind bash --rcfile <(echo 'complete -C: -I') -i <<<$' \cA\t' ERROR: AddressSanitizer: heap-buffer-overflow READ of size 1 at 0x0044e7a7d22f thread T0 #0 0x63e8175148 in bind_compfunc_variables pcomplete.c:946:7 #1 0x63e816afb0 in gen_command_matches pcomplete.c:1179:3 #2 0x63e8165358 in gen_compspec_completions pcomplete.c:1389:18 #3 0x63e81700e0 in gen_progcomp_completions pcomplete.c:1539:9 #4 0x63e816eb7c in programmable_completions pcomplete.c:1592:13 #5 0x63e810b4b8 in attempt_shell_completion bashline.c:1745:26
Re: How difficult would it be to add a timeout to "wait"?
On 4/21/23 11:34 AM, Dale R. Worley wrote: My interest here isn't "Can I accomplish this task with Bash?" but quite literally, Can I make this a *feature* of Bash so I don't have to set up the mechanics? (I already know of a couple of other ways to do it with Bash.) My point is that if it's easy enough -- and it is -- to do it without adding features to bash itself, then there's not a compelling argument, nor sufficient demand, to add more code to bash. So then fleshing this out, let me ask: Is it reasonable to add an optional timeout to the "wait" builtin using this mechanism? See above. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: How difficult would it be to add a timeout to "wait"?
Chet Ramey writes: > On 4/20/23 1:53 PM, Dale R. Worley wrote: >> How difficult would it be to add an optional timeout argument to the >> "wait" builtin? > > Try a variant of this. > ... My interest here isn't "Can I accomplish this task with Bash?" but quite literally, Can I make this a *feature* of Bash so I don't have to set up the mechanics? (I already know of a couple of other ways to do it with Bash.) An interesting point, which you may or may not have intended, was that this Bash code can be turned into C code fairly easily: Fork a subprocess to wait for the timeout and when it fires, send USR1 to Bash. Then make sure Bash is waiting for the timeout subprocess as well as whatever other children it should be waiting for. My *reflex* is that this is a really heavyweight implementation, but on consideration, I think I'm wrong: fork() is cheap in Un*x, indeed, that may have been its central design innovation, make processes cheap and use them freely. So then fleshing this out, let me ask: Is it reasonable to add an optional timeout to the "wait" builtin using this mechanism? Dale