Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
infosec-ecomp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cidre-public
Compilation
infosec-ecomp
Commits
4dedd34d
Commit
4dedd34d
authored
4 years ago
by
Wilke Pierre
Browse files
Options
Downloads
Patches
Plain Diff
Les exécutions échouent si elles durent plus d'une seconde. Timeout paramétrable
dans options.ml
parent
ccb1a057
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/options.ml
+1
-0
1 addition, 0 deletions
src/options.ml
src/report.ml
+43
-8
43 additions, 8 deletions
src/report.ml
with
44 additions
and
8 deletions
src/options.ml
+
1
−
0
View file @
4dedd34d
...
...
@@ -39,3 +39,4 @@ let naive_regalloc = ref true
let
rig_dump
:
string
option
ref
=
ref
None
let
handwritten_lexer
=
ref
Config
.
lex_hand
let
alpaga_parser
=
ref
Config
.
alpaga_parser
let
timeout
=
ref
1
.
0
This diff is collapsed.
Click to expand it.
src/report.ml
+
43
−
8
View file @
4dedd34d
...
...
@@ -77,19 +77,54 @@ let record_compile_result ?error:(error=None) ?data:(data=[]) step =
results
:=
!
results
@
[
CompRes
{
step
;
error
;
data
}]
let
kill
pid
sign
=
try
Unix
.
kill
pid
sign
with
|
Unix
.
Unix_error
(
e
,
f
,
p
)
->
begin
match
e
with
|
ESRCH
->
()
|
_
->
Printf
.
printf
"%s
\n
"
((
Unix
.
error_message
e
)
^
"|"
^
f
^
"|"
^
p
)
end
|
e
->
raise
e
let
run_exn_to_error
f
x
=
try
f
x
with
|
e
->
Error
(
Printexc
.
to_string
e
)
let
timeout
(
f
:
'
a
->
'
b
res
)
(
arg
:
'
a
)
(
time
:
float
)
:
(
'
b
*
string
)
res
=
let
pipe_r
,
pipe_w
=
Unix
.
pipe
()
in
(
match
Unix
.
fork
()
with
|
0
->
let
r
=
run_exn_to_error
f
arg
>>=
fun
v
->
OK
(
v
,
Format
.
flush_str_formatter
()
)
in
let
oc
=
Unix
.
out_channel_of_descr
pipe_w
in
Marshal
.
to_channel
oc
r
[]
;
close_out
oc
;
exit
0
|
pid0
->
(
match
Unix
.
fork
()
with
|
0
->
Unix
.
sleepf
time
;
kill
pid0
Sys
.
sigkill
;
let
oc
=
Unix
.
out_channel_of_descr
pipe_w
in
Marshal
.
to_channel
oc
(
Error
(
Printf
.
sprintf
"Timeout after %f seconds."
time
))
[]
;
close_out
oc
;
exit
0
|
pid1
->
let
ic
=
Unix
.
in_channel_of_descr
pipe_r
in
let
result
=
Marshal
.
from_channel
ic
in
result
))
let
run
step
flag
eval
p
=
if
flag
then
begin
let
starttime
=
Unix
.
gettimeofday
()
in
let
res
=
match
eval
Format
.
str_formatter
p
!
heapsize
!
params
with
|
exception
e
->
Error
(
Printexc
.
to_string
e
)
|
e
->
e
in
let
res
=
timeout
(
fun
(
p
,
params
)
->
eval
Format
.
str_formatter
p
!
heapsize
params
)
(
p
,
!
params
)
!
Options
.
timeout
in
let
timerun
=
Unix
.
gettimeofday
()
-.
starttime
in
let
output
=
Format
.
flush_str_formatter
()
in
let
rres
=
{
step
;
retval
=
None
;
output
;
error
=
None
;
time
=
timerun
}
in
let
rres
=
{
step
;
retval
=
None
;
output
=
""
;
error
=
None
;
time
=
timerun
}
in
let
rres
=
begin
match
res
with
|
OK
v
->
{
rres
with
retval
=
v
}
|
OK
(
v
,
output
)
->
{
rres
with
retval
=
v
;
output
}
|
Error
msg
->
{
rres
with
error
=
Some
msg
}
end
in
results
:=
!
results
@
[
RunRes
rres
];
...
...
@@ -99,7 +134,7 @@ let run step flag eval p =
Printf
.
sprintf
"With parameters : [%s]<br>
\n
"
(
String
.
concat
","
(
List
.
map
string_of_int
!
params
))
^
Printf
.
sprintf
"Mem size : %d bytes<br>
\n
"
!
heapsize
^
Printf
.
sprintf
"Return value : %s<br>
\n
"
(
match
rres
.
retval
with
|
Some
v
->
string_of_int
v
|
_
->
"none"
)
^
Printf
.
sprintf
"Output : <pre style=
\"
padding: 1em; background-color: #ccc;
\"
>%s</pre>
\n
"
output
^
Printf
.
sprintf
"Output : <pre style=
\"
padding: 1em; background-color: #ccc;
\"
>%s</pre>
\n
"
rres
.
output
^
(
match
rres
.
error
with
|
Some
msg
->
Printf
.
sprintf
"Error : <pre style=
\"
padding: 1em; background-color: #fcc;
\"
>
\n
%s</pre>
\n
"
msg
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment