bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pgrep and pkill (any? arguments): cannot allocate 4294967295 bytes


From: Paul Dufresne
Subject: Re: pgrep and pkill (any? arguments): cannot allocate 4294967295 bytes
Date: Tue, 02 Feb 2021 09:34:54 -0500
User-agent: Zoho Mail

Code seems to make an abnormal call... I think:

I include the first part to show that you need to cd to the source code directory for gdb to show you source lines.

root@kibar:~# gdb pgrep
GNU gdb (Debian 10.1-1.7+hurd.1) 10.1.90.20210103-git
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "i686-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from pgrep...
Reading symbols from /usr/lib/debug/.build-id/9d/db1b82ac5d2dbcf3848a674d389138555fce77.debug...
(gdb) l
907     pgrep.c: No such file or directory.
(gdb) q
root@kibar:~# ls
procps-3.3.16                  procps_3.3.16-5.dsc
procps_3.3.16-5.debian.tar.xz  procps_3.3.16.orig.tar.xz
root@kibar:~# cd procps-3.3.16/
root@kibar:~/procps-3.3.16# ls
AUTHORS            free.1       pgrep.1   ps         sysctl.c          vmstat.8
autogen.sh         free.c       pgrep.c   pwdx.1     sysctl.conf       vmstat.c
ChangeLog          include      pidof.1   pwdx.c     sysctl.conf.5     w.1
configure.ac       INSTALL.md   pidof.c   README.md  testsuite         watch.1
contrib            kill.1       pkill.1   skill.1    tload.1           watch.c
COPYING            lib          pmap.1    skill.c    tload.c           w.c
COPYING.LIB        Makefile.am  pmap.c    slabtop.1  top
create-man-pot.sh  man-po       po        slabtop.c  translate-man.sh
debian             misc         proc      snice.1    uptime.1
Documentation      NEWS         procio.c  sysctl.8   uptime.c
root@kibar:~/procps-3.3.16# gdb pgrep
GNU gdb (Debian 10.1-1.7+hurd.1) 10.1.90.20210103-git
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "i686-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from pgrep...
Reading symbols from /usr/lib/debug/.build-id/9d/db1b82ac5d2dbcf3848a674d389138555fce77.debug...
(gdb) set args testany
(gdb) l main
916                                          program_invocation_short_name);
917     }
918     
919     
920     int main (int argc, char **argv)
921     {
922             struct el *procs;
923             int num;
924     
925     #ifdef HAVE_PROGRAM_INVOCATION_NAME
(gdb) l 925
920     int main (int argc, char **argv)
921     {
922             struct el *procs;
923             int num;
924     
925     #ifdef HAVE_PROGRAM_INVOCATION_NAME
926             program_invocation_name = program_invocation_short_name;
927     #endif
928             setlocale (LC_ALL, "");
929             bindtextdomain(PACKAGE, LOCALEDIR);
(gdb) break 928
Breakpoint 1 at 0x11a5: file pgrep.c, line 928.
(gdb) run
Starting program: /usr/bin/pgrep testany
[New Thread 8553.5]

Thread 4 hit Breakpoint 1, main (argc=2, argv=0x1032e24) at pgrep.c:928
928             setlocale (LC_ALL, "");
(gdb) s
929             bindtextdomain(PACKAGE, LOCALEDIR);
(gdb) s
930             textdomain(PACKAGE);
(gdb) s
931             atexit(close_stdout);
(gdb) s
933             parse_opts (argc, argv);
(gdb) s
parse_opts (argv=0x1032e24, argc=2) at pgrep.c:690
690             char opts[64] = "";
(gdb) s
730             if (strstr (program_invocation_short_name, "pkill")) {
(gdb) s
main (argc=2, argv=0x1032e24) at pgrep.c:933
933             parse_opts (argc, argv);
(gdb) s
parse_opts (argv=0x1032e24, argc=2) at pgrep.c:740
740                     strcat (opts, "lad:vw");
(gdb) s
strcat (__src=0x803592d "lad:vw", __dest=0x1032d3c "")
    at /usr/include/i386-gnu/bits/string_fortified.h:128
warning: Source file is more recent than executable.
128       return __builtin___strcat_chk (__dest, __src, __bos (__dest));
(gdb) s
743             strcat (opts, "LF:cfinoxP:g:s:u:U:G:t:r:?Vh");
(gdb) s
0x0803331b in strcat (__src=0x8035934 "LF:cfinoxP:g:s:u:U:G:t:r:?Vh",
    __dest=0x1032d3c "lad:vw")
    at /usr/include/i386-gnu/bits/string_fortified.h:128
128       return __builtin___strcat_chk (__dest, __src, __bos (__dest));
(gdb) s
743             strcat (opts, "LF:cfinoxP:g:s:u:U:G:t:r:?Vh");
(gdb) s
0x08033335 in strcat (__src=0x8035934 "LF:cfinoxP:g:s:u:U:G:t:r:?Vh",
    __dest=0x1032d3c "lad:vwLF:cfinoxP:g:s:u:U:G:t:r:?Vh")
    at /usr/include/i386-gnu/bits/string_fortified.h:128
128       return __builtin___strcat_chk (__dest, __src, __bos (__dest));
(gdb) s
745             while ((opt = getopt_long (argc, argv, opts, longopts, NULL)) != -1) {
(gdb) s
894             if(opt_lock && !opt_pidfile)
(gdb) s
899             if(opt_pidfile){
(gdb) s
907             if (argc - optind == 1)
(gdb) s
908                     opt_pattern = argv[optind];
(gdb) s
main (argc=<optimized out>, argv=<optimized out>) at pgrep.c:935
935             procs = select_procs (&num);
(gdb) s
select_procs (num=0x1032c94) at pgrep.c:489
489     {
(gdb) s
498             pid_t myself = getpid();
(gdb) s
500             long cmdlen = sysconf(_SC_ARG_MAX) * sizeof(char);
(gdb) s
506             ptp = do_openproc();
(gdb) s
0x0803474d in do_openproc () at pgrep.c:434
434                     flags |= PROC_FILLCOM;
(gdb) s
xmalloc (size=4294967295) at ./include/xalloc.h:25
25              void *ret = malloc(size);
(gdb)

from cat -n pgrep.c:
  428  static PROCTAB *do_openproc (void)
   429  {
   430          PROCTAB *ptp;
   431          int flags = 0;
   432  
   433          if (opt_pattern || opt_full || opt_longlong)
   434                  flags |= PROC_FILLCOM;
   435          if (opt_ruid || opt_rgid)
   436                  flags |= PROC_FILLSTATUS;
   437          if (opt_oldest || opt_newest || opt_pgrp || opt_sid || opt_term)
   438                  flags |= PROC_FILLSTAT;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]