Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-alphanumeric names #110

Closed
hakavlad opened this issue Jan 22, 2019 · 12 comments
Closed

Non-alphanumeric names #110

hakavlad opened this issue Jan 22, 2019 · 12 comments

Comments

@hakavlad
Copy link
Contributor

hakavlad commented Jan 22, 2019

Example of output for some non-alphanumeric names:

янв 23 05:24:15 PC earlyoom[18493]: Low memory! At or below SIGKILL limits (mem: 1 %, swap: 1 %)
янв 23 05:24:15 PC earlyoom[18493]: mem avail:  200 of 13855 MiB ( 1 %), swap free:    0 of    0 MiB ( 0 %)
янв 23 05:24:15 PC earlyoom[18493]: [90B blob data]
янв 23 05:28:15 PC earlyoom[18493]: mem avail: 9861 of 13855 MiB (71 %), swap free:    0 of    0 MiB ( 0 %)

This strange behavior should be documented and explained.
What is [90B blob data]?

@hakavlad
Copy link
Contributor Author

And how --prefer and --avoid works with non-alphanumeric names?

@hakavlad
Copy link
Contributor Author

hakavlad commented Jan 22, 2019

Examples of cmdlines that was handled incorrectly: ./ЙЦУКЕНГШЩ, ./ячсмитьб, ./1ああああああああ1.

@hakavlad
Copy link
Contributor Author

With debug:

янв 23 06:02:47 PC earlyoom[19296]: pid 19296: badness   0 vm_rss   1860 earlyoom
янв 23 06:02:47 PC earlyoom[19296]: pid 19297: badness   0 vm_rss   3780 sudo
янв 23 06:02:47 PC earlyoom[19296]: pid 19298: badness   0 vm_rss   5340 journalctl
янв 23 06:02:47 PC earlyoom[19296]: [53B blob data]
янв 23 06:02:47 PC earlyoom[19296]:     ^ new victim (higher badness)
янв 23 06:02:47 PC earlyoom[19296]: [90B blob data]
янв 23 06:02:47 PC earlyoom[19296]: selecting victim and sending signal took 8.008 ms
янв 23 06:02:47 PC earlyoom[19296]: adaptive sleep time: 100 ms
янв 23 06:02:47 PC earlyoom[19296]: adaptive sleep time: 461 ms

@hakavlad
Copy link
Contributor Author

Killing process '...' with signal 9, pid: 19368, badness: 702, VmRSS: 9714 MiB is not displayed.

@rfjakob
Copy link
Owner

rfjakob commented Jan 22, 2019

How do you view the log file? Can you try journalctl -a ?

@hakavlad
Copy link
Contributor Author

hakavlad commented Jan 22, 2019

How do you view the log file?

sudo journalctl -eu earlyoom
or realtime view:
sudo journalctl -fu earlyoom

@hakavlad
Copy link
Contributor Author

hakavlad commented Jan 22, 2019

Output in terminal:

mem avail: 8297 of 13855 MiB (59 %), swap free:    0 of    0 MiB ( 0 %)
mem avail: 5708 of 13855 MiB (41 %), swap free:    0 of    0 MiB ( 0 %)
mem avail: 2796 of 13855 MiB (20 %), swap free:    0 of    0 MiB ( 0 %)
Low Memory! At or below SIGTERM limits (mem: 10 %, swap: 10 %)
mem avail: 1410 of 13855 MiB (10 %), swap free:    0 of    0 MiB ( 0 %)
Killing process 'ячсмить�' with signal 15, pid: 19504, badness: 605, VmRSS: 8367 MiB
mem avail: 9768 of 13855 MiB (70 %), swap free:    0 of    0 MiB ( 0 %)
mem avail: 9759 of 13855 MiB (70 %), swap free:    0 of    0 MiB ( 0 %)

@hakavlad
Copy link
Contributor Author

hakavlad commented Jan 22, 2019

journalctl -a:

янв 23 06:12:30 PC earlyoom[19296]: pid 19298: badness   0 vm_rss   5964 journalctl
янв 23 06:12:30 PC earlyoom[19296]: pid 19443: badness 704 vm_rss 9971980 ячсмить<D0>
янв 23 06:12:30 PC earlyoom[19296]:     ^ new victim (higher badness)
янв 23 06:12:30 PC earlyoom[19296]: Killing process 'ячсмить<D0>' with signal 9, pid: 19443, badness: 704, VmRSS: 9738 MiB
янв 23 06:12:30 PC earlyoom[19296]: selecting victim and sending signal took 7.948 ms
янв 23 06:12:30 PC earlyoom[19296]: adaptive sleep time: 100 ms
янв 23 06:12:30 PC earlyoom[19296]: adaptive sleep time: 438 ms
янв 23 06:12:31 PC earlyoom[19296]: adaptive sleep time: 1000 ms

@hakavlad
Copy link
Contributor Author

hakavlad commented Jan 22, 2019

In nohang I get

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 20: invalid continuation byte

at

        with open('/proc/' + pid + '/status') as f:
            for line in f:

By the way, cmdline was handled correctly.

@hakavlad
Copy link
Contributor Author

hakavlad commented Jan 22, 2019

Short unicode names (like йцук) was handled correctly. This problem appears if len(name) > 15 bytes.

@hakavlad
Copy link
Contributor Author

hakavlad commented Jan 23, 2019

Journalctl output with blob data if a process with the Unicode name is in the process list (without earlyoom):

янв 23 16:46:58 PC kernel: [19734]  1000 19734   194620     2022     229       4        0             0 kate
янв 23 16:46:58 PC kernel: [20437]     0 20437    79344      424      57       3        0             0 packagekitd
янв 23 16:46:58 PC kernel: [21057]  1000 21057   231392     7771     259       4        0             0 dolphin
янв 23 16:46:58 PC kernel: [92B blob data]
янв 23 16:46:58 PC kernel: [24555]  1000 24555   787871   186037     857       6        0             0 firefox-esr
янв 23 16:46:58 PC kernel: [24697]  1000 24697   782208   190934     861       6        0             0 firefox-esr
янв 23 16:46:58 PC kernel: [25998]  1000 25998   651199    41884     388       6        0             0 Web Content
янв 23 16:46:58 PC kernel: [26856]  1000 26856   194620     2006     223       3        0             0 kate
янв 23 16:46:58 PC kernel: [27225]  1000 27225    49826      543      81       3        0             0 file.so
янв 23 16:46:58 PC kernel: [27233]  1000 27233   589991    24892     409       5        0             0 vlc
янв 23 16:46:58 PC kernel: [27443]  1000 27443   504571    32843     368       5        0             0 Web Content
янв 23 16:46:58 PC kernel: [27672]  1000 27672  2718374  2713392    5314      15        0             0 python3
янв 23 16:46:58 PC kernel: Out of memory: Kill process 27672 (python3) score 766 or sacrifice child
янв 23 16:46:58 PC kernel: Killed process 27672 (python3) total-vm:10873496kB, anon-rss:10853568kB, file-rss:0kB, shmem-rss:0kB
янв 23 16:47:32 PC sudo[27685]:     user : TTY=pts/0 ; PWD=/home/user ; USER=root ; COMMAND=/bin/journalctl -e
янв 23 16:47:32 PC sudo[27685]: pam_unix(sudo:session): session opened for user root by (uid=0)

May be it is a journalctl bug and it is not a bug for earlyoom. But output may be fixed if you remove bad bytes from names like this:

with open('/proc/' + pid + '/stat', 'rb') as f:
    line = f.read().decode('utf-8', 'ignore')

I don't know how to do it in C, but I have already solved this problem in nohang.

@rfjakob
Copy link
Owner

rfjakob commented Apr 28, 2019

The problem is that the kernel truncates the name after 16 bytes, which may leave broken utf8 multibyte sequences. Fixed now in earlyoom via fix_truncated_utf8
(

earlyoom/msg.c

Line 128 in 8887f63

void fix_truncated_utf8(char *str) {
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants