Opened 6 years ago

Last modified 3 years ago

#7988 new bug

Big integers crashing integer-simple on qnxnto-arm with unregisterised build

Reported by: singpolyma Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.7
Keywords: Cc: pho@…, erikd
Operating System: QNX Architecture: arm
Type of failure: Runtime crash Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

The following program gives a SIGSEGV when run on qnxnto-arm (my Blackberry Z10 running OS10.1, to be exact) after being compiled by my cross-compiler.

Initial investigation shows that compiling a non-cross-compiler for i486 that uses integer-simple does *not* crash on the same program, so it's not a fundamental issue with integer-simple (unless the bug has been fixed between the version of source my cross-compiler uses and HEAD, which I have not yet tested because I'm not sure how to build HEAD to make a good-style statically-linking-libraries GHC).

module Main(main) where

main::IO()
main=print 169821641172389640937095636777672117931888945045504182713271897430274187839083732143233634367563316254925040331580602942790529924419031237257992694047545188803054325440702792009735658578224936744314329623399862853427161588994478038000957583036049445212750560294647972107700330648403394932373528288706138101730866129542001812796094504052779945357555018210304989340497464935845180607042646690920787035715174921382511732745931975718868480005317353569848454618331425749699355019762926384123909468814180690222898222556785716853422930906736084397064171894642825018414586574929919999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999

Change History (11)

comment:1 Changed 6 years ago by singpolyma

The following code *works*, so the integer can exist and operations can be done on it, but certain operations apparently cause it to fail:

module Main(main) where

import Data.Char

newShow' :: Integer -> [Int]
newShow' 0 = []
newShow' x = (fromIntegral $ x `mod` 10) : newShow' (x `div` 10)

newShow :: Integer -> String
newShow x = map intToDigit $ reverse (newShow' x)

main :: IO ()
main = print $ newShow x
	where
	x = 169821641172389640937095636777672117931888945045504182713271897430274187839083732143233634367563316254925040331580602942790529924419031237257992694047545188803054325440702792009735658578224936744314329623399862853427161588994478038000957583036049445212750560294647972107700330648403394932373528288706138101730866129542001812796094504052779945357555018210304989340497464935845180607042646690920787035715174921382511732745931975718868480005317353569848454618331425749699355019762926384123909468814180690222898222556785716853422930906736084397064171894642825018414586574929919999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999

comment:2 Changed 6 years ago by singpolyma

After investigating the implementation of show, I found that this code crashes:

module Main(main) where

baseSize :: Integer -> Integer -> Integer
baseSize b n
	| b > n = b
	| otherwise = baseSize (b*b) n

main :: IO ()
main = const (print "hai") $! (baseSize 10 x)
	where
	x = 1698216411723896409370956367776721179318889450455041827132718974302741878390837321432336343675633162549250403315806029427905299244190312372579926940475451888030543254407027920097356585782249367443143296233998628534271615889944780380009575830360494452127505602946479721077003306484033949323735282887061381017308661295420018127960945040527799453575550182103049893404974649358451806070426466909207870357151749213825117327459319757188684800053173535698484546183314257496993550197629263841239094688141806902228982225567857168534229309067360843970641718946428250184145865749

29919999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999

comment:3 Changed 6 years ago by singpolyma

The bug appears to be some sort of race condition. When compiled with -debug -rtsopts, the test programs from above still crash, if that version is then run with +RTS -v, the program works fine. Here's the output:

created capset 0 of type 2
created capset 1 of type 3
cap 0: initialised
assigned cap 0 to capset 0
assigned cap 0 to capset 1
cap 0: created thread 1
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (stack overflow)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stoppedcap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stoppecap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stoppedcap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (heap overflow)
cap 0: starting GC
cap 0: GC working
cap 0: GC idle
cap 0: GC done
cap 0: GC idle
cap 0: GC done
cap 0: GC idle
cap 0: GC done
cap 0: GC idle
cap 0: GC done
cap 0: all caps stopped for GC
cap 0: finished GC
cap 0: running thcap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thrcap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thcap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (heap overflow)
cap 0: starting GC
cap 0: GC working
cap 0: GC idle
cap 0: GC done
cap 0: GC idle
cap 0: GC done
cap 0: GC idle
cap 0: GC done
cap 0: GC idle
cap 0: GC done
cap 0: all caps stopped for GC
cap 0: finished GC
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (yielding)
cap 0: running thread 1 (ThreadRunGHC)
cap 0: thread 1 stopped (suspended while making a foreign call)
cap 0: running thread 1 (ThreadRunGHC)
169821641172389640937095636777672117931888945045504182713271897430274187839083732143233634367563316254925040331580602942790529924419031237257992694047545188803054325440702792009735658578224936744314329623399862853427161588994478038000957583036049445212750560294647972107700330648403394932373528288706138101730866129542001812796094504052779945357555018210304989340497464935845180607042646690920787035715174921382511732745931975718868480005317353569848454618331425749699355019762926384123909468814180690222898222556785716853422930906736084397064171894642825018414586574929919999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
cap 0: thread 1 stopped (finished)
cap 0: created thread 2
cap 0: running thread 2 (ThreadRunGHC)
cap 0: thread 2 stopped (finished)
cap 0: starting GC
cap 0: GC cap 0: GC idle
cap 0: GC done
cap 0: GC idle
cap 0: GC done
cap 0: GC idle
cap 0: GC done
cap 0: GC idle
cap 0: GC done
cap 0: all caps stopped for GC
cap 0: finished GC
removed cap 0 from capset 0
removed cap 0 from capset 1
cap 0: shutting down
deleted capset 0
deleted capset 1

comment:4 Changed 6 years ago by singpolyma

Running it many more times with various debug options, it will usually not crash if a lot of debug output is on, but sometimes will.

comment:5 Changed 6 years ago by simonpj

difficulty: Unknown

As I understand it, this crash is ARM-specific; that is integer-simple is just fine on other architectures. Correct?

It's odd because integer-simple is just ordinary Haskell code. Nothing fancy, I think.

Might be worth using integer-gmp to make things work, and checking that all regression tests work. Maybe something simpler will trigger the bug.

comment:6 Changed 6 years ago by singpolyma

I just built HEAD registerised (or at least, didn't explicitly --enable-unregisterised). It requires the weird -lcaps hack still, but then my first example seems to work. I will try an unregisterised HEAD and if that also works will mark this as resolved. Sorry.

comment:7 Changed 6 years ago by singpolyma

Ok, so, my unregisterised build of HEAD still has the crash. So this exists in unregisterised only, AFAICT

comment:8 Changed 6 years ago by singpolyma

Just tested an unregisterised, LLVM, integer-simple x86-linux compiler, and it worked fine, so this is something in the intersection of unregisterised and ARM

comment:9 Changed 6 years ago by PHO

Cc: pho@… added

comment:10 Changed 3 years ago by erikd

Cc: erikd added

comment:11 Changed 3 years ago by bgamari

Summary: Big integers crashing integer-simple on qnxnto-armBig integers crashing integer-simple on qnxnto-arm with unregisterised build
Note: See TracTickets for help on using tickets.