A
alex323
Hey. I must have an array that can be resized dynamically. I have coded
an implementation of it using malloc/realloc, but I am getting a
runtime error as seen below in GDB:
*** glibc detected *** realloc(): invalid next size: 0x08054828 ***
Program received signal SIGABRT, Aborted.
[Switching to Thread -1218516048 (LWP 14211)]
0xffffe410 in __kernel_vsyscall ()
(gdb) bt
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb7e2f9b1 in raise () from /lib/tls/i686/cmov/libc.so.6
#2 0xb7e312c9 in abort () from /lib/tls/i686/cmov/libc.so.6
#3 0xb7e636ea in __fsetlocking () from /lib/tls/i686/cmov/libc.so.6
#4 0xb7e6bba2 in free () from /lib/tls/i686/cmov/libc.so.6
#5 0xb7e6ca66 in realloc () from /lib/tls/i686/cmov/libc.so.6
#6 0x0804901f in sockstate_handle_outgoing (arg=0x804c008) at
sockstate.c:75
#7 0xb7f3a361 in start_thread () from
/lib/tls/i686/cmov/libpthread.so.0
#8 0xb7ecfbde in clone () from /lib/tls/i686/cmov/libc.so.6
(gdb)
The code is as follows:
ufds = malloc(sizeof(struct pollfd)*numconns); /* Where ufds is a
pointer to a pollfd, and numconns is the number of sockets that will be
stored in ufds. */
[...]
if( the number of sockets has changed ) {
ufds = realloc(ufds, sizeof(struct pollfd)*numconns); /* numconns
is set to the new number, which could be higher or lower. This is the
line GDB is reporting (sockstate.c:75) */
}
Anyone have any ideas on how to resolve this problem?
Thanks,
Alex
an implementation of it using malloc/realloc, but I am getting a
runtime error as seen below in GDB:
*** glibc detected *** realloc(): invalid next size: 0x08054828 ***
Program received signal SIGABRT, Aborted.
[Switching to Thread -1218516048 (LWP 14211)]
0xffffe410 in __kernel_vsyscall ()
(gdb) bt
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb7e2f9b1 in raise () from /lib/tls/i686/cmov/libc.so.6
#2 0xb7e312c9 in abort () from /lib/tls/i686/cmov/libc.so.6
#3 0xb7e636ea in __fsetlocking () from /lib/tls/i686/cmov/libc.so.6
#4 0xb7e6bba2 in free () from /lib/tls/i686/cmov/libc.so.6
#5 0xb7e6ca66 in realloc () from /lib/tls/i686/cmov/libc.so.6
#6 0x0804901f in sockstate_handle_outgoing (arg=0x804c008) at
sockstate.c:75
#7 0xb7f3a361 in start_thread () from
/lib/tls/i686/cmov/libpthread.so.0
#8 0xb7ecfbde in clone () from /lib/tls/i686/cmov/libc.so.6
(gdb)
The code is as follows:
ufds = malloc(sizeof(struct pollfd)*numconns); /* Where ufds is a
pointer to a pollfd, and numconns is the number of sockets that will be
stored in ufds. */
[...]
if( the number of sockets has changed ) {
ufds = realloc(ufds, sizeof(struct pollfd)*numconns); /* numconns
is set to the new number, which could be higher or lower. This is the
line GDB is reporting (sockstate.c:75) */
}
Anyone have any ideas on how to resolve this problem?
Thanks,
Alex