cgroup: fix panic in parse memory.numa_stat#2751
Conversation
|
|
||
| for _, column := range columns { | ||
| pagesByNode := strings.SplitN(column, numaStatKeyValueSeparator, numaStatColumnSliceLength) | ||
| if len(pagesByNode) != 2 { |
There was a problem hiding this comment.
nit: s/2/numaStatColumnSliceLength/
strings.SplitN not always return N fields if not staify, sometimes cgroup interface add some custom fields make parse memory.numa_stat fails, it will case panic Signed-off-by: acetang <aceapril@126.com>
|
@Ace-Tang can you show the contents of For the record, here's kernel doc about memory.numa_stat (from https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt) |
|
|
dqminh
left a comment
There was a problem hiding this comment.
The check is reasonable. However, it would be nice if we can add a failing test.
|
Ah, OK, I was not able to find these kernel patches in the wild -- the most similar one is "sched/numa: introduce per-cgroup NUMA locality info" from Alibaba's Michael Wang (which also adds some non-standard fields to I took a look at the code and found that if someone ever adds some line that will contain In the meantime, LGTM |
|
@dqminh can we merge this hotfix as it is? I'm working on more robust parser and will add more tests. |
|
@kolyshkin lets go with #2755 . Thanks @Ace-Tang very much for your fix ! |
|
Thanks |

strings.SplitN not always return N fields if not staify, sometimes
cgroup interface add some custom fields make parse memory.numa_stat
fails, it will case panic
Signed-off-by: acetang aceapril@126.com
Fix panic in parse memory.numa_stat, since memory.numa_stat was add some custom fields that make splitN fail
