Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

double free or corruption (!prev) #1459

Open
maikebing opened this issue Mar 8, 2024 · 1 comment
Open

double free or corruption (!prev) #1459

maikebing opened this issue Mar 8, 2024 · 1 comment

Comments

@maikebing
Copy link

maikebing commented Mar 8, 2024


Thread 12 "MQTTAsync_rcv" received signal SIGABRT, Aborted.
[Switching to Thread 0xdf326b40 (LWP 1392)]
0xf7fd7549 in __kernel_vsyscall ()
#0  0xf7fd7549 in __kernel_vsyscall ()
#1  0xf7caaeb9 in __GI_raise (sig=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#2  0xf7cac417 in __GI_abort () at abort.c:89
#3  0xf7ce638c in __libc_message (do_abort=2, 
    fmt=0xf7ddef74 "*** Error in `%s': %s: 0x%s ***\n")
    at ../sysdeps/posix/libc_fatal.c:175
#4  0xf7cec307 in malloc_printerr (action=<optimized out>, 
    str=0xf7ddefe4 "double free or corruption (!prev)", ptr=<optimized out>, 
    ar_ptr=0xf7e32780 <main_arena>) at malloc.c:5020
#5  0xf7cecc41 in _int_free (av=0xf7e32780 <main_arena>, p=<optimized out>, 
    have_lock=0) at malloc.c:3874
#6  0x083e1543 in MQTTProtocol_removePublication (p=0xce445d80)
    at paho.mqtt.c/src/MQTTProtocolClient.c:302
#7  0x083e0ca5 in MQTTAsync_cycle (sock=0xdf326300, timeout=1000, 
    rc=0xdf326304) at paho.mqtt.c/src/MQTTAsyncUtils.c:3183
#8  0x083de637 in MQTTAsync_receiveThread (n=0x9d39620)
    at paho.mqtt.c/src/MQTTAsyncUtils.c:2027
#9  0xf7e3c295 in start_thread (arg=0xdf326b40) at pthread_create.c:333
#10 0xf7d661ce in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:114

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Log files
Please try to attach log files rather than pasting the log contents. It makes the issues easier to read.

** Environment (please complete the following information):**

  • OS: ubuntu
  • Version [16]

Additional context

Makefile.am


noinst_LIBRARIES = libpahomqttc.a

LIBS =  -lc -ldl -lpthread -lrt -lanl 

libpahomqttc_a_CFLAGS = -DHIGH_PERFORMANCE -DPAHO_BUILD_STATIC  -DEMRCLINUX -D_GNU_SOURCE -fvisibility=hidden -DPAHO_MQTT_EXPORTS=1   -DNO_PERSISTENCE \
			-I$(top_srcdir)/src/thirdParty/paho.mqtt.c/src  -I$(top_srcdir)/src/include


libpahomqttc_a_SOURCES =  paho.mqtt.c/src/MQTTTime.c \
  paho.mqtt.c/src/MQTTProtocolClient.c \
  paho.mqtt.c/src/Clients.c \
  paho.mqtt.c/src/utf-8.c \
  paho.mqtt.c/src/MQTTPacket.c \
  paho.mqtt.c/src/MQTTPacketOut.c \
  paho.mqtt.c/src/Messages.c \
  paho.mqtt.c/src/Tree.c \
  paho.mqtt.c/src/Socket.c \
  paho.mqtt.c/src/Log.c \
  paho.mqtt.c/src/MQTTPersistence.c \
  paho.mqtt.c/src/Thread.c \
  paho.mqtt.c/src/MQTTProtocolOut.c \
  paho.mqtt.c/src/MQTTPersistenceDefault.c \
  paho.mqtt.c/src/SocketBuffer.c \
  paho.mqtt.c/src/LinkedList.c \
  paho.mqtt.c/src/MQTTProperties.c \
  paho.mqtt.c/src/MQTTReasonCodes.c \
  paho.mqtt.c/src/Base64.c \
  paho.mqtt.c/src/SHA1.c \
  paho.mqtt.c/src/WebSocket.c \
  paho.mqtt.c/src/Proxy.c \
  paho.mqtt.c/src/MQTTAsync.c paho.mqtt.c/src/MQTTAsyncUtils.c

Valgrind


==1333== Invalid free() / delete / delete[] / realloc()
==1333==    at 0x402D358: free (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==1333==    by 0x83E1542: MQTTProtocol_removePublication (MQTTProtocolClient.c:302)
==1333==    by 0x83E0CA4: MQTTAsync_cycle (MQTTAsyncUtils.c:3183)
==1333==    by 0x83DE636: MQTTAsync_receiveThread (MQTTAsyncUtils.c:2027)
==1333==    by 0x41BE294: start_thread (pthread_create.c:333)
==1333==    by 0x42BC1CD: clone (clone.S:114)
@icraggs
Copy link
Contributor

icraggs commented Apr 18, 2024

Hmm. I'm unlikely to be able to to more with this without more context as to what was happening. What API calls were being used, how many client objects, what they were doing, how many threads, and so on. If it's reproducible a client library trace.

What version of the API are you using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants