Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

malloc setting errno even if fine



Hi!

I've been debugging a program and found that malloc changes errno even
when it's not reporting an error in the end. In my case, fseeko
returned no error, but still errno was set.

The flow is like this:

Breakpoint 2, malloc_init_hard () at 
/archive/cvs/src/lib/libc/stdlib/jemalloc.c:3323
3323    {
(gdb) n
3329            malloc_mutex_lock(&init_lock);
(gdb) disp errno
1: errno = 0
(gdb) n
3330            if (malloc_initialized) {
1: errno = 0
(gdb)
3344                    mib[0] = CTL_HW;
1: errno = 0
(gdb)
3345                    mib[1] = HW_NCPU;
1: errno = 0
(gdb)
3346                    len = sizeof(ncpus);
1: errno = 0
(gdb)
3347                    if (sysctl(mib, 2, &ncpus, &len, (void *) 0, 0) == -1) {
1: errno = 0
(gdb)
3357                    result = sysconf(_SC_PAGESIZE);
1: errno = 0
(gdb)
3359                    pagesize = (unsigned) result;
1: errno = 0
(gdb)
3366                    pagesize_mask = result - 1;
1: errno = 0
(gdb)
3367                    pagesize_2pow = ffs((int)result) - 1;
1: errno = 0
(gdb)
3372                    switch (i) {
1: errno = 0
(gdb)
42      __ssp_redirect(ssize_t, readlink, (const char *__restrict __path, \
1: errno = 0
(gdb)
3374                            if ((linklen = readlink("/etc/malloc.conf", buf,
1: errno = 2
(gdb) l
3369
3370            for (i = 0; i < 3; i++) {
3371                    /* Get runtime configuration. */
3372                    switch (i) {
3373                    case 0:
3374                            if ((linklen = readlink("/etc/malloc.conf", buf,
3375                                                    sizeof(buf) - 1)) != 
-1) {
3376                                    /*
3377                                     * Use the contents of the 
"/etc/malloc.conf"
3378                                     * symbolic link's name.
(gdb) bt
#0  malloc_init_hard () at /archive/cvs/src/lib/libc/stdlib/jemalloc.c:3374
#1  0x00007f7ff709c435 in malloc (size=16384) at 
/archive/cvs/src/lib/libc/stdlib/jemalloc.c:3316
#2  0x00007f7ff70e8a3f in __smakebuf (fp=0x7f7ff731f960) at 
/archive/cvs/src/lib/libc/stdio/makebuf.c:79
#3  0x00007f7ff70bc013 in _fseeko (fp=0x7f7ff731f960, offset=0, whence=2) at 
/archive/cvs/src/lib/libc/stdio/fseeko.c:143
#4  0x00007f7ff7806677 in _zip_open (fn=0x7f7ffffff7c4 "Makefile.am", 
fp=0x7f7ff731f960, flags=0, aflags=-150040912, zep=0x0) at zip_open.c:92
#5  0x00007f7ff7806e47 in zip_open (fn=0x7f7ffffff7c4 "Makefile.am", flags=0, 
zep=0x7f7fffffd4ec) at zip_open.c:79
#6  0x0000000000400ca8 in main (argc=<value optimized out>, 
argv=0x7f7fffffd530) at tryopen.c:86
(gdb)


I think this is a bug. Should I file a bug report, or is this not a
bug for some reason?
 Thomas

(NetBSD-5.99.48/amd64)


Home | Main Index | Thread Index | Old Index