Commit b45df929 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Give an explicit message when SIGSEGV happens.



Fixes #767.
Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent 6cca0e71
......@@ -690,7 +690,8 @@ rebuildTargets verbosity
InstallPlan.execute jobControl keepGoing
(BuildFailure Nothing . DependentFailed . packageId)
installPlan $ \pkg ->
handle (return . Left) $ fmap Right $ --TODO: review exception handling
--TODO: review exception handling
handle (\(e :: BuildFailure) -> return (Left e)) $ fmap Right $
let uid = installedUnitId pkg
Just pkgBuildStatus = Map.lookup uid pkgsBuildStatus in
......
......@@ -93,7 +93,7 @@ import Data.Either
import Control.Exception (Exception(..))
import System.Exit (ExitCode(..), exitFailure)
#ifdef MIN_VERSION_unix
import System.Posix.Signals (sigKILL)
import System.Posix.Signals (sigKILL, sigSEGV)
#endif
......@@ -586,11 +586,14 @@ reportBuildFailures verbosity plan buildOutcomes
| otherwise
= False
-- NB: if the Setup script segfaulted or was interrupted,
-- we should give more detailed information. So only
-- assume that exit code 1 is "pedestrian failure."
isFailureSelfExplanatory (BuildFailed e)
| Just (ExitFailure _) <- fromException e = True
| Just (ExitFailure 1) <- fromException e = True
isFailureSelfExplanatory (ConfigureFailed e)
| Just (ExitFailure _) <- fromException e = True
| Just (ExitFailure 1) <- fromException e = True
isFailureSelfExplanatory _ = False
......@@ -651,7 +654,27 @@ reportBuildFailures verbosity plan buildOutcomes
Just (ExitFailure 1) -> ""
#ifdef MIN_VERSION_unix
-- Note [Positive "signal" exit code]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- What's the business with the test for negative and positive
-- signal values? The API for process specifies that if the
-- process died due to a signal, it returns a *negative* exit
-- code. So that's the negative test.
--
-- What about the positive test? Well, when we find out that
-- a process died due to a signal, we ourselves exit with that
-- exit code. However, we don't "kill ourselves" with the
-- signal; we just exit with the same code as the signal: thus
-- the caller sees a *positive* exit code. So that's what
-- happens when we get a positive exit code.
Just (ExitFailure n)
| -n == fromIntegral sigSEGV ->
" The build process segfaulted (i.e. SIGSEGV)."
| n == fromIntegral sigSEGV ->
" The build process terminated with exit code " ++ show n
++ " which may be because some part of it segfaulted. (i.e. SIGSEGV)."
| -n == fromIntegral sigKILL ->
" The build process was killed (i.e. SIGKILL). " ++ explanation
......
......@@ -35,6 +35,10 @@ Extra-Source-Files:
tests/IntegrationTests/custom/plain/A.hs
tests/IntegrationTests/custom/plain/Setup.hs
tests/IntegrationTests/custom/plain/plain.cabal
tests/IntegrationTests/custom/segfault.sh
tests/IntegrationTests/custom/segfault/Setup.hs
tests/IntegrationTests/custom/segfault/cabal.project
tests/IntegrationTests/custom/segfault/plain.cabal
tests/IntegrationTests/exec/Foo.hs
tests/IntegrationTests/exec/My.hs
tests/IntegrationTests/exec/adds_sandbox_bin_directory_to_path.out
......
. ./common.sh
if [ "x$(uname)" != "xLinux" ]; then
exit
fi
# Older GHCs don't report exit via signal adequately
require_ghc_ge 708
cd segfault
! cabal new-build 2> log
cat log
grep SIGSEGV log
import System.Posix.Signals
main = putStrLn "Quitting..." >> raiseSignal sigSEGV
name: plain
version: 0.1.0.0
license: BSD3
author: Edward Z. Yang
maintainer: ezyang@cs.stanford.edu
build-type: Custom
cabal-version: >=1.10
library
build-depends: base
default-language: Haskell2010
custom-setup
setup-depends: base, unix
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment