Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
* [lttng-dev] lttng list -u return "Error: Command error"
@ 2015-06-04  3:00 zhenyu.ren
  2015-06-23 22:03 ` Jérémie Galarneau
  0 siblings, 1 reply; 2+ messages in thread
From: zhenyu.ren @ 2015-06-04  3:00 UTC (permalink / raw)


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?

Thanks
zhenyu.ren



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [lttng-dev] lttng list -u return "Error: Command error"
  2015-06-04  3:00 [lttng-dev] lttng list -u return "Error: Command error" zhenyu.ren
@ 2015-06-23 22:03 ` Jérémie Galarneau
  0 siblings, 0 replies; 2+ messages in thread
From: Jérémie Galarneau @ 2015-06-23 22:03 UTC (permalink / raw)


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>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-23 22:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-04  3:00 [lttng-dev] lttng list -u return "Error: Command error" zhenyu.ren
2015-06-23 22:03 ` Jérémie Galarneau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox