Lorsque je compile mon programme, il n'y a pas de problème, aucune
erreur détectée... par contre quand je lance mon programme, j'ai bien
le résultat de ma requête qui s'affiche mais avec à la fin un 'segment
fault (core dumped)'.
J'ai lu dans plusieurs posts que c'est parce que le programme accède à
une partie de la mémoire qui ne lui est pas autorisé... ok mais que
puis -je faire pour palier à ce problème???
Je teste en fait un programme en C qui puisse se connecter à une base
MySQL.
J'ai récupéré ce code source comme exemple:
http://www.linuxfocus.org/Francais/September2003/mysql_test.c
J'ai modifié juste les paramètres de connexion et tout le reste du
code ne change pas.
Voici le résultat:
[dibzou@localhost dibzou]$ gcc -Wall mysql_test.c -o test1 -L/usr/lib
-lz
-L/usr/lib/mysql -lmysqlclient
[dibzou@localhost dibzou]$./test1
Connexion etablie...
Requete : select * from carnet
Resultat de la requete :
toto toto@toto.com
titi titi@titi.com
Segmentation fault (core dumped)
[dibzou@localhost dibzou]$
Si vous pouviez m'aider, ca serait gentil pour que j'avance sous
Linux...
Merci.
[ dibzou]$ gcc -Wall mysql_test.c -o test1 -L/usr/lib -lz -L/usr/lib/mysql -lmysqlclient [ dibzou]$./test1 Connexion etablie... Requete : select * from carnet Resultat de la requete : toto titi Segmentation fault (core dumped) [ dibzou]$
ajouter -g pour gcc
gdb ./test1 run bt ...
(cf gdb howto)
dibzou
Francois Cartegnie wrote in message news:<425d9457$0$804$...
dibzou wrote:
> [ dibzou]$ gcc -Wall mysql_test.c -o test1 -L/usr/lib > -lz > -L/usr/lib/mysql -lmysqlclient > [ dibzou]$./test1 > Connexion etablie... > Requete : select * from carnet > Resultat de la requete : > toto > titi > Segmentation fault (core dumped) > [ dibzou]$
ajouter -g pour gcc
gdb ./test1 run bt ...
(cf gdb howto)
Voilà ce que cela donne: [ root]# gdb ./test1 GNU gdb 6.2-2mdk (Mandrakelinux) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i586-mandrake-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) run Starting program: /root/test1 Connexion etablie... Requete : select * from carnet Resultat de la requete : toto titi
Program received signal SIGSEGV, Segmentation fault. 0x0804871f in __do_global_dtors_aux () (gdb) bt #0 0x0804871f in __do_global_dtors_aux () #1 0x08048a0a in _fini () #2 0x080489c6 in __libc_csu_fini () #3 0x400954d7 in exit () from /lib/tls/libc.so.6 #4 0x0804893f in main () at mysql_test.c:76 (gdb)
Après recherche: description de SIGSEGV: 11 Invalid memory reference action : Default action is to dump core.
Je ne vois pas ce qu'il faut faire :(
Francois Cartegnie <NOSPAM@TAMAMAN.OWC> wrote in message news:<425d9457$0$804$636a15ce@news.free.fr>...
dibzou wrote:
> [dibzou@localhost dibzou]$ gcc -Wall mysql_test.c -o test1 -L/usr/lib
> -lz
> -L/usr/lib/mysql -lmysqlclient
> [dibzou@localhost dibzou]$./test1
> Connexion etablie...
> Requete : select * from carnet
> Resultat de la requete :
> toto toto@toto.com
> titi titi@titi.com
> Segmentation fault (core dumped)
> [dibzou@localhost dibzou]$
ajouter -g pour gcc
gdb ./test1
run
bt
...
(cf gdb howto)
Voilà ce que cela donne:
[root@localhost root]# gdb ./test1
GNU gdb 6.2-2mdk (Mandrakelinux)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "i586-mandrake-linux-gnu"...Using host
libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) run
Starting program: /root/test1
Connexion etablie...
Requete : select * from carnet
Resultat de la requete :
toto toto@toto.com
titi titi@titi.com
Program received signal SIGSEGV, Segmentation fault.
0x0804871f in __do_global_dtors_aux ()
(gdb) bt
#0 0x0804871f in __do_global_dtors_aux ()
#1 0x08048a0a in _fini ()
#2 0x080489c6 in __libc_csu_fini ()
#3 0x400954d7 in exit () from /lib/tls/libc.so.6
#4 0x0804893f in main () at mysql_test.c:76
(gdb)
Après recherche:
description de SIGSEGV: 11 Invalid memory reference
action : Default action is to dump core.
Francois Cartegnie wrote in message news:<425d9457$0$804$...
dibzou wrote:
> [ dibzou]$ gcc -Wall mysql_test.c -o test1 -L/usr/lib > -lz > -L/usr/lib/mysql -lmysqlclient > [ dibzou]$./test1 > Connexion etablie... > Requete : select * from carnet > Resultat de la requete : > toto > titi > Segmentation fault (core dumped) > [ dibzou]$
ajouter -g pour gcc
gdb ./test1 run bt ...
(cf gdb howto)
Voilà ce que cela donne: [ root]# gdb ./test1 GNU gdb 6.2-2mdk (Mandrakelinux) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i586-mandrake-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) run Starting program: /root/test1 Connexion etablie... Requete : select * from carnet Resultat de la requete : toto titi
Program received signal SIGSEGV, Segmentation fault. 0x0804871f in __do_global_dtors_aux () (gdb) bt #0 0x0804871f in __do_global_dtors_aux () #1 0x08048a0a in _fini () #2 0x080489c6 in __libc_csu_fini () #3 0x400954d7 in exit () from /lib/tls/libc.so.6 #4 0x0804893f in main () at mysql_test.c:76 (gdb)
Après recherche: description de SIGSEGV: 11 Invalid memory reference action : Default action is to dump core.
Je ne vois pas ce qu'il faut faire :(
Francois Cartegnie
dibzou wrote:
#4 0x0804893f in main () at mysql_test.c:76
Je ne vois pas ce qu'il faut faire :(
Que tu commence par regarder ligne 76 ce qui cause le core dump.
dibzou wrote:
#4 0x0804893f in main () at mysql_test.c:76
Je ne vois pas ce qu'il faut faire :(
Que tu commence par regarder ligne 76 ce qui cause le core dump.