On 11-Sep-96 13:48:34 Thomas Leitner wrote:
> >
> Hi Grant,
>
> Thanks for your reply.
>
> On Tue, 10 Sep 1996, Grant McDorman wrote:
>
> > Based on this, I suspect your problem may not be the signal handler.
> > What I suggest you do is break into the looping process(es) with your
> > debugger, get the call stack, and post it to the list. We can proceed
> > from there.
>
> O.K. I had a 1 hour debugging session this morning before I had to do
> what I get paid for :-)
>
> 1.) FVWM2 didn't always loop when exiting X. Sometimes I dumped core
> as well. I got the following traceback for that:
>
> (gdb) r
> Starting program: /home/users/tom/sources/fvwm-2.0.43/fvwm/fvwm2
> X connection to finwal01:0.0 broken (explicit kill or server
shutdown).
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x3ff8046fdb8 in XQueryPointer ()
> (gdb) bt
> #0 0x3ff8046fdb8 in XQueryPointer ()
> #1 0x120025eec in WaitForButtonsUp () at menus.c:852
> #2 0x12001da98 in ExecuteFunction (
> Action=0x140001850 "Function ExitFunction", tmp_win=0x0,
> eventp=0x140004980, context=8, Module=-1) at functions.c:183
> #3 0x120020600 in Done (restart=0, command=0x0) at fvwm.c:1076
> #4 0x120020948 in CatchFatal (dpy=0x140008000) at fvwm.c:1149
> #5 0x3ff80485cf4 in _XIOError ()
> #6 0x3ff80482054 in _XRead ()
> #7 0x3ff80483664 in _XReply ()
> #8 0x3ff8047b6a0 in XSync ()
> #9 0x12002760c in Destroy (Tmp_win=0x14005d300) at misc.c:116
> #10 0x12001bc48 in HandleUnmapNotify () at events.c:931
> #11 0x120019e78 in DispatchEvent () at events.c:232
> #12 0x120019ed8 in HandleEvents () at events.c:253
> #13 0x12001ebd0 in main (argc=1, argv=0x11ffff9a8) at fvwm.c:447
> (gdb)
>
> The reason whas, that I had an "ExitFunction" defined which was
> supposed to kill FvwmButton. I saw this in a posting in the list
> and though it might be good idea. Actually when the ExitFunction
> was defined, ExecuteFunction is called which in turn makes some
> X calls again which dump core since the connection is already
> broken.
>
> 2.) Now for the looping problem. As expected, I get a SIGPIPE when X
> is killed. When I execute the SIGPIPE Handler with "signal 13"
> (13 = SIGPIPE) I found that this:
>
> struct stat buf;
> if (fstat(XConnectionNumber(dpy), &buf) == -1) exit(1);
>
> is not working! The program does not exit. Instead:
>
> signal(SIGPIPE, DeadPipe);
>
> is executed and the program continues.
The 'fstat' code was just a stab in the dark.
> Now the program loops and eats cpu time. When I interrupt it with
> the debugger I get the following traceback:
>
> (gdb) bt
> #0 0x3ff80481398 in _XFlush ()
> #1 0x3ff80485fd4 in _XData32 ()
> #2 0x3ff80472888 in XConfigureWindow ()
> #3 0x120010e0c in SetupFrame (tmp_win=0x14006af20, x=79,
y=1055,w=921,
> h=981, sendEvent=1) at borders.c:1154
> #4 0x120034408 in MoveViewport (newx=0, newy=0, grab=0) at
virtual.c:393
> #5 0x1200205b0 in Done (restart=0, command=0x0) at fvwm.c:1071
> #6 0x120020948 in CatchFatal (dpy=0x140008000) at fvwm.c:1149
> #7 0x3ff80485cf4 in _XIOError ()
> #8 0x3ff80481614 in _XFlush ()
> #9 0x3ff804835fc in _XReply ()
> warning: Hit heuristic-fence-post without finding
> warning: enclosing function for address 0x4a40537248019600
>
> Apparently "CatchFatal" is correctly called but in turn calls
> X functions and ends up in XFlush which sits there and loops.
> XFlush never returns.
>
> Examining the source reveals that the 'Done' routine does:
>
> #ifndef NON_VIRTUAL
> MoveViewport(0,0,False);
> #endif
>
> I don't know what this is for but it is definately the reason
> for the troubles.
>
> So all in all I come to the following conclusions:
>
> a.) ExitFunctions are not good !! The can cause fvwm2 to dump core
> when exiting!
> b.) The MoveViewPort call in 'Done' is the reason for the troubles.
>
> I don't have too much insight in fvwm to decide if its appropriate just
> to remove this call from the 'Done' routine.
It should be possible to just remove the 'Done' and replace it with exit(1);
for now. The problem in your case appears to be that it is not permissable
to call X functions from the X fatal I/O error handler.
The XLib Reference Manual (for 'R5) says nothing about calling X functions
from the fatal error handler; it does say it isn't permissable to call them
from the regular error handler. Obviously, though, making X calls from the
fatal error handler is a Bad Thing.
>From an inspection of the code, it appears the only safe thing from Done()
that could be invoked in the fatal I/O error handler is ClosePipes().
This means, by the way, that the ExitFunction won't get invoked on a server
shutdown, unless some way of preventing all X calls during its operation can
be put in place.
The SIGSEGV in the ExitFunction may be the same problem.
I am attaching a patch to fvwm.c which changes the CatchFatal to call
ClosePipes() and exit(1), and the patch FvwmButtons which changes the signal
handling.
Chuck may have more to say on this, of course.
> So how can we solve the problem?
>
> Thanks for your help everybody -- Tom
Grant McDorman <grant_at_isgtec.com>
ISG Technologies, Inc.
*** fvwm-2.0.43/modules/FvwmButtons/FvwmButtons.c.orig Thu Jun 27 10:45:30 1996
--- fvwm-2.0.43/modules/FvwmButtons/FvwmButtons.c Wed Sep 11 09:27:37 1996
***************
*** 27,32 ****
--- 27,33 ----
#include <string.h>
#include <sys/wait.h>
#include <sys/time.h>
+ #include <sys/stat.h>
#if defined ___AIX || defined _AIX || defined __QNX__ || defined ___AIXV3 || d
efined AIXV3 || defined _SEQUENT_
#include <sys/select.h>
#endif
***************
*** 75,80 ****
--- 76,82 ----
/* ------------------------------ prototypes ------------------------------- *
/
void DeadPipe(int nonsense);
+ void CleanUp(void);
void SetButtonSize(button_info*,int,int);
/* main */
void Loop(void);
***************
*** 123,128 ****
--- 125,132 ----
GC NormalGC;
int Width,Height;
+ int running = 1;
+
int x= -30000,y= -30000,w= -1,h= -1,gravity = NorthWestGravity;
int new_desk = 0;
int ready = 0;
***************
*** 170,182 ****
**/
void DeadPipe(int whatever)
{
button_info *b,*ub=UberButton;
int button=-1;
- signal(SIGPIPE, SIG_IGN);/* Xsync may cause SIGPIPE */
-
XSync(Dpy,0); /* Wait for thing to settle down a bit */
XGrabServer(Dpy); /* We don't want interference right now */
while(NextButton(&ub,&b,&button,0))
{
/* delete swallowed windows */
--- 174,217 ----
**/
void DeadPipe(int whatever)
{
+ struct stat buf;
+
+ /*
+ * If a SIGPIPE arrives during this operation, just exit.
+ * - the signal will probably because the server is shutting
+ * down. Attempting to do any further processing is useless
+ * and may in fact, on some platforms, put the process into
+ * a tight loop (if SIGPIPE is ignored).
+ * 22 July 1996 GRM.
+ *
+ * Further investigation: XSync may loop *without* causing a SIGPIPE.
+ * This may be because the connection is dead, or because of the
+ * fact that X operations in signal handlers are discouraged.
+ *
+ * In order to cover all the bases, then, this function will now
+ * set a global flag which will cause the main loop to stop.
+ *
+ * SIGPIPE is reset to DeadPipe, as well.
+ */
+ signal(SIGPIPE, DeadPipe);
+
+ /*
+ * Try to check status of X connection.
+ */
+ if (fstat(XConnectionNumber(Dpy), &buf) == -1)
+ exit(0);
+
+ running = 1;
+ }
+
+ void CleanUp(void)
+ {
button_info *b,*ub=UberButton;
int button=-1;
XSync(Dpy,0); /* Wait for thing to settle down a bit */
XGrabServer(Dpy); /* We don't want interference right now */
+
while(NextButton(&ub,&b,&button,0))
{
/* delete swallowed windows */
***************
*** 506,512 ****
int ex=10000,ey=10000,ex2=0,ey2=0;
#endif
! while(1)
{
if(My_XNextEvent(Dpy,&Event))
{
--- 541,547 ----
int ex=10000,ey=10000,ex2=0,ey2=0;
#endif
! while(running)
{
if(My_XNextEvent(Dpy,&Event))
{
***************
*** 733,738 ****
--- 768,774 ----
}
}
}
+ CleanUp();
}
/**
*** fvwm-2.0.43/fvwm/fvwm.c.orig Thu Jun 27 10:08:08 1996
--- fvwm-2.0.43/fvwm/fvwm.c Wed Sep 11 09:25:16 1996
***************
*** 1146,1152 ****
/* No action is taken because usually this action is caused by someone
using "xlogout" to be able to switch between multiple window managers
*/
! Done(0, NULL);
}
/***********************************************************************
--- 1146,1153 ----
/* No action is taken because usually this action is caused by someone
using "xlogout" to be able to switch between multiple window managers
*/
! ClosePipes();
! exit(1);
}
/***********************************************************************
End of MIME message
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_hpc.uh.edu.
To report problems, send mail to fvwm-owner_at_hpc.uh.edu.
Received on Wed Sep 11 1996 - 08:42:55 BST