Put a timeout on executions
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- fsharp
- Bereich
- web-dev
Rechercherichtung
Führen Sie zunächst das bereitgestellte F#-Programm als Konsolenanwendung und im Browser aus, um die endlose Ausführung und das Einfrieren der Seite zu reproduzieren. Verfolgen Sie den im Issue beschriebenen Einstiegspunkt der Ausführung; abgeschlossen ist die Aufgabe, wenn die Ausführung nach einem festgelegten Limit stoppt und der Benutzer benachrichtigt wird, anstatt dass der Browser eingefroren bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
The following code contains an infinite loop in it:
open System
type Ops = Add | Sub | Mul | Div | And | Or | Eor | Bic | Lsl | Lsr | Asr | Ror | Ldc of int
| Dup | Drop | Swap | Over | Ld8 | St8 | Ld16 | St16 | Ld32 | St32 | Se8 | Se16
| For of Exp | Next | If of Exp*Exp | Func of string*Exp | Ldl of string | Stl of string
and Exp = Ops list
type Sym = Var of int32 | Fun of Exp
let symbols = Map.empty
let isNumber (x:string) = fst (Int32.TryParse(x))
let getOps = function
| "+" -> Add
| "-" -> Sub
| "*" -> Mul
| "/" -> Div
| "and" -> And
| "or" -> Or
| "eor" -> Eor
| "bic" -> Bic
| "lsl" -> Lsl
| "lsr" -> Lsr
| "asr" -> Asr
| "ror" -> Ror
| "dup" -> Dup
| "drop" -> Drop
| "swap" -> Swap
| "over" -> Over
| "ld8" -> Ld8
| "st8" -> St8
| "ld16" -> Ld16
| "st16" -> St16
| "ld32" -> Ld32
| "st32" -> St32
| "for" -> For []
| "next" -> Next
| x when isNumber x -> Ldc (int x)
| x -> failwithf "Unknown word %A" x
let exec = function
| (Add,x::y::xs) -> (x+y)::xs
| (Sub,x::y::xs) -> (y-x)::xs
| (Mul,x::y::xs) -> (x*y)::xs
| (Div,x::y::xs) -> (y/x)::xs
| (Ldc x,xs) -> x::xs
| (_,[]) -> failwith "Empty stack"
| x -> failwithf "Unknown Op %A" x
let infix = function
| (Add,x::y::xs) -> ("("+x+" + "+y+")")::xs
| (Sub,x::y::xs) -> ("("+y+" - "+x+")")::xs
| (Mul,x::y::xs) -> ("("+x+" * "+y+")")::xs
| (Div,x::y::xs) -> ("("+y+" / "+x+")")::xs
| (Ldc x,xs) -> (string x)::xs
| (_,[]) -> failwith "Empty stack"
| x -> failwithf "Unknown Op %A" x
let run f = Array.fold (fun xs op -> f (op,xs)) []
//let source = "2 3 + 1 - 2 /"
let source = "1 4 for dup + next + -"
let code = source.Split() |> Array.filter ((<>)"") |> Array.map getOps
printfn "Source: %A" source
printfn "Code: %A" code
let rec combFor xs bb ys depth =
match xs with
| [] -> if bb <> [] then printfn "ERROR: bb not empty %A" bb
(xs,[],List.rev (bb@ys))
| Next::xs when depth = 0 -> printfn "ERROR: No For!"
failwith ""
| Next::xs when depth = 1 -> (xs,[],List.rev (bb@ys))//(xs,List.rev bb,ys)
//| Next::xs when depth > 0 -> combFor xs bb ys (depth - 1)
//| For [] :: xs -> combFor xs bb (For []::ys) (depth + 1)
| For [] :: xs -> let (xs,bb,ys) = combFor xs bb ys (depth + 1)
combFor xs [] (For bb :: ys) (depth + 1)
| x::xs when depth > 0 -> combFor xs (x::bb) ys depth
| x::xs -> combFor (x::xs) bb ys depth
let c = List.ofArray code
printfn "Code: %A" c
let d = combFor c [] [] 0
printfn "CFor: %A" d
//printfn "Infix: %A" (run infix code)
//let result = run exec code
//printfn "Result = %A" (List.rev result)
It's a lot, but this will run infinitely on a local machine as a console app.
In the browser, this will freeze the page until your browser eventually asks to quit. We should put a limit on execution time and stop executing code, then notify the user about that.
- Vorherrschende Sprache
- F#
- Sterne
- 25
- Forks
- 14
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus fsharp/TryFSharp
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 25/100
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 15/100
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 38/100
-
Update to .NET 6?Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
Alle Issues in fsharp/TryFSharp
Ähnliche Issues
-
area/frontend area/v2 kind/bug priority/needs-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
kubeflow/notebooks#1498 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Maintainer antworten meist innerhalb von 1 Tag
-
area/web interface
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
mastodon/mastodon#41009 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
canonical/vanilla-framework#5856 · 1 Kommentar ·
-
Table: Space fires onActivate in single-selection mode — the reference doc and the JSDoc disagreeOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
sidorares/react-x11-components#764 ·
Maintainer antworten meist innerhalb von 1 Tag