koljanos / wmr

Automatically exported from code.google.com/p/wmr
1 stars 0 forks source link

Segmentation fault #1

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Compile
2. Try to run
3. Get a segfault

What is the expected output? What do you see instead?

$ LD_LIBRARY_PATH=. ./wmrd 
- WMR: [0/584351822] (shared memory) Attach: 1 Creator: 18612 LastConnected: 
18612
Segmentation fault

What version of the product are you using? On what operating system?

wmr-oregon-0.4-2013-01-23
Ubuntu 13.10 64 bit

Please provide any additional information below.

Original issue reported on code.google.com by radomir....@gmail.com on 6 Nov 2013 at 7:43

GoogleCodeExporter commented 8 years ago
Hi!

I think the issue is due to incorrect usage of the basename function. The 
program name (argv[0]) has to be duplicated before sent as argument to the 
basename function because basename may modify the contents of the path argument.

I've just started using this software with my weather station and I don't know 
how to contribute with fixes and patches but the following change solved the 
segmentation fault problem:

Change the line wmr.c:387

fbname =  (char *) basename( (char **) argv[0]);

to something like this

char *path = strdup((const char*)argv[0]);
fbname =  (char *) basename(path);

/Andrei

Original comment by andrei.p...@gmail.com on 7 Jan 2014 at 8:48

GoogleCodeExporter commented 8 years ago
After some more investigation this seems to be a build issue.

According to the libc manual this is correct if the GNU version of the function 
basename is used (with some portability issues):

char *prog = basename (argv[0]);

However, for some reason  the standard XPG defined basename function is linked 
instead on my system, and it's probably because _GNU_SOURCE is not defined 
(outcommented on wmr.c:16).

Original comment by andrei.p...@gmail.com on 7 Jan 2014 at 9:23