Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Jul 2000 17:54:49 +0000
From:      Gustavo Vieira Goncalves Coelho Rios <kernel@tdnet.com.br>
To:        questions@freebsd.org
Subject:   VERY WEIRD PROBLEM
Message-ID:  <39773CE9.497E8E81@tdnet.com.br>

next in thread | raw e-mail | index | archive | help
Dear gentleman,

I have cvsupped my system and now some programs i wrote are totally
crazy!

I will explain:

my argv values is changing on the fly, i would like to known if some of
you have ever faced such a situation? I am desperatly looking for help!

Just to give you an ideia about what is happening:

my add.c :

#include <mysql/mysql.h>
#include <stdio.h>
#include <unistd.h>

#include "db.h"
#include "pop_add.h"

int
main(int argc, const char **argv)
{
        MYSQL   *mysql;

        if (argc != 2)
                _exit(1);

        mysql = mysql_init(NULL);
        mysql_real_connect(mysql, HOST, USER, PASS, DB, PORT, U_SOCK,
FLAGS);

        pop_add(mysql, argv[1]);

        mysql_close(mysql);

        return 0;
}


my pop_add.c:
#include <mysql/mysql.h>
#include <sys/types.h>
#include <pwd.h>
#include <stdio.h>

unsigned int
pop_add(MYSQL *mysql, const char *login)
{
        struct passwd   *pw;
        char            query[256];

        if ((pw = getpwnam(login)))
                return 1;

        sprintf(query, "insert ignore into pop set
uid='%u',gid='%u',name='%s'", pw-
>pw_uid, pw->pw_gid, pw->pw_name);

        if (mysql_query(mysql, query))
                return 2;
        else if (mysql_affected_rows(mysql) == 1)
                return 0;
        else
                return 3;
}



My gdb session
grios@etosha:~/projects/am2/stub/pop$ gdb add
GNU gdb 4.18
Copyright 1998 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 "i386-unknown-freebsd"...
(gdb) break main
Breakpoint 1 at 0x8048613: file add.c, line 13.
(gdb) run pop
Starting program: /usr/home/grios/projects/am2/stub/pop/add pop

Breakpoint 1, main (argc=2, argv=0xbfbff78c) at add.c:13
13              if (argc != 2)
(gdb) p argc
$1 = 2
(gdb) p argv
$2 = (char **) 0x80485ac
(gdb) n
16              mysql = mysql_init(NULL);
(gdb) p mysql
$3 = (MYSQL *) 0x2
(gdb) n
17              mysql_real_connect(mysql, HOST, USER, PASS, DB, PORT,
U_SOCK, FLAGS);
(gdb) p mysql
$4 = (MYSQL *) 0x804b000
(gdb) n
19              pop_add(mysql, argv[1]);
(gdb) s
pop_add (mysql=0x0, login=0x0) at pop_add.c:8
8       {
(gdb) n
12              if ((pw = getpwnam(login)))
(gdb) p mysql
$5 = (MYSQL *) 0x804b000
(gdb) p login
$6 = 0x0
(gdb) n
13                      return 1;
(gdb) n
0x80486f9       22                      return 3;
(gdb) n
main (argc=2, argv=0xbfbff78c) at add.c:21
21              mysql_close(mysql);
(gdb) p argv
$7 = (char **) 0x1
(gdb) p mysql
$8 = (MYSQL *) 0x804b000
(gdb) n
23              return 0;
(gdb) n
0x80485a5 in _start ()
(gdb) n
Single stepping until exit from function _start, 
which has no line number information.

Program exited normally.


As you can see, my argv changes on the fly, what is happening ?

My system is: FreeBSD etosha 4.1-RC FreeBSD 4.1-RC #10: Tue Jul 18
11:42:45 GMT 2000     root@etosha:/usr/src/sys/compile/ETOSHA  i386


Thanks a lot for your time and cooperation


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?39773CE9.497E8E81>