Tomas-M / xlunch

Graphical app launcher for X with minimal dependencies
http://xlunch.org
GNU General Public License v3.0
219 stars 37 forks source link

Porting it to FreeBSD #106

Closed unix4you2 closed 5 years ago

unix4you2 commented 5 years ago

Hi @Tomas-M

I'm porting xlunch to FreeBSD 12 and I hope to port it for each new version of your launcher and the OS because I think is very efficient, simple and just do what people need when they have a simple desk. Thanks for your work (and for Slax too).

I did a little changed to your code replacing the constant POLLRDHUP for POLLHUP to get xlunch succefully compiled using gcc under FreeBSD:

    //eventfds[0].events = POLLIN || POLLPRI || POLLOUT || POLLRDHUP;
    eventfds[0].events = POLLIN || POLLPRI || POLLOUT || POLLHUP;

But when I try to run it I get a "Segmentation fault (core dumped)" message. Then when I go to debug it with gdb I get this:

(gdb) run
Program received signal SIGSEGV, Segmentation fault.
0x00000008009c821f in strlen () from /lib/libc.so.7
(gdb) bt full
#0  0x00000008009c821f in strlen () from /lib/libc.so.7
No symbol table info available.
#1  0x000000080079dccc in XSetClassHint () from /usr/local/lib/libX11.so.6
No symbol table info available.
#2  0x0000000000402ccf in main ()
No symbol table info available.
(gdb) 
Line number 67 out of range; /usr/src/lib/csu/amd64/reloc.c has 66 lines.

Do you have any idea what should I change to solve it?

Thanks for your time. Best regards.

Tomas-M commented 5 years ago

Hello, I have really no idea. I think POLLRDHUP was added by @PMunch, maybe he can provide more info. As far as I can see it requires _GNU_SOURCE, and from what i've read, using _GNU_SOURCE is not much portable, so maybe there will be more things requiring adjustment.

I am afraid I cannot help with this.

unix4you2 commented 5 years ago

There is no reasons to be afraid @Tomas-M GPL3 license is very clear about that kind of things in "15. Disclaimer of Warranty"... ..."PROVIDE THE PROGRAM "AS IS"... So the effort of an open source comunity is around that, everyone tries to help from their knowledge and you did your part creating this project.

Thanks for your time.

I'll be checking sources because this is a really nice launcher and I supose that many users in FreeBSD will like it because is simply, light and functional.

Regards

PMunch commented 5 years ago

Ah yes, it was me who added that. It's part of the functionality that allows xlunch to read input from a stream in progress and add elements on the fly instead of just statically reading in everything in the beginning of the program. According to the poll documentiation POLLHUP is only available for revents and is ignored in events, so adding that flag wont do anything. Can't quite remember if POLLRDHUP is required or not for this feature, I don't think it is. Removing it and building on Linux works just fine, so I don't think this is what's causing your segfault. Could you look in the Makefile and comment out CFLAGS and comment in the CFLAGS that enable debugging information? The stack trace you provided doesn't really contain any helpful information.

unix4you2 commented 5 years ago

Hi @PMunch thanks for your suggestions.

I re-build it in linux without POLLRDHUP and works fine. so I will delete that to be compliant with linux and BSD systems. This already compile over OpenBSD and FreeBSD without warnings or problems.

About the CFLAGS suggestion I change the file in this way and re-compile:

#CFLAGS ?= -O2 -s
CFLAGS ?= -ggdb -g3 # For debugging

And at build time this show this info with two warnings:

$ make test
gcc xlunch.c -o xlunch -lImlib2 -lX11 -O2 -pipe
xlunch.c: In function 'main':
xlunch.c:2413:31: warning: implicit declaration of function 'basename'; did you mean 'ptsname'? [-Wimplicit-function-declaration]
         classHint->res_name = basename(program_name);
                               ^~~~~~~~
                               ptsname
xlunch.c:2413:29: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
         classHint->res_name = basename(program_name);
                             ^
./xlunch -g extra/wp.jpg -f "extra/OpenSans-Regular.ttf/10" -i extra/sample_entries.dsv -b 140 --outputonly --iconpadding 20 --textpadding 10 --paddingswap --leastmargin 10 --highlight extra/highlight.png
*** Signal 11

Stop.
make: stopped in /mnt/datos/Usuario/Documentos/_TEMP_/BORRAR/xlunch-master

But this is finishing with a "Signal 11", so this means that the program accessed a memory location that was not assigned to it.

At run time and in gdb I see the same for now:

$ ./xlunch -W 
Segmentation fault (core dumped)

GDB:

Reading symbols from xlunch...done.
[New LWP 101481]
Core was generated by `./xlunch -W'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00000008009c821f in strlen () from /lib/libc.so.7

For me this appear to be a problem when xlunch includes in its build process to reloc.c in /lib/csu/amd64/reloc.c because if I change that file adding two blank lines at the end the problem appears two lines after two...

In normal build without change:

(gdb) 
Line number 67 out of range; /usr/src/lib/csu/amd64/reloc.c has 66 lines.

In a build after add two blank lines:

(gdb) 
Line number 69 out of range; /usr/src/lib/csu/amd64/reloc.c has 68 lines.

Any idea? Thanks again. Best regards

Tomas-M commented 5 years ago

Where is the basename() function defined on Linux? And where on BSD? Maybe add the following line at the top of xlunch.c ?

    #include <libgen.h>
unix4you2 commented 5 years ago

OMG!!! Thanks @Tomas-M last suggestion was the difference.

That works like a charm in FreeBSD and it's running now in my right monitor. I will check some details and check all the functionallity to submit this package as a port in FreeBSD (and maybe OpenBSD too).

xlunch

Thanks a lot @Tomas-M and @PMunch !

Tomas-M commented 5 years ago

It looks to me that basename() function is declared by string.h on Linux, not sure why that is not the case on FreeBSD, but anyway, I think we can safely add #include to xlunch.c. It compiles fine for me on Linux with the include. So I've updated the sources here: 7db2f51f3ab4391b2bc4457599c503b75445bb30