[Ace-users] [ace-users] PRF: Premature reactor termination on seteuid

Andre Kostur akostur at incognito.com
Wed Nov 21 11:27:24 CST 2007


I was literally about to retract the PRF as I was looking through the
Select_Reactor's source code and saw that comment.  Thanks!

 

From: Steve Huston [mailto:shuston at riverace.com] 
Sent: Wednesday, November 21, 2007 9:03 AM
To: Andre Kostur; ace-users at cs.wustl.edu
Subject: RE: [ace-users] PRF: Premature reactor termination on seteuid

 

Hi Andre,

 

Thanks for the PRF!

 

You can avoid this problem by calling

 

ACE_Reactor::instance()->restart (1);

 

before run_reactor_event_loop(), or explicitly construct a reactor with
the "restart" arg set to 1.

 

Best regards,

-Steve

--
Steve Huston, Riverace Corporation
Want to take ACE training on YOUR schedule?
See http://www.riverace.com/training.htm

	-----Original Message-----
	From: ace-users-bounces at cse.wustl.edu
[mailto:ace-users-bounces at cse.wustl.edu] On Behalf Of Andre Kostur
	Sent: Tuesday, November 20, 2007 9:37 PM
	To: ace-users at cs.wustl.edu
	Subject: [ace-users] PRF: Premature reactor termination on
seteuid

	    ACE VERSION: 5.6.1

	 

	    HOST MACHINE and OPERATING SYSTEM: Xen VM of Linux/i386
v2.6.18-5-xen-vserver-686

	 

	    COMPILER NAME AND VERSION (AND PATCHLEVEL): gcc version
4.1.2 20061115 (prerelease) (Debian 4.1.1-21)

	 

	    THE $ACE_ROOT/ace/config.h FILE [if you use a link to a
platform-

	    specific file, simply state which one]:

	#define ACE_AS_STATIC_LIBS                      1

	#define TAO_AS_STATIC_LIBS                      1

	#define ACE_HAS_STANDARD_CPP_LIBRARY            1

	#define ACE_HAS_IPV6                            1

	#define ACE_USES_IPV4_IPV6_MIGRATION              1

	#include "ace/config-linux.h"

	 

	    THE $ACE_ROOT/include/makeinclude/platform_macros.GNU FILE
[if you

	    use a link to a platform-specific file, simply state which
one

	    (unless this isn't used in this case, e.g., with Microsoft
Visual

	    C++)]:

	ACE_COMPONENTS=FOR_TAO

	exceptions        = 1

	debug             = 0

	optimize          = 1

	static_libs_only  = 1

	xt_reactor        = 0

	fl_reactor        = 0

	ssl               = 1

	ipv6              = 1

	zlib              = 1

	LDFLAGS          += -L$(ACE_ROOT)/ace/$(TARGET_PLATFORM)

	VDIR            = .obj/$(TARGET_PLATFORM)/

	INSLIB          = $(ACE_ROOT)/ace/$(TARGET_PLATFORM)

	include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU

	 

	    CONTENTS OF
$ACE_ROOT/bin/MakeProjectCreator/config/default.features

	    (used by MPC when you generate your own makefiles):

	ssl           = 1

	ipv6          = 1

	zlib          = 1

	 

	    AREA/CLASS/EXAMPLE AFFECTED: ACE_Reactor

	 

	    DOES THE PROBLEM AFFECT:

	        COMPILATION? No

	        LINKING? No

	            On Unix systems, did you run make realclean first?

	        EXECUTION? Yes

	        OTHER (please specify)? n/a

	 

	    SYNOPSIS:

	 

	Performing a seteuid in a thread causes reactors running in
other threads to terminate unexpectedly.

	 

	    DESCRIPTION:

	 

	If you have a reactor running in one thread, calling seteuid in
a different thread causes the reactor to terminate its event loop
prematurely, returning -1.  Examining errno immediately after the
reactor indicates EINTR (Interrupted system call).

	 

	    REPEAT BY:

	 

	#include <ace/Task.h>

	#include <ace/Reactor.h>

	#include <iostream>

	 

	using namespace std;

	 

	class AClass : public ACE_Task<ACE_MT_SYNCH> {

	public:

	        int svc() {

	                cout << "Beginning task" << endl;
ACE_OS::sleep(5);

	                cout << "Changing UIDs" << endl;

	                ACE_OS::seteuid(1025); ACE_OS::sleep(5);

	                cout << "Returning UIDs" << endl;

	                ACE_OS::seteuid(0); ACE_OS::sleep(5);

	                cout << "Ending task" << endl;

	
ACE_Reactor::instance()->end_reactor_event_loop();

	                return 0;

	        }

	};

	 

	int main() {

	        cout <<  "Begin" << endl;

	 

	        AClass ac;

	 

	        ac.activate();

	 

	        cout << "Reactor: " <<

	
ACE_Reactor::instance()->run_reactor_event_loop() << endl;

	}

	 

	 

	When run (of course, as root so that the seteuid call doesn't
outright fail), outputs:

	 

	Begin

	Beginning task

	Changing UIDs

	Reactor: -1

	 

	 

	    SAMPLE FIX/WORKAROUND:

	 

	I have experimented with passing a reactor event hook to the
reactor:

	 

	int reh(ACE_Reactor *) {

	  if (errno == 4) return 1;

	 

	  return 0;

	}

	 

	And this seems to allow the reactor to continue to run:

	 

	Begin

	Beginning task

	Changing UIDs

	Returning UIDs

	Ending task

	Reactor: 0

	 

	 

	However, this would require one to use an event hook, and
exploits a different bug in ACE (see my previous PRF).

	 

	 

	Regards,

	 

	Andre Kostur

	Incognito Software Inc.

	Senior Software Design Engineer

	T: +1(604)678-2864

	F: +1(604)688-4339

	E: akostur at incognito.com

	 

	www.incognito.com

	 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.isis.vanderbilt.edu/pipermail/ace-users/attachments/20071121/87bf016b/attachment-0001.html 


More information about the Ace-users mailing list