From: Javi <ja...@gs...> - 2004-03-11 12:55:36
|
Hi list. I've created a MySQL section in lccd4linux.conf in order to get from there the server, login and password parameters to connect to MySQL. The problem is wherever I use cfg_get() function I get "Segmentation fault" when running lcd4linux. GDB doesn't give me any usefull information: # gdb --args lcd4linux -Fq GNU gdb 6.0 Copyright 2003 Free Software Foundation, Inc. (gdb) run Starting program: /home/javi/proyectos/lcd4linux/lcd4linux -Fq Program received signal SIGSEGV, Segmentation fault. 0x08062fd9 in ?? () (gdb) Any ideas? thanks,bye |
From: Michael R. <re...@eu...> - 2004-03-11 16:56:46
|
Hi Javier, > The problem is wherever I use cfg_get() function I get "Segmentation > fault" when running lcd4linux. Can you send me the code? > Program received signal SIGSEGV, Segmentation fault. 0x08062fd9 in ?? strange. Does "bt" or "u" work? -- Michael Reinelt Tel: +43 676 3079941 Geisslergasse 4 Fax: +43 316 692343 A-8045 Graz, Austria e-mail: re...@eu... |
From: Javi <ja...@gs...> - 2004-03-11 17:28:35
|
Hi. > > The problem is wherever I use cfg_get() function I get "Segmentation > > fault" when running lcd4linux. > Can you send me the code? Upsss ;) I forgot it Just insert char *get=cfg_get("MySQL","server","NOT FOUND"); wherever in pluging_mysql.c > > Program received signal SIGSEGV, Segmentation fault. 0x08062fd9 in ?? > strange. Does "bt" or "u" work? If it is inseted into my_MySQLquery(...) then: # gdb --args lcd4linux -Fq (gdb) run Starting program: /home/javi/proyectos/lcd4linux/lcd4linux -Fq Program received signal SIGSEGV, Segmentation fault. 0x08062fd9 in ?? () (gdb) bt #0 0x08062fd9 in ?? () #1 0x08054ca3 in my_MySQLquery (result=0x806f060, server=0x8060d40, login=0x8060d40, pass=0x8060d40, database=0x8060d40, query=0x8060d40) at plugin_mysql.c:79 #2 0x0804da18 in EvalTree (Root=0x806ef20) at evaluator.c:1007 #3 0x0804db29 in Eval (tree=0x806ef20, result=0xbffff010) at evaluator.c:1216 #4 0x0804fc8a in widget_text_update (Self=0x806d768) at widget_text.c:251 #5 0x0804f169 in timer_process (delay=0xbffff0c0) at timer.c:160 #6 0x0804a930 in main (argc=-1073745728, argv=0x805efc0) at lcd4linux.c:636 If it is inserted into plugin_init_mysq(...) then: # gdb --args lcd4linux -Fq (gdb) run Starting program: /home/javi/proyectos/lcd4linux/lcd4linux -Fq Program received signal SIGSEGV, Segmentation fault. 0x08062fd9 in ?? () (gdb) bt #0 0x08062fd9 in ?? () #1 0x08054f24 in plugin_init_mysql () at plugin_mysql.c:144 #2 0x08050b81 in plugin_init () at plugin.c:197 #3 0x0804a618 in main (argc=0, argv=0xbffff574) at lcd4linux.c:497 Bye |
From: Javi <ja...@gs...> - 2004-03-16 15:18:47
Attachments:
lcd4linux.conf
plugin_mysql.c
|
Hi all. First, I think there is a problem with the Makefile. The configure script detects I have MySQL and pluging_mysql.c is compiled, but when compiling, it shows errors like: undefined reference to `mysql_init' undefined reference to `mysql_real_connect' etc It's because MySQL libraries are in the mysqlclient library. So while compiling a MySQL program, it is necessary to add the -lmysqlclient compiler option. I don't know how makefile is generated, but it should include the -lmysqlclient compiler option if MySQL is installed. I've patched manually the Makefile adding "CC = gcc -lmysqlclient" but it is not very elegant. Now I return to my "loved" Segmentation fault ;) remeber: > > The problem is wherever I use cfg_get() function I get "Segmentation > > fault" when running lcd4linux. > > Can you send me the code? I enclose the code and a sample lcd4linux.conf. In order to test MySQL pluging , just change the display settings to fit your display. I've also created a MySQL account on my server, so developers can test the pluging (Only select privileges). Server, login, password and db are listed in the sample lcd4linux.conf file. Here is gdb output: Program received signal SIGSEGV, Segmentation fault. 0x080642a4 in cfg_get () (gdb) bt #0 0x080642a4 in cfg_get () #1 0x080552a1 in plugin_init_mysql () at plugin_mysql.c:143 #2 0x08050bc6 in plugin_init () at plugin.c:209 #3 0x0804a7c9 in main (argc=3, argv=0x1) at lcd4linux.c:529 Bye Javi. |
From: Xavier V. <xav...@fr...> - 2004-03-16 20:26:45
|
Hello Javi ! The solution to the claim was very simple, read this : gcc -lmysqlclient -DHAVE_CONFIG_H -I. -I. -I. -I/opt/X11R6/include -D_GNU_SOU RCE -Wall -g -O2 -c plugin_mysql.c plugin_mysql.c: In function `plugin_init_mysql': plugin_mysql.c:143: warning: implicit declaration of function `cfg_get' plugin_mysql.c:143: warning: initialization makes pointer from integer without a cast plugin_mysql.c:143: warning: unused variable `server' You forgot to include the "cfg.h" header :) Include cfg.h, and all will go well ! Bye ! -- Xavier VELLO ( who made his good action of the week :D ) |
From: Javi <ja...@gs...> - 2004-03-16 21:24:04
|
> Hello Javi ! > > You forgot to include the "cfg.h" header :) > Include cfg.h, and all will go well ! Where should I add "cfg.h"? I've added #include "cfg.h" into plugin_mysql.c, but I'm afraid it doesn't solve it :(. make clean make distclean-hdr ./configure make ... gcc -DHAVE_CONFIG_H -I. -I. -I. -I/usr/X11R6/include -D_GNU_SOURCE -Wall -g -O2 -c plugin_mysql.c ... undefined reference to `mysql_init' etc ... Thanks in advice. Javi |
From: Michael R. <re...@eu...> - 2004-03-17 06:24:06
|
Hi Javi, > Where should I add "cfg.h"? > I've added #include "cfg.h" into plugin_mysql.c, but I'm afraid it doesn't solve it :(. O, it will solve 'it', the question is what is 'it' :-) an '#include <cfg.h>' is necessary to use the cfg_get() function, ans should cure your segfault. It has nothing to do with the mysql stuff. bye, Michael -- Michael Reinelt Tel: +43 676 3079941 Geisslergasse 4 Fax: +43 316 692343 A-8045 Graz, Austria e-mail: re...@eu... |
From: Michael R. <re...@eu...> - 2004-03-17 06:31:48
|
Hi Javi, > First, I think there is a problem with the Makefile. The configure > script detects I have MySQL and pluging_mysql.c is compiled, but when > compiling, it shows errors like: You are right. The check for mysql.h is just a quick-hack. Please patch the makefile as you already did, until I found someone who can write me a good autoconf macro for this... [Segfault with cfg_get()] I've read the code, looks like Xavier is right: including cfg.h should solve this issue. I tried to code lcd4linux in a way so it does not emit *any* warning at compiling. (except thwo or three which come from the fact that the code isn't finished at the moment). If you get such a warning, chances are good that there's a mistake in your code, and that you should correct it. bye, Michael -- Michael Reinelt Tel: +43 676 3079941 Geisslergasse 4 Fax: +43 316 692343 A-8045 Graz, Austria e-mail: re...@eu... |
From: Xavier V. <xav...@fr...> - 2004-03-11 17:14:48
|
Hello Javi, hello list ! > I've created a MySQL section in lccd4linux.conf in order to get from there the server, login and password parameters to connect to MySQL. > The problem is wherever I use cfg_get() function I get "Segmentation fault" when running lcd4linux. > [...] > Any ideas? The problem may be in your variables. It will segfault it you use a plain variable and not a pointer. For example, I used for i2c_sensors : char *path_cfg=cfg_get(NULL, "i2c_sensors-path", ""); which would become for you : char *server=cfg_get("mysql", "server", ""); Bye ! -- Xavier VELLO <xav...@fr...> |
From: Michael R. <re...@eu...> - 2004-03-12 05:51:30
|
Hi Javi, >>>The problem is wherever I use cfg_get() function I get "Segmentation >>>fault" when running lcd4linux. >> >>Can you send me the code? > > Upsss ;) I forgot it > Just insert > char *get=cfg_get("MySQL","server","NOT FOUND"); > wherever in pluging_mysql.c As I cannot test because I don't have MySQL installed here, I'd need the full code. Normally if a library segfaults, it means that you passed wrong parameters. > #1 0x08054ca3 in my_MySQLquery (result=0x806f060, server=0x8060d40, login=0x8060d40, pass=0x8060d40, database=0x8060d40, query=0x8060d40) Strange: all pointers have the same address.... > #3 0x0804db29 in Eval (tree=0x806ef20, result=0xbffff010) at evaluator.c:1216 This pointer looks strange, too.... bye, Michael -- Michael Reinelt Tel: +43 676 3079941 Geisslergasse 4 Fax: +43 316 692343 A-8045 Graz, Austria e-mail: re...@eu... |
From: Xavier V. <xav...@fr...> - 2004-03-13 20:14:15
|
Hi Javi ! I suspect you're trowing a *char pointer to the connect function where it expects a char. Maybe you can try : char server; &server=cfg_get(...... Bye ! -- Xavier VELLO <xav...@fr...> |