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

Memory exception in MQTTAsync_freeCommand #999

Closed
vortex314 opened this issue Nov 19, 2020 · 3 comments
Closed

Memory exception in MQTTAsync_freeCommand #999

vortex314 opened this issue Nov 19, 2020 · 3 comments

Comments

@vortex314
Copy link

Describe the bug
The mqtt stack seems to fail when I send very rapidly about 20 published messages, I'm connecting a joystick that at initialization sends all buttons and axis info.
https://github.com/vortex314/joystick2mqtt
To Reproduce
Not alsways reproducible
Expected behavior
No crash
Screenshots
If applicable, add screenshots to help explain your problem.

** Environment (please complete the following information):**
Linux pcdell 5.4.0-54-generic #60-Ubuntu SMP Fri Nov 6 10:37:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Additional context
Sources in https://github.com/vortex314/joystick2mqtt
Stack trace
ut/js0 I | 00:06:04.158 | pcdell | Joystick2Mqtt.cpp: 291 | axis : 6 = 0
ut/js0 I | 00:06:04.158 | pcdell | Mqtt.cpp: 172 | MQTT PUB : src/pcdell/js0/axis6 = 0
ut/js0 I | 00:06:04.158 | pcdell | Joystick2Mqtt.cpp: 291 | axis : 7 = 0
ut/js0 I | 00:06:04.158 | pcdell | Mqtt.cpp: 172 | MQTT PUB : src/pcdell/js0/axis7 = 0
free(): invalid pointer
Aborted (core dumped)
lieven@pcdell:/workspace/joystick2mqtt/Debug$ gdb joystick2mqtt core
GNU gdb (Ubuntu 9.2-0ubuntu1
20.04) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from joystick2mqtt...
[New LWP 127717]
[New LWP 127714]
[New LWP 127716]
[New LWP 127715]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./joystick2mqtt ../src/joystick2mqtt.json'.
Program terminated with signal SIGABRT, Aborted.
--Type for more, q to quit, c to continue without paging--
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
[Current thread is 1 (Thread 0x7f7876255700 (LWP 127717))]
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x00007f78773d1859 in __GI_abort () at abort.c:79
#2 0x00007f787743c3ee in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7f7877566285 "%s\n") at ../sysdeps/posix/libc_fatal.c:155
#3 0x00007f787744447c in malloc_printerr (str=str@entry=0x7f78775644ae "free(): invalid pointer") at malloc.c:5347
#4 0x00007f7877445cac in _int_free (av=, p=, have_lock=0) at malloc.c:4173
#5 0x000055a8ff6d4f70 in Internal_heap_unlink (file=file@entry=0x55a8ff6dde6d "src/MQTTAsync.c", line=line@entry=1726, p=p@entry=0x7f78700220c8) at src/Heap.c:260
#6 0x000055a8ff6d5198 in myfree (file=file@entry=0x55a8ff6dde6d "src/MQTTAsync.c", line=line@entry=1726, p=p@entry=0x7f78700220c8) at src/Heap.c:282
#7 0x000055a8ff6bf15f in MQTTAsync_freeCommand (command=command@entry=0x7f78700220c8) at src/MQTTAsync.c:1726
#8 0x000055a8ff6c241e in MQTTAsync_cycle (rc=0x7f7876254e0c, timeout=, sock=0x7f7876254e10) at src/MQTTAsync.c:4705
#9 MQTTAsync_receiveThread (n=) at src/MQTTAsync.c:2712
#10 0x00007f78777a3609 in start_thread (arg=) at pthread_create.c:477
#11 0x00007f78774ce293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

@icraggs
Copy link
Contributor

icraggs commented Nov 20, 2020

A client library trace, as described in the readme might help to illustrate a bit more about what's going on. Just at the normal level, not maximum. Even if you can't trace the error situation, it might give me an idea of the circumstances.

@vortex314
Copy link
Author

Hi Ian, as I also refactored my code, I was not able to reproduce the issue. Sorry for the inconvenience. Lieven

@icraggs
Copy link
Contributor

icraggs commented Nov 20, 2020

Thanks for letting me know.

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

No branches or pull requests

2 participants