Giter Club home page Giter Club logo

knot-modbus-source's People

Contributors

brduarte95 avatar cktakahasi avatar pauloserrafh avatar ramonhpr avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

knot-modbus-source's Issues

Bug: Crash when slave invalid address is added

$ sudo valgrind --leak-check=full src/modbusd 
==1033== Memcheck, a memory error detector
==1033== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==1033== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==1033== Command: src/modbusd
==1033== 
Starting manager ...
Starting dbus ...
Name acquire complete.
Starting slave ...
Starting source ...
slave_ref(0x5875d50): 1
Slave(0x5875d50): (/slave_3b8d616040201ed5) url: (tcp://yahoo.com:80)
slave_ref(0x5875d50): 2
slave_ref(0x58779c0): 1
Slave(0x58779c0): (/slave_5f8cb08ed47472eb) url: (tcp://google.com:80)
slave_ref(0x58779c0): 2
slave_ref(0x5879630): 1
Slave(0x5879630): (/slave_979174b28eae2fe3) url: (tcp://google.com)
slave_ref(0x5879630): 2
RTU: tcp://yahoo.com:80
RTU: tcp://google.com:80
Address (tcp://google.com) not supported: Invalid format
==1033== Invalid read of size 8
==1033==    at 0x5293E40: modbus_set_slave (in /usr/lib/x86_64-linux-gnu/libmodbus.so.5.0.5)
==1033==    by 0x402ECC: enable_slave (slave.c:309)
==1033==    by 0x4E4BFF9: timeout_callback (timeout.c:81)
==1033==    by 0x4E4B659: l_main_iterate (main.c:473)
==1033==    by 0x4E4B72B: l_main_run (main.c:520)
==1033==    by 0x4E4B94A: l_main_run_with_signal (main.c:642)
==1033==    by 0x40270F: main (main.c:97)
==1033==  Address 0x30 is not stack'd, malloc'd or (recently) free'd
==1033== 
==1033== 
==1033== Process terminating with default action of signal 11 (SIGSEGV)
==1033==  Access not within mapped region at address 0x30
==1033==    at 0x5293E40: modbus_set_slave (in /usr/lib/x86_64-linux-gnu/libmodbus.so.5.0.5)
==1033==    by 0x402ECC: enable_slave (slave.c:309)
==1033==    by 0x4E4BFF9: timeout_callback (timeout.c:81)
==1033==    by 0x4E4B659: l_main_iterate (main.c:473)
==1033==    by 0x4E4B72B: l_main_run (main.c:520)
==1033==    by 0x4E4B94A: l_main_run_with_signal (main.c:642)
==1033==    by 0x40270F: main (main.c:97)
==1033==  If you believe this happened as a result of a stack
==1033==  overflow in your program's main thread (unlikely but
==1033==  possible), you can try to increase the size of the
==1033==  main thread stack using the --main-stacksize= flag.
==1033==  The main thread stack size used in this run was 8388608.
==1033== 
==1033== HEAP SUMMARY:
==1033==     in use at exit: 47,195 bytes in 275 blocks
==1033==   total heap usage: 1,037 allocs, 762 frees, 284,939 bytes allocated
==1033== 
==1033== LEAK SUMMARY:
==1033==    definitely lost: 0 bytes in 0 blocks
==1033==    indirectly lost: 0 bytes in 0 blocks
==1033==      possibly lost: 0 bytes in 0 blocks
==1033==    still reachable: 47,195 bytes in 275 blocks
==1033==         suppressed: 0 bytes in 0 blocks
==1033== Reachable blocks (those to which a pointer was found) are not shown.
==1033== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==1033== 
==1033== For counts of detected and suppressed errors, rerun with: -v
==1033== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)

Create storage files/path based on slave random id

Slave id (random) should be used as path(directory) name at /var/lib/modbus/slave_id

Storage path suggestion:
if (test "${prefix}" = "NONE"); then
dnl no prefix and no localstatedir, so default to /var
if (test "$localstatedir" = '${prefix}/var'); then
AC_SUBST([localstatedir], ['/var'])
fi

    prefix="${ac_default_prefix}"

fi

if (test "$localstatedir" = '${prefix}/var'); then
storagedir="${prefix}/var/lib/modbus"
else
storagedir="${localstatedir}/lib/modbus"
fi
AC_DEFINE_UNQUOTED(STORAGEDIR, "${storagedir}",
[Directory for the storage files])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.