You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
1.7 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
la_mojo: fix memory leaks and heap corruption Continuous leaks: - protocolParser: on package-pool overflow the oldest package was removed but never freed while the newest (still pooled) one was freed. Every packet a handler does not consume (e.g. other sensors on a shared bus) leaked once the pool was full. Free the removed package, free pooled packages in the destructor and getPackage(), use memmove for the overlapping buffer shifts. - SQLite_Connector::Query: loop only while sqlite3_step() returns SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed open, fix escapeBinary() writing into uninitialised buffers. - basicThread/basicDualThread: threads that ended by themselves were never joined, leaking their stacks on every stream drop/restart. Always join once (detach when called from the thread itself); check pthread_create result correctly. - curlRequest: free the header list; initialise m_pPostData and the content type; curlRequestsManager deletes requests it cannot queue. - kernelModuleModemManager: free the phonebook ID list on every reload. - deviceNodeFactory: do not append the same pending node every cycle. - streamHandler: free frames left in the encoding queue on destruction. Heap corruption: - kernelModuleFactory: module that failed to start was deleted twice. - mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a bool; compare with -1. Fix packetExtractor and destructor leaks. - utilizeBasicEvent: payloads are malloc'ed, release with free(). - videoAVLIBSource: avoid sws context double free, NULL check order. - trim(): memmove for overlapping copy. Smaller leaks: dropSession duplicate query, LRF upload data, report backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
24 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
la_mojo: fix memory leaks and heap corruption Continuous leaks: - protocolParser: on package-pool overflow the oldest package was removed but never freed while the newest (still pooled) one was freed. Every packet a handler does not consume (e.g. other sensors on a shared bus) leaked once the pool was full. Free the removed package, free pooled packages in the destructor and getPackage(), use memmove for the overlapping buffer shifts. - SQLite_Connector::Query: loop only while sqlite3_step() returns SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed open, fix escapeBinary() writing into uninitialised buffers. - basicThread/basicDualThread: threads that ended by themselves were never joined, leaking their stacks on every stream drop/restart. Always join once (detach when called from the thread itself); check pthread_create result correctly. - curlRequest: free the header list; initialise m_pPostData and the content type; curlRequestsManager deletes requests it cannot queue. - kernelModuleModemManager: free the phonebook ID list on every reload. - deviceNodeFactory: do not append the same pending node every cycle. - streamHandler: free frames left in the encoding queue on destruction. Heap corruption: - kernelModuleFactory: module that failed to start was deleted twice. - mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a bool; compare with -1. Fix packetExtractor and destructor leaks. - utilizeBasicEvent: payloads are malloc'ed, release with free(). - videoAVLIBSource: avoid sws context double free, NULL check order. - trim(): memmove for overlapping copy. Smaller leaks: dropSession duplicate query, LRF upload data, report backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
24 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __BASICDUALTHREAD_H_INCL__
  2. #define __BASICDUALTHREAD_H_INCL__
  3. #include "basicThread.h"
  4. /**
  5. * TODO: Add class description
  6. *
  7. * @author Gagua
  8. */
  9. class basicDualThread
  10. {
  11. private:
  12. basicLogCollection * m_pLog;
  13. #if defined(__linux__) || defined(WIN_PTHREAD)
  14. pthread_t m_sThreadAHandler;
  15. static void * m_fThreadAEntryPoint(void *);
  16. pthread_t m_sThreadBHandler;
  17. static void * m_fThreadBEntryPoint(void *);
  18. #else
  19. HANDLE m_hThreadAHandle;
  20. HANDLE m_hThreadBHandle;
  21. DWORD m_dwThreadAID;
  22. DWORD m_dwThreadBID;
  23. static DWORD WINAPI m_fThreadAEntryPoint(LPVOID lpParameter);
  24. static DWORD WINAPI m_fThreadBEntryPoint(LPVOID lpParameter);
  25. #endif
  26. // true while a created thread has not been joined yet (its stack is only released by pthread_join)
  27. bool m_bThreadAJoinable;
  28. bool m_bThreadBJoinable;
  29. protected:
  30. thredStatus m_bThreadAStatus;
  31. virtual void m_fThreadAProc(void);
  32. thredStatus m_bThreadBStatus;
  33. virtual void m_fThreadBProc(void);
  34. public:
  35. // Constructor
  36. basicDualThread();
  37. // Destructor
  38. ~basicDualThread();
  39. virtual bool init(void);
  40. virtual bool uninit(void);
  41. thredStatus getAStatus(void)
  42. {
  43. return m_bThreadAStatus;
  44. }
  45. thredStatus getBStatus(void)
  46. {
  47. return m_bThreadBStatus;
  48. }
  49. void waitThreadAEnd(bool Force = true);
  50. void waitThreadBEnd(bool Force = true);
  51. };
  52. // Constructor implementation
  53. inline basicDualThread::basicDualThread()
  54. {
  55. m_pLog = basicLogCollection::getInstance();
  56. m_bThreadAStatus = TH_PRE_INIT;
  57. m_bThreadBStatus = TH_PRE_INIT;
  58. m_bThreadAJoinable = false;
  59. m_bThreadBJoinable = false;
  60. }
  61. // Destructor implementation
  62. inline basicDualThread::~basicDualThread()
  63. {
  64. waitThreadAEnd(true);
  65. waitThreadBEnd(true);
  66. }
  67. #endif // __BASICTHREAD_H_INCL__