[Xmonad] darcs patch: fix potential hole in userCode.
dons at galois.com
Fri Oct 12 13:32:48 EDT 2007
> Oe Fri, Oct 12, 2007 at 10:11:13AM -0500, Spencer Janssen wrote:
> > On Friday 12 October 2007 10:03:52 David Roundy wrote:
> > > Fri Oct 12 11:02:53 EDT 2007 David Roundy <droundy at darcs.net>
> > > * fix potential hole in userCode.
> > > This makes userCode catch errors even when the
> > > user does something like (return undefined).
> > Applied.
> I was thinking that we might get a little more benefit from adding just a
> tad of strictness to catchX itself. It could call seq on the return value
> to catch at least the grossest errors that might be hidden in lazy values.
> That still wouldn't obsolete this change to userCode, since the advantage
> when we've got a () return value is that we can safely ignore it and keep
> any changes that might have been made.
Fwiw, here's the exception catching code from lambdabot. This has to
evaluate completely untrusted code, of course:
case s of
Left e -> mapM_ putStrLn e
Right v -> Control.Exception.catch
(\e -> Control.Exception.handle (const $ putStrLn "Exception") $ do
e' <- Control.Exception.evaluate e
putStrLn $ "Exception: " ++ take 1024 (show e'))
Right means there was no compile error. So we then show the value, forcing it.
Note that it can throw an exception whose thrown value is an exception.
'evaluate' takes care of some of the work for us.
More information about the Xmonad