- 论坛徽章:
- 0
|
下面程序向一个线程传递参数 aa
传递前后的值不一致,是什么原因?
谢谢!
代码:
site.host = "192.168.1.30";
site.port = 7000;
aa.sites = &site;
aa.dbenv = db_env;
aa.home = "/usr/local/database/data/dbfile/";
aa.progname = "dbsrvd";
aa.machtab = machtab[db_no];
if ((ret = pthread_create(&all_thr[db_no], NULL, connect_all, &aa)) != 0){
传递前aa的值为:
(gdb) p aa
$9 = {dbenv = 0x84e1858,
progname = 0x805e600 "dbsrvd",
home = 0x805e420 "/usr/local/database/data/dbfile/",
machtab = 0x8451840,
sites = 0xbffea690, nsites = 2}
(gdb) p aa.sites->port
$10 = 7000
(gdb) p aa.sites->host
$11 = 0x805e618 "192.168.1.30"
传递后aa的值为:
(gdb) p *aa
$30 = {dbenv = 0x8523e48,
progname = 0x805e420 "/usr/local/database/data/dbfile/",
home = 0x4f041 <Address 0x4f041 out of bounds>,
machtab = 0x1ff, sites = 0xbffea690, nsites = 2}
(gdb) p sites->port
$31 = 3221224196
(gdb) p sites->host
$32 = 0x8523e48 ""
[ 本帖最后由 xyhost 于 2006-9-22 19:19 编辑 ] |
|