Put a timeout on executions
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- fsharp
- 领域
- web-dev
调研方向
首先将提供的 F# 程序作为控制台应用运行,并在浏览器中运行,以复现无限执行和页面冻结。跟踪 issue 中描述的执行入口点;当执行在达到定义的限制后停止,并通知用户,而不是让浏览器继续冻结时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- F#
- 星标
- 25
- 派生
- 14
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
fsharp/TryFSharp 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 25/100
-
难度 5/5 一周以上 新手友好度 15/100
-
难度 3/5 1-2 天 新手友好度 38/100
-
难度 4/5 3-5 天 新手友好度 25/100
-
难度 4/5 3-5 天 新手友好度 48/100
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 72/100
betagouv/mon-entreprise#4699 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 3 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
jaegertracing/jaeger-ui#4547 · 3 条评论 ·
维护者通常 1 天内回复
-
ai-driven-qa
难度 2/5 1-3 小时 新手友好度 84/100
linagora/twake-calendar-frontend#1467 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
auth0/universal-login#414 ·
维护者通常 1 天内回复