[lttng-dev] lttng list -u return "Error: Command error"

Jérémie Galarneau jeremie.galarneau at efficios.com
Tue Jun 23 18:03:12 EDT 2015


On Thu, Jun 4, 2015 at 5:00 AM, zhenyu.ren <zhenyu.ren at aliyun.com> wrote:

> Hi,dev-team
>
>    As the subject is my problem. It seems that the function
> get_cmdline_by_pid() will fail if kernel.pid_max > 100000 (i.e. 131072)
>
> static char *get_cmdline_by_pid(pid_t pid)
> {
>         int ret;
>         FILE *fp = NULL;
>         char *cmdline = NULL;
>         char path[20];        /* Can't go bigger than /proc/65535/cmdline
> */
>
>
>  I think path[20] is not big enough .Do you have any better idea?
>

Good catch! Sorry for the delay, traveling has caused me to fall behind on
e-mails... Catching up!

Based on PROC(5):

       /proc/sys/kernel/pid_max (since Linux 2.5.34)
              This  file  specifies the value at which PIDs wrap around
              (i.e., the value in this file is  one  greater  than  the
              maximum PID).  PIDs greater than this value are not allo‐
              cated; thus, the value in this file also acts as  a  sys‐
              tem-wide  limit  on  the  total  number  of processes and
              threads.  The default value for this file, 32768, results
              in  the  same  range  of  PIDs as on earlier kernels.  On
              32-bit platforms, 32768 is the maximum value for pid_max.
              On  64-bit systems, pid_max can be set to any value up to
              2^22 (PID_MAX_LIMIT, approximately 4 million).

I have introduced a fix in master, stable-2.6 and stable-2.5.

commit fae9a062a468c47fc71ef7aa96374bf9d87d137e
Author: Jérémie Galarneau <jeremie.galarneau at efficios.com>
Date:   Tue Jun 23 23:27:31 2015 +0200

    Fix: get_cmdline_by_pid path length assumes a max pid of 65535

    PROC(5) mentions that "On 64-bit systems, pid_max can be set to any
    value up to 2^22 (PID_MAX_LIMIT, approximately 4 million)."

    We use 32 bits for simplicity's sake.

    Reported-by: Zhenyu Ren <zhenyu.ren at aliyun.com>
    Signed-off-by: Jérémie Galarneau <jeremie.galarneau at efficios.com>


Thanks!
Jérémie



>
> Thanks
> zhenyu.ren
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20150624/92e197ff/attachment.html>


More information about the lttng-dev mailing list