>>>>> "Derek" == Derek Callaway <super@stripped> writes:
Derek> I'm writing a program using the MySQL C API. After linked the
Derek> program with -lmysqlclient it started mysteriously core dumping. gdb says
Derek> that the problem lies within the mysql_once_init function.
Derek> #0 0x400773f2 in chunk_alloc (ar_ptr=0x40107580, nb=128) at malloc.c:2784
Derek> #1 0x40076b8a in __libc_malloc (bytes=120) at malloc.c:2616
Derek> #2 0x4007049e in _IO_getdelim (lineptr=0xbffff038, n=0xbffff03c,
Derek> delimiter=10, fp=0x804d698) at iogetdelim.c:67
Derek> #3 0x4006f7dc in __getline (lineptr=0xbffff038, n=0xbffff03c,
Derek> stream=0x804d698) at getline.c:35
Derek> #4 0x400dc88d in nss_parse_file (fname=0x38 "") at nsswitch.c:510
Derek> #5 0x400dbd2a in __nss_database_lookup (database=0x40102291 "services",
Derek> alternate_name=0x0, defconfig=0x0, ni=0x4010866c) at nsswitch.c:98
Derek> #6 0x400dd030 in __nss_services_lookup (ni=0xbffff098,
Derek> fct_name=0x401024f7 "getservbyname_r", fctp=0xbffff09c) at
Derek> XXX-lookup.c:61
Derek> #7 0x400e1188 in __getservbyname_r (name=0x4011c0b8 "mysql",
Derek> proto=0x4011c0b4 "tcp", resbuf=0x4010b950, buffer=0x80528e8 "",
Derek> buflen=1024, result=0xbffff0d0) at ../nss/getXXbyYY_r.c:149
Derek> #8 0x400e10fd in getservbyname (name=0x4011c0b8 "mysql",
Derek> proto=0x4011c0b4 "tcp") at ../nss/getXXbyYY.c:133
Derek> #9 0x401121e6 in mysql_once_init ()
Derek> #10 0x40036cb3 in __libc_start_main (main=0x8049640 <main>, argc=1,
Derek> argv=0xbffffd94, init=0x8048f58 <_init>, fini=0x804ba1c
> <_fini>,
Derek> rtld_fini=0x4000a350 <_dl_fini>, stack_end=0xbffffd8c)
Derek> at ../sysdeps/generic/libc-start.c:78
Derek> I've looked everywhere for information on this mysql_once_init function
Derek> and haven't found anything useful. I'm assuming it's similar to
Derek> mysql_init() which I'm already useing in my program. Also, this
Derek> mysql_once_init function seems to be overwriting memory which I have
Derek> already malloc()'ed. I have an array of pointers to char (char
Derek> *array[100];) that point to malloc()'ed memory. Data that this
Derek> mysql_once_init function gets in the allocated memory somehow. Does
Derek> anybody know what's going on here?
Derek> Derek Callaway <super@stripped>
Derek> Programmer -- CE Net, Inc.
Hi!
If you have already called my_init() then my_once_init() should only
call my_thread_init() which should NOT destroy any memory.
Can you find out on which line your memory gets destroyed ?
Are you sure you are not using an old set of include files with a new
libmysqlclient library?
Regards,
Monty