stephane / libmodbus

A Modbus library for Linux, Mac OS, FreeBSD and Windows
http://libmodbus.org
GNU Lesser General Public License v2.1
3.29k stars 1.71k forks source link

*** buffer overflow detected ***: ./unit-test-server terminated #527

Open vickymadeshwaran opened 4 years ago

vickymadeshwaran commented 4 years ago

Please read the following carefully before submitting this new issue.

When you get here and you are still convinced that you want report a bug:

Good bug reports provide right and quick fixes!

Finally, thank you very much for using libmodbus and taking the time to file a good bug report. Doing so signals your respect for the developers.

The following template helps you to address the points above. Please delete everything up to and including the following line which starts with ---.


libmodbus version

## OS and/or distribution ## Environment ## Description <...> ## Expected behaviour <...> ## Actual behaviour <...> ## Steps to reproduce the behavior (commands or source code) <...> ## libmodbus output with debug mode enabled <...>
JoelStienlet commented 4 years ago

Hello, Sadly this bug report doesn't provide much information, we have the form without the answers. I haven't been able to reproduce this on fedora 31.

ladmanj commented 4 years ago

Hi I can't understand what it means here above. Why someone copied a bug report manual here?

Anyway: After todays kernel update on my ubuntu 19.10 the libmodbus test crashes in this way. I'm not sure that there is anything more than correlation between the update and the crash.

libmodbus-master$ tests/bandwidth-server-one rtu
*** buffer overflow detected ***: /home/ladmanj/DataDisk/modbus/libmodbus-master/tests/.libs/bandwidth-server-one terminated
Aborted (core dumped)

libmodbus installed from sources from this github repo

$ pkg-config --modversion libmodbus
3.1.6
$ uname -a
Linux thinkpad 5.3.0-45-generic #37-Ubuntu SMP Thu Mar 26 20:41:27 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Thank you

ladmanj commented 4 years ago

Oh, i have found it. The serial port involved disappeared from the system (the USB to serial dongle seems died overnight).

So in my case, the bug is, that libmodbus can open non-existing device and then crashes while preparing handlers for select().

J.

Breakpoint 1, _modbus_receive_msg (ctx=0x5555555592a0, msg=0x7fffffffda50 "", msg_type=msg_type@entry=MSG_INDICATION)
    at modbus.c:341
341     {
(gdb) list
336        - ETIMEDOUT
337        - read() or recv() error codes
338     */
339
340     int _modbus_receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type)
341     {
342         int rc;
343         fd_set rset;
344         struct timeval tv;
345         struct timeval *p_tv;
(gdb) n
350         if (ctx->debug) {
(gdb) 
359         FD_ZERO(&rset);
(gdb) 
360         FD_SET(ctx->s, &rset);
(gdb) 
*** buffer overflow detected ***: /home/ladmanj/DataDisk/modbus/libmodbus-master/tests/.libs/bandwidth-server-one terminated

Program received signal SIGABRT, Aborted.
__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.
(gdb)
TangxzYiLin commented 3 years ago

how to solve this problem? I just ran into this problem,thanku