Skip to content

Commit

Permalink
bug fix setStackSize (#32)
Browse files Browse the repository at this point in the history
* bug fix setStackSize

* fix

* debug

* debug

* fix new macos set-stacksize bad behaviour
  • Loading branch information
melsman authored Jul 3, 2019
1 parent 21c3691 commit 206b4bd
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 41 deletions.
10 changes: 7 additions & 3 deletions src/Runtime/Runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,17 @@ setStackSize(rlim_t size)
res = setrlimit(RLIMIT_STACK, &lim);
if (res == -1)
{
bad = strerror(errno);
die2("setStackSize(2)", bad);
return; // return silently in case of an error; on
// macOS, the call fails, but the stack should already be
// big in size (set during linking)
//bad = strerror(errno);
//die2("setStackSize(2)", bad);
}
res = getrlimit(RLIMIT_STACK, &limit);
if (res == -1)
{
bad = strerror(errno);
die2("setStackSize(2)", bad);
die2("setStackSize(3)", bad);
}
// printf("Stack size: %llu; %lluMb\n", limit.rlim_cur, limit.rlim_cur / 1024 / 1024);
return;
Expand Down Expand Up @@ -363,6 +366,7 @@ main(int argc, char *argv[])
if ((((double)Max_Int) != Max_Int_d) || (((double)Min_Int) != Min_Int_d))
die("main - integer configuration is erroneous");

// try to set stack size
setStackSizeUnlimited();

parseCmdLineArgs(argc, argv); /* also initializes ml-access to args */
Expand Down
33 changes: 17 additions & 16 deletions src/Tools/Tester/CompilerTimings.sml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ structure CompilerTimings : COMPILER_TIMINGS =
struct

fun pr [] = ()
| pr ((n,t)::rest) = (print (n ^ ": " ^ Time.toString t ^ "\n"); pr rest)
| pr ((n,t)::rest) = (print (n ^ ": " ^ Time.toString t ^ "\n"); pr rest)

exception ReadTimingsError of string

Expand All @@ -23,33 +23,34 @@ structure CompilerTimings : COMPILER_TIMINGS =

fun read_entry is : (string * Time.time) option =
case TextIO.scanStream scanChars is
of SOME name =>
(case TextIO.scanStream Time.scan is
of SOME t => SOME(name,t)
| NONE => raise ReadTimingsError "time expected")
of SOME name =>
((case TextIO.scanStream Time.scan is
of SOME t => SOME(name,t)
| NONE => raise ReadTimingsError "time expected")
handle Time.Time => raise ReadTimingsError "Time raised when trying to read time value")
| NONE => NONE

fun read is = case read_entry is
of SOME e => e :: read is
| NONE => nil
| NONE => nil


(* Compressing timings *)

fun compress (ss : (string * Time.time) list) : (string * Time.time) list =
let
let
fun unref [] = []
| unref ((n,ref t)::rest) = (n,t):: unref rest

fun insert ((n,t),nts) =
let
let
fun loop [] = nts@[(n,ref t)]
| loop ((n', r as ref t')::rest) =
if n = n' then (r:= Time.+(t,t'); nts)
else loop rest
in loop nts
end

fun loop ([],nts) = unref nts
| loop (e::rest,nts) = loop(rest,insert(e,nts))

Expand All @@ -58,16 +59,16 @@ structure CompilerTimings : COMPILER_TIMINGS =


fun from_file s : (string * Time.time) list =
let val is = (TextIO.openIn s)
let val is = (TextIO.openIn s)
handle _ => raise ReadTimingsError ("failed to open compiler timings file `" ^ s ^ "'.\n")
in let val ss = (read is)
handle ReadTimingsError s =>
in let val ss = (read is)
handle ReadTimingsError s =>
(TextIO.closeIn is;
raise ReadTimingsError ("error when trying to read compiler timings: " ^ s ^ ".\n"))
raise ReadTimingsError ("error when trying to read compiler timings: " ^ s ^ ".\n"))
val ss = compress ss
in TextIO.closeIn is;
ss
end
end
end

end
48 changes: 26 additions & 22 deletions src/Tools/Tester/Tester.sml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ structure Tester : TESTER =
let val entries = CompilerTimings.from_file "KITtimings"
in TestReport.add_comptime_line {name=filepath, entries=entries}
end handle CompilerTimings.ReadTimingsError s => (msgErr s; ())
| Time.Time => (msgErr "Time raised by maybe_report_comptimes"; ())
else ()

val exe_file = "./runexe"
Expand Down Expand Up @@ -131,6 +132,9 @@ structure Tester : TESTER =

end handle Fail s => (msgErr (exe_file ^ " failure: " ^ s);
TestReport.add_runtime_bare_line(file_label,false))
| Time.Time =>
(msgErr ("Time raised during execution of " ^ exe_file);
TestReport.add_runtime_bare_line(file_label,false))
else
let val res = OS.Process.system (exe_file ^ " > " ^ file ^ out_file ^ " 2>&1" (*".out"*))
in
Expand Down Expand Up @@ -165,29 +169,29 @@ structure Tester : TESTER =
\ compilation.\n")

fun main (progname, args) =
case process_args args
of SOME (kitexe,testfile,flags) =>
let val _ = (reset_error_counter())
handle Time.Time => (print "bad time4\n" ; raise Fail "bad")
val _ = (TestReport.reset())
handle Time.Time => (print "bad time5\n" ; raise Fail "bad")
in (msglog:=TextIO.openOut(log);
case TestFile.parse testfile
of NONE => OS.Process.failure
| SOME (testfile_string,entries) =>
let val entries = map (fn TestFile.SML (filepath,opt) => (filepath,opt,kitexe)
case process_args args of
SOME (kitexe,testfile,flags) =>
let val _ = (reset_error_counter())
handle Time.Time => (print "bad time4\n" ; raise Fail "bad")
val _ = (TestReport.reset())
handle Time.Time => (print "bad time5\n" ; raise Fail "bad")
in (msglog:=TextIO.openOut(log);
case TestFile.parse testfile
of NONE => OS.Process.failure
| SOME (testfile_string,entries) =>
let val entries = map (fn TestFile.SML (filepath,opt) => (filepath,opt,kitexe)
| TestFile.MLB (filepath,opt) => (filepath,opt,kitexe)) entries
in (app (process_entry flags) entries)
handle Time.Time => (print "bad time2\n" ; raise Fail "bad2") ;
msgErrors();
(TestReport.export {errors=noOfErrors(),testfile_string=testfile_string, kitexe=kitexe})
handle Time.Time => (print "bad time1\n" ; raise Fail "bad1")
;
(* if noOfErrors() = 0 then OS.Process.success else OS.Process.failure *)
OS.Process.success (* to make make work! mael 2001-10-22 *)
end) before (TextIO.closeOut (!msglog))
end
| NONE => (print_usage progname; OS.Process.failure)
in (app (process_entry flags) entries)
handle Time.Time => (print "bad time2\n" ; raise Fail "bad2") ;
msgErrors();
(TestReport.export {errors=noOfErrors(),testfile_string=testfile_string, kitexe=kitexe})
handle Time.Time => (print "bad time1\n" ; raise Fail "bad1")
;
(* if noOfErrors() = 0 then OS.Process.success else OS.Process.failure *)
OS.Process.success (* to make make work! mael 2001-10-22 *)
end) before (TextIO.closeOut (!msglog))
end
| NONE => (print_usage progname; OS.Process.failure)

(*
fun install() =
Expand Down

0 comments on commit 206b4bd

Please sign in to comment.