ami-iit / bipedal-locomotion-framework

Suite of libraries for achieving bipedal locomotion on humanoid robots
https://ami-iit.github.io/bipedal-locomotion-framework/
BSD 3-Clause "New" or "Revised" License
136 stars 36 forks source link

Fix the barrier logic for threads synchronization #811

Closed LoreMoretti closed 5 months ago

LoreMoretti commented 5 months ago

As explained in this comment, we found out that the barrier logic for threads synchronization is not working properly.

This is due to the following two reasons:

  1. No thread will go to the else branch if the if condition reads ((--m_count) == 1). Therefore no thread will wait.
  2. The wait() function is not included in the lambda function passed to std::thread(). This means that, even if the wait command is reached, it will stop the main thread (i.e. the one which is spawning the other threads).

This PR aims at addressing these problems.

LoreMoretti commented 5 months ago

I have closed and re-opened the PR to trigger again the CI, because Windows jobs were failing (probably due to a connection error, since the download of the wget package was failing). But it seems like these Windows jobs are failing again for the same reason.

@GiulioRomualdi could you try to trigger again just the Windows jobs? I think I do not have the rights to trigger specific jobs. Thanks!

traversaro commented 5 months ago

For reference, the error is:

Chocolatey v2.2.2
Installing the following packages:
wget;unzip
By installing, you accept licenses for the packages.
Invalid credentials specified.
Please provide credentials for: https://community.chocolatey.org/api/v2/
User name: Password: Chocolatey had an error on fv-az1389-843 (with user runneradmin):
System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read.
   at System.Console.ReadKey(Boolean intercept)
   at chocolatey.infrastructure.commandline.ReadKeyTimeout.ConsoleReadKey()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Unhandled Exception: System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read.
   at System.Console.ReadKey(Boolean intercept)
   at chocolatey.infrastructure.commandline.ReadKeyTimeout.ConsoleReadKey()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
wget: D:\a\_temp\6bc5d996-a0b3-49ae-adb6-33659e0889e6.ps1:7
Line |
   7 |  wget https://github.com/robotology/robotology-superbuild-dependencies …
     |  ~~~~
     | The term 'wget' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the
     | spelling of the name, or if a path was included, verify that the path is correct and try again.
Error: Process completed with exit code 1.

Not sure if it is a network error. Perhaps we could use curl instead of wget to download the .zip on Windows?

traversaro commented 5 months ago

For reference, the error is:

Chocolatey v2.2.2
Installing the following packages:
wget;unzip
By installing, you accept licenses for the packages.
Invalid credentials specified.
Please provide credentials for: https://community.chocolatey.org/api/v2/
User name: Password: Chocolatey had an error on fv-az1389-843 (with user runneradmin):
System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read.
   at System.Console.ReadKey(Boolean intercept)
   at chocolatey.infrastructure.commandline.ReadKeyTimeout.ConsoleReadKey()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Unhandled Exception: System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read.
   at System.Console.ReadKey(Boolean intercept)
   at chocolatey.infrastructure.commandline.ReadKeyTimeout.ConsoleReadKey()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
wget: D:\a\_temp\6bc5d996-a0b3-49ae-adb6-33659e0889e6.ps1:7
Line |
   7 |  wget https://github.com/robotology/robotology-superbuild-dependencies …
     |  ~~~~
     | The term 'wget' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the
     | spelling of the name, or if a path was included, verify that the path is correct and try again.
Error: Process completed with exit code 1.

Not sure if it is a network error. Perhaps we could use curl instead of wget to download the .zip on Windows?

Related upstream issue: https://github.com/actions/runner-images/issues/9367#issuecomment-1952245895 . There still seems to be problem: https://status.chocolatey.org/ . Probably we can just ignore the Windows-vcpkg job for now, as long as Windows conda is compiling fine, I do not think we can risk regressions.

traversaro commented 5 months ago

I restarted the CI as Chocolatey is now up: https://status.chocolatey.org/ .

GiulioRomualdi commented 5 months ago

Thank you @LoreMoretti