Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Incompatibility issues caused by #593 #597

@hugbug

Description

@hugbug

With PR #593 by @fedux the code for creating and synchronising threads has been reworked to use standard facilities of C++11: std::thread, std::mutex, std::atomic, std::condition_variable. That was a nice and welcoming change allowing to reduce the amount of OS specific code in NZBGet code base.

All seemed fine: compilation worked on Mac, Windows and on Linux (tested via Travis CI). Compatibility with many systems is a major priority for NZBGet project. To catch potential compatibility issues we have Travis CI tests that compile nzbget using GCC 4.8 (among other versions), which is the oldest supported compiler. These tests succeeded.

After merging PR #593 I was making performance tests on ARM platform (ARMv7 CPU, armhf target). Unfortunately that didn't go well. The program crashed on start. After investigating the issue the problematic places were:

  • creating new threads with std::thread
  • working with std::condition_variable.

In both cases the library code throwed exception std::system_error and terminated the program.

Before that another issue was found: the compilation for armel target failed. In that case the compiler feature promise/future wasn't implemented in GCC for armel target. That particular bug seemed to be fixed in newer versions of GCC. The issue in nzbget was fixed by reworking the code to use std::condition_variable instead of std::promise/std::future.

I could possibly update build machine to newer GCC version which would hopefully fix issues with std::thread and std::condition_variable. However the fact that GCC 5.2 can't compile nzbget successfully is frustrating. Our Linux installer provides binaries for popular platforms but not for all CPUs. There are sure other devices whose users need to compile nzbget themselves. Many devices come with old toolchains.

Increasing system requirements of nzbget must be adjusted with a very big gain. The rework of thread management code was initiated by #351. Decrease idle cpu/power usage has however far less importance than compatibility with many platforms. Moreover the changes in #593 which directly address idle CPU usage rely on only one new (previously not available in nzbget code base) thread management facility - condition variables.

The plan to fix compatibility issues but keep improvements addressing idle CPU usage is: revert all threads management code back (use OS specific code) and implement condition variables using OS-specific code.

Tasks:

  • revert changes to unit Thread.cpp/.h
  • implement condition variable class for POSIX
  • implement condition variable class for Windows (Windows Vista provides system facility "condition variable" which we can use. For Windows XP an alternative implementation is needed):
    • Windows Vista and above
    • Windows XP
  • replace usage of std::condition_variable with new class
  • test compilation of Linux installer targets
  • test on all available platforms including:
    • Mac
    • Linux ARMv7
    • Windows 10
    • Windows XP
    • Android ARM
    • FreeBSD x86_64.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions