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

Memory leak with long commands (commands_parser stack full) #2968

Open
cornerman opened this Issue Sep 18, 2017 · 4 comments

Comments

Projects
None yet
4 participants
@cornerman
Contributor

cornerman commented Sep 18, 2017

Output of i3 --moreversion 2>&- || i3 --version:

Binary i3 version: 4.14-93-ga3a7d04a (2017-09-18, branch "remotes/upstream/next") © 2009 Michael Stapelberg and contributors
Running i3 version: 4.14 (2017-09-04, branch "4.14") (pid 774)
Loaded i3 config: /home/cornerman/.i3/config (Last modified: Mon 18 Sep 2017 06:24:50 PM CEST, 799 seconds ago)

The i3 binary you just called: /usr/local/bin/i3
RUNNING BINARY DIFFERENT FROM BINARY ON DISK!
The i3 binary you are running: i3

URL to a logfile as per http://i3wm.org/docs/debugging.html:

http://logs.i3wm.org/logs/5643059551272960.bz2

What I did:

Thanks for fixing #2903, I tried it out, but now run into another problem: Long commands with more than 10 words can crash i3.

Reproduction:

Xephyr :1 &
DISPLAY=:1 i3 &
i3-msg -s $(DISPLAY=:1 i3 --get-socketpath) "swap container container container container container container container container container container"

What I saw:

Receiving this command, i3 crashes and the leak sanitizer reports memory leaks:

BUG: commands_parser stack full. This means either a bug in the code, or a new command which contains more than 10 identified tokens.
=================================================================
==6978==ERROR: LeakSanitizer: detected memory leaks

Why did I try this command?

I am maintaining a script to generate a bash completion script for i3 (https://github.com/cornerman/i3-completion). It runs bogus command against the i3 ipc interface and tries to find valid commands from the hints of the command parser ("Expected one of these tokens: ...").

And with the swap command the Expected tokens are a bit misleading (similar to the move ... to ... syntax):

i3-msg "swap container foobar"
Expected one of these tokens: 'container', 'with', 'id', 'con_id', 'mark'

What I expected instead:

It should not crash.

@i3bot i3bot added the 4.14 label Sep 18, 2017

@cornerman

This comment has been minimized.

Show comment
Hide comment
@cornerman

cornerman Sep 18, 2017

Contributor

Ok, I am actually sending a command with more than 10 identified tokens, because the command parser keeps on suggesting to add container to the swap command. Is this expected behaviour for such longs commands?

Contributor

cornerman commented Sep 18, 2017

Ok, I am actually sending a command with more than 10 identified tokens, because the command parser keeps on suggesting to add container to the swap command. Is this expected behaviour for such longs commands?

@Airblader Airblader added the bug label Sep 18, 2017

@cornerman cornerman changed the title from Memory leak after certain commands (commands_parser stack full) to Memory leak with long commands (commands_parser stack full) Sep 18, 2017

@orestisf1993

This comment has been minimized.

Show comment
Hide comment
@orestisf1993

orestisf1993 Sep 18, 2017

Member

This easily reproducible: commands with optional words can trigger the error. Eg i3-msg move window window window window window window window window window window.

Member

orestisf1993 commented Sep 18, 2017

This easily reproducible: commands with optional words can trigger the error. Eg i3-msg move window window window window window window window window window window.

@cornerman

This comment has been minimized.

Show comment
Hide comment
@cornerman

cornerman Sep 21, 2017

Contributor

I have now fixed the problem with the long swap command in i3-completion and i3 does not crash anymore. But the Addresssanitizer still reports about memory leaks: http://logs.i3wm.org/logs/5707931811053568.bz2

Contributor

cornerman commented Sep 21, 2017

I have now fixed the problem with the long swap command in i3-completion and i3 does not crash anymore. But the Addresssanitizer still reports about memory leaks: http://logs.i3wm.org/logs/5707931811053568.bz2

@orestisf1993

This comment has been minimized.

Show comment
Hide comment
@orestisf1993

orestisf1993 Mar 27, 2018

Member

I found one memory leak in #3205 using your utility, ignoring the leaks from libfontconfig.so and libc.so.

The issue you are describing (BUG: commands_parser stack full. This means either a bug in the code, or a new command which contains more than 10 identified tokens.) is unrelated to the leaks though.

Member

orestisf1993 commented Mar 27, 2018

I found one memory leak in #3205 using your utility, ignoring the leaks from libfontconfig.so and libc.so.

The issue you are describing (BUG: commands_parser stack full. This means either a bug in the code, or a new command which contains more than 10 identified tokens.) is unrelated to the leaks though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment