BOINC / boinc

Open-source software for volunteer computing and grid computing.
https://boinc.berkeley.edu
GNU Lesser General Public License v3.0
2.03k stars 449 forks source link

Core client can't terminate project applications (Windows only) #965

Closed romw closed 9 years ago

romw commented 9 years ago

Reported by Thyme Lawn on 20 Sep 40310674 08:00 UTC If a project application fails to respond to a request the BOINC core client's attempt to kill the process always fails when running in Windows protected mode. I modified the core client to generate an error message when ACTIVE_TASK::kill_task() fails to kill the process. This generated the following:

23-Apr-2010 01:25:55 [[app_msg_send](---]) sent <quit/> to famous_r3tj_599_200_000097119_0
23-Apr-2010 01:25:55 [[app_msg_send](---]) sent <quit/> to v4_orca_janto_raha-tpssd-tzvpp_1171_0
23-Apr-2010 01:25:57 [Beta](CPDN) [task_state=EXITED for famous_r3tj_599_200_000097119_0 from has_task_exited
23-Apr-2010 01:26:00 [QMC@HOME](task_debug]) [Task v4_orca_janto_raha-tpssd-tzvpp_1171_0 TerminateProcessById(828) failed, GetLastError()=6 (The handle is invalid.
).
23-Apr-2010 01:26:00 [QMC@HOME](error]) [task_state=ABORTED for v4_orca_janto_raha-tpssd-tzvpp_1171_0 from kill_task

My additional error message indicates that the handle retrieved by OpenProcess() can't be used by the core client.

All subsequent attempts to restart this task fail with a '''Can't acquire lockfile''' error until the task has been terminated. This can only be done by manually killing the task or by rebooting; stopping the BOINC service results in an orphaned task.

I repeated the test after using System Internals Process Explorer to grant the '''Terminate''' permission to the '''boinc_admins''' group for the QMC process. This time kill_task() successfully terminated the process:

23-Apr-2010 10:00:44 [---](task_debug]) [sent <quit/> to famous_r3tj_599_200_000097119_0
23-Apr-2010 10:00:44 [---](app_msg_send]) [sent <quit/> to v4_orca_janto_raha-tpssd-tzvpp_1171_0
23-Apr-2010 10:00:45 [CPDN Beta](app_msg_send]) [task_state=EXITED for famous_r3tj_599_200_000097119_0 from has_task_exited
23-Apr-2010 10:00:49 [QMC@HOME](task_debug]) [task_debug] task_state=ABORTED for v4_orca_janto_raha-tpssd-tzvpp_1171_0 from kill_task

ACTIVE_TASK::start() needs to set up a security descriptor to assign the required privilege and pass it to CreateProcessAsUser() (as the 4th parameter).

romw commented 9 years ago

Commented by romw on 28 Aug 40311938 20:26 UTC Thyme, when you say Windows protected mode, do you mean when UAC is turned on?

romw commented 9 years ago

Commented by Thyme Lawn on 30 May 40311977 22:40 UTC I mean a service installation Rom. The tests were run on an XP system.

romw commented 9 years ago

Commented by Thyme Lawn on 28 Jul 40321466 20:26 UTC Further information.

The QMC application used as an example was built using BOINC API version 6.3.0.

2 changes have been made to boinc_api.cpp since then which affect how Windows project applications respond to requests.

[modified boinc_exit() to follow up the call to TerminateProcess() with calls to Sleep() and DebugBreak() (first used in BOINC API version 6.7.5).

20772 modified exit_from_timer_thread() to resume a task before calling boinc_exit(). That was checked in on 2nd March 2010 and the current trunk version number (6.11.1) was set on 23rd November 2009 (i.e. an with 6.11.1 is not guaranteed to have that change).

For any application using the current trunk version of boinc_api.cpp I'd expect that a request could only fail to be actioned if the application is in a critical section for longer than 5 seconds.

romw commented 9 years ago

Commented by Thyme Lawn on 6 Jul 40450116 18:40 UTC [21295] resolves this problem.