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

maximizing window sends SIGABRT which segfaults afterwards #37

Closed
matu3ba opened this issue Nov 26, 2021 · 9 comments
Closed

maximizing window sends SIGABRT which segfaults afterwards #37

matu3ba opened this issue Nov 26, 2021 · 9 comments

Comments

@matu3ba
Copy link

matu3ba commented Nov 26, 2021

Running with gdb --ex run ./havoc and maximizing (moving out of bound on upper part) in KDE Plasma on Wayland has the following behavior. Note, that resizing to halfsize (left and right side) or moving terminal out of bounds does not have the problem.

Starting program: /home/misterspoon/dev/git/c/havoc/havoc 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[Detaching after fork from child process 376481]

Program received signal SIGABRT, Aborted.
0x00007ffff7c56d22 in raise () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff7c56d22 in raise () from /usr/lib/libc.so.6
#1  0x00007ffff7c40862 in abort () from /usr/lib/libc.so.6
#2  0x0000555555559a0f in main ()

Valgrind with valgrind ./havoc shows additionally

==376548== Process terminating with default action of signal 6 (SIGABRT): dumping core
==376548==    at 0x4A6BD22: raise (in /usr/lib/libc-2.33.so)
==376548==    by 0x4A55861: abort (in /usr/lib/libc-2.33.so)
==376548==    by 0x10DA0E: main (in /home/misterspoon/dev/git/c/havoc/havoc)
@ii8
Copy link
Owner

ii8 commented Dec 13, 2021

Hm I don't use KDE myself. Maximizing or moving the window up and out works fine in sway and weston.

Could you run it with debugging symbols in gdb and tell me at which line number it aborts?

@ii8
Copy link
Owner

ii8 commented Dec 13, 2021

Here is how you can make a debug version:

make clean
make CFLAGS="-g -O0"

Also there is no segfault it looks like, the program just ends because of the abort call.

@matu3ba
Copy link
Author

matu3ba commented Dec 14, 2021

I guess I need to dig into the KDE logs for this. Can you give me a starting point where to look for a look of screen/window actions and what caused them?

@ii8
Copy link
Owner

ii8 commented Dec 14, 2021

We don't need kde logs for now, maybe later though.
The first thing to find out is which abort call in havoc it is.

To do that you just have to compile a debug version of havoc like this:

make clean
make CFLAGS="-g -O0"

Then run it in gdb again and make it crash like you did before, then we will see the line number where the abort happened. That will help with finding out what is causing it.

@matu3ba
Copy link
Author

matu3ba commented Dec 14, 2021

on 1a5a6ce

make clean
make CFLAGS="-g -O0"
gdb --ex run ./havoc
(gdb) bt
#0  0x00007ffff7c55d22 in raise () from /usr/lib/libc.so.6
#1  0x00007ffff7c3f862 in abort () from /usr/lib/libc.so.6
#2  0x000055555555f7c7 in swap_buffers () at main.c:562
#3  0x000055555555ffd9 in redraw () at main.c:709
#4  0x0000555555562e22 in main (argc=1, argv=0x7fffffffe1b0) at main.c:1957
(gdb) l
1814				    " Use empty string for defaults.\n"
1815		      "  -l         Keep window open after the child process exits.\n"
1816		      "  -s <name>  Wayland display server to connect to.\n"
1817		      "  -i <id>    Wayland app ID to use instead of \"havoc\".\n"
1818		      "  -v         Show version information.\n"
1819		      "  -h         Show this help.\n");
1820	}
1821	
1822	#define take(s) (*(argv+1) \
1823		? *++argv \

abort() gets called here:

static struct buffer *swap_buffers(void)
{
	struct buffer *buf;

	assert(term.configured);

	if (!term.buf[0].busy)
		buf = &term.buf[0];
	else if (!term.buf[1].busy)
		buf = &term.buf[1];
	else
		abort();

	if (term.resize) {
		buffer_unmap(buf);
		if (buffer_init(buf) < 0)
			abort();
	}

	return buf;
}

@ii8
Copy link
Owner

ii8 commented Dec 14, 2021

So it looks like the KDE compositor is telling havoc to redraw without releasing buffers first.
I've added error messages instead of just aborting but I can't do much more I think, no way to redraw if there are no buffers to use so it will now freeze instead (which doesn't matter I guess if its offscreen).

@matu3ba
Copy link
Author

matu3ba commented Dec 14, 2021

works now, thanks alot!

One last question: Do you think I should file a bug upstream for this behavior?

@matu3ba matu3ba closed this as completed Dec 14, 2021
@ii8
Copy link
Owner

ii8 commented Dec 14, 2021

I will do it myself, it'll be easier for me to explain I think.

@ii8
Copy link
Owner

ii8 commented Dec 14, 2021

The report is here: https://bugs.kde.org/show_bug.cgi?id=446978
@matu3ba could you add a comment there telling them the kde version and linux distro you are using, thanks.

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