frenetic-lang / frenetic

The Frenetic Programming Language and Runtime System
http://www.frenetic-lang.org/
Other
223 stars 51 forks source link

pesky unhandled exception in Async scheduler #566

Open reservoirman opened 7 years ago

reservoirman commented 7 years ago

hello so I'm basically trying to update the policy whenever certain events occur. After the event occurs, the program crashes with the following exception:

(((pid 24589) (thread_id 0))
 ((human_readable 2017-07-15T02:21:10-0400)
  (int63_ns_since_epoch 1500099670959842000))
 "unhandled exception in Async scheduler"
 ("unhandled exception"
  ((src/monitor.ml.Error_
    ((exn Not_found)
     (backtrace
      ("Raised at file \"src/core_hashtbl.ml\", line 296, characters 29-38"
       "Called from file \"lib/Frenetic_Vlr.ml\", line 181, characters 24-31"
       "Called from file \"lib/Frenetic_NetKAT_Compiler.ml\", line 356, characters 38-49"
       "Called from file \"lib/Frenetic_NetKAT_Compiler.ml\", line 363, characters 18-56"
       "Called from file \"async/Frenetic_OpenFlow0x01_Plugin.ml\", line 364, characters 16-76"
       "Called from file \"src/deferred_list.ml\", line 14, characters 22-29"
       "Called from file \"src/deferred0.ml\", line 57, characters 2-10"
       "Called from file \"src/deferred0.ml\", line 64, characters 64-69"
       "Called from file \"src/job_queue.ml\", line 160, characters 6-47" ""))
     (monitor
      (((name main) (here ()) (id 1) (has_seen_error true)
        (is_detached false))))))
   ((pid 24589) (thread_id 0)))))

any idea why this is the case?

jnfoster commented 7 years ago

Hmm. This looks like a bug. Any chance you could share the example that triggers it?

-N

On Fri, Jul 14, 2017 at 11:38 PM, Ten-Seng Guh notifications@github.com wrote:

hello so I'm basically trying to update the policy whenever certain events occur. After the event occurs, the program crashes with the following exception:

(((pid 24589) (thread_id 0)) ((human_readable 2017-07-15T02:21:10-0400) (int63_ns_sinceepoch 1500099670959842000)) "unhandled exception in Async scheduler" ("unhandled exception" ((src/monitor.ml.Error ((exn Not_found) (backtrace ("Raised at file \"src/core_hashtbl.ml\", line 296, characters 29-38" "Called from file \"lib/Frenetic_Vlr.ml\", line 181, characters 24-31" "Called from file \"lib/Frenetic_NetKAT_Compiler.ml\", line 356, characters 38-49" "Called from file \"lib/Frenetic_NetKAT_Compiler.ml\", line 363, characters 18-56" "Called from file \"async/Frenetic_OpenFlow0x01_Plugin.ml\", line 364, characters 16-76" "Called from file \"src/deferred_list.ml\", line 14, characters 22-29" "Called from file \"src/deferred0.ml\", line 57, characters 2-10" "Called from file \"src/deferred0.ml\", line 64, characters 64-69" "Called from file \"src/job_queue.ml\", line 160, characters 6-47" "")) (monitor (((name main) (here ()) (id 1) (has_seen_error true) (is_detached false)))))) ((pid 24589) (thread_id 0)))))

any idea why this is the case?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/frenetic-lang/frenetic/issues/566, or mute the thread https://github.com/notifications/unsubscribe-auth/ABwi0sdcUbNoLJWPztwPp17VXmpY6U6Bks5sOF57gaJpZM4OY71b .

reservoirman commented 7 years ago

Hi Nate, sorry for the delay. Here is the code that triggers it. I'm also running the following tree topology in mininet and attempting a pingall command:

sudo mn --controller=remote --topo=tree,2,2 --mac --arp

I've narrowed down the culprit to the call to the Controller.update (takeCareOfSentCounters srcMac); The problem goes away if I bind the return value of takeCareOfSentCounters to a variable and pass that into Controller.update, however I'd still like to know what's the difference. I'm also a beginner in OCaml so it could be something inherent in the language. Thanks for your help in advance!

`open Frenetic_NetKAT module StdMap = Map open Core.Std open Async.Std open Frenetic_OpenFlow open Frenetic_OpenFlow0x01 module Log = Frenetic_Log

module PacketTable = StdMap.Make(Int64)

let counter = ref 0 let cs1 = ref 0 let cs2 = ref 0 let cs3 = ref 0 let cs4 = ref 0

let cr1 = ref 0 let cr2 = ref 0 let cr3 = ref 0 let cr4 = ref 0

let h1forwarded = ref 0 let h2forwarded = ref 0 let h3forwarded = ref 0 let h4forwarded = ref 0

let sendToController : policy = Mod(Location(Pipe("sendToController")))

let%nk monitor = {| if true then $sendToController else drop |}

( this is based on the tutorial http://frenetic-lang.github.io/tutorials/NetKATRouting/ ) let%nk routing = {| if switch = 1 then if port = 1 then port := 2 else if port = 2 then port := 1 else drop else if switch = 2 then if ethDst = 1 then port := 1 else if ethDst = 2 then port := 2 else port := 3 else if switch = 3 then if ethDst = 3 then port := 1 else if ethDst = 4 then port := 2 else port := 3 else drop |}

let%nk routingMonitoring = {| $routing + $monitor |}

(this is an attempt at the extra credit portion) let sendToPacketLogger counter forwarded srcMac : policy = if (counter > 10 && !forwarded <= 0) then ( printf "Hey forwarding packets to the logger! From Host %Ld\n" srcMac; forwarded := 1; let%nk routingMonitoring = {|$routingMonitoring + (if ethSrc = $srcMac then ethDst := 4 else id)|} in routingMonitoring ) else routingMonitoring

let takeCareOfReceivedCounters dstMac = match dstMac with 1L -> cr1 := !cr1 + 1; printf "%d packets received on Host %Ld!\n" !cr1 dstMac; |2L -> cr2 := !cr2 + 1; printf "%d packets received on Host %Ld!\n" !cr2 dstMac; |3L -> cr3 := !cr3 + 1; printf "%d packets received on Host %Ld!\n" !cr3 dstMac; |4L -> cr4 := !cr4 + 1; printf "%d packets received on Host %Ld!\n" !cr4 dstMac; |_ -> printf "Holla unknown dest Mac %Ld\n" dstMac

let takeCareOfSentCounters srcMac: policy = match srcMac with 1L -> cs1 := !cs1 + 1; printf "%d packets sent on Host %Ld!\n" !cs1 srcMac; sendToPacketLogger !cs1 h1forwarded srcMac; |2L -> cs2 := !cs2 + 1; printf "%d packets sent on Host %Ld!\n" !cs2 srcMac; sendToPacketLogger !cs2 h1forwarded srcMac; |3L -> cs3 := !cs3 + 1; printf "%d packets sent on Host %Ld!\n" !cs3 srcMac; sendToPacketLogger !cs3 h1forwarded srcMac; |4L -> cs4 := !cs4 + 1; printf "%d packets sent on Host %Ld!\n" !cs4 srcMac; sendToPacketLogger !cs4 h1forwarded srcMac; |_ -> printf "Holla unknown source Mac %Ld\n" srcMac; routingMonitoring

let rec handle_events (module Controller : Frenetic_NetKATController.CONTROLLER) = let open Controller in event () >>= fun evt -> match evt with PacketIn(a,b,port,Buffered(, cstruct),d,e) | PacketIn(a,b,port,NotBuffered(cstruct),d,e) -> let dstMac = (Frenetic_Packet.parse cstruct).dlDst in
let srcMac = (Frenetic_Packet.parse cstruct).dlSrc in ( increment counters for packets sent/received per host. ) takeCareOfReceivedCounters dstMac; Controller.update (takeCareOfSentCounters srcMac); handleevents (module Controller) | -> handle_events (module Controller)

let _ = let module Controller = Frenetic_NetKAT_Controller.Make (Frenetic_OpenFlow0x01_Plugin) in Controller.start 6633; Controller.update routingMonitoring; Deferred.don't_wait_for(handle_events (module Controller)); ( Controller.update is equivalent to the OpenFlow Flow Mod call) never_returns (Scheduler.go ());`

jnfoster commented 7 years ago

Great. I am about to go on vacation so I may not have a chance to debug this for a few weeks. But this example gives me everything I need to do it.

Many Thanks, -N

On Thu, Jul 20, 2017 at 6:59 PM, Ten-Seng Guh notifications@github.com wrote:

Hi Nate, sorry for the delay. Here is the code that triggers it. I'm also running the following tree topology in mininet and attempting a pingall command:

sudo mn --controller=remote --topo=tree,2,2 --mac --arp

I've narrowed down the culprit to the call to the Controller.update (takeCareOfSentCounters srcMac); The problem goes away if I bind the return value of takeCareOfSentCounters to a variable and pass that into Controller.update, however I'd still like to know what's the difference. I'm also a beginner in OCaml so it could be something inherent in the language. Thanks for your help in advance!

`open Frenetic_NetKAT module StdMap = Map open Core.Std open Async.Std open Frenetic_OpenFlow open Frenetic_OpenFlow0x01 module Log = Frenetic_Log

module PacketTable = StdMap.Make(Int64)

let counter = ref 0 let cs1 = ref 0 let cs2 = ref 0 let cs3 = ref 0 let cs4 = ref 0

let cr1 = ref 0 let cr2 = ref 0 let cr3 = ref 0 let cr4 = ref 0

let h1forwarded = ref 0 let h2forwarded = ref 0 let h3forwarded = ref 0 let h4forwarded = ref 0

let sendToController : policy = Mod(Location(Pipe("sendToController")))

let%nk monitor = {| if true then $sendToController else drop |}

( this is based on the tutorial http://frenetic-lang.github.io/tutorials/NetKATRouting/ ) let%nk routing = {| if switch = 1 then if port = 1 then port := 2 else if port = 2 then port := 1 else drop else if switch = 2 then if ethDst = 1 then port := 1 else if ethDst = 2 then port := 2 else port := 3 else if switch = 3 then if ethDst = 3 then port := 1 else if ethDst = 4 then port := 2 else port := 3 else drop |}

let%nk routingMonitoring = {| $routing + $monitor |}

(this is an attempt at the extra credit portion)

let sendToPacketLogger counter forwarded srcMac : policy = if (counter > 10 && !forwarded <= 0) then ( printf "Hey forwarding packets to the logger! From Host %Ld\n" srcMac; forwarded := 1; let%nk routingMonitoring = {|$routingMonitoring + (if ethSrc = $srcMac then ethDst := 4 else id)|} in routingMonitoring ) else routingMonitoring

let takeCareOfReceivedCounters dstMac = match dstMac with 1L -> cr1 := !cr1 + 1; printf "%d packets received on Host %Ld!\n" !cr1 dstMac; |2L -> cr2 := !cr2 + 1; printf "%d packets received on Host %Ld!\n" !cr2 dstMac; |3L -> cr3 := !cr3 + 1; printf "%d packets received on Host %Ld!\n" !cr3 dstMac; |4L -> cr4 := !cr4 + 1; printf "%d packets received on Host %Ld!\n" !cr4 dstMac; |_ -> printf "Holla unknown dest Mac %Ld\n" dstMac

let takeCareOfSentCounters srcMac: policy = match srcMac with 1L -> cs1 := !cs1 + 1; printf "%d packets sent on Host %Ld!\n" !cs1 srcMac; sendToPacketLogger !cs1 h1forwarded srcMac; |2L -> cs2 := !cs2 + 1; printf "%d packets sent on Host %Ld!\n" !cs2 srcMac; sendToPacketLogger !cs2 h1forwarded srcMac; |3L -> cs3 := !cs3 + 1; printf "%d packets sent on Host %Ld!\n" !cs3 srcMac; sendToPacketLogger !cs3 h1forwarded srcMac; |4L -> cs4 := !cs4 + 1; printf "%d packets sent on Host %Ld!\n" !cs4 srcMac; sendToPacketLogger !cs4 h1forwarded srcMac; |_ -> printf "Holla unknown source Mac %Ld\n" srcMac; routingMonitoring

let rec handle_events (module Controller : Frenetic_NetKATController.CONTROLLER) = let open Controller in event () >>= fun evt -> match evt with PacketIn(a,b,port,Buffered(, cstruct),d,e) | PacketIn(a,b,port,NotBuffered(cstruct),d,e) -> let dstMac = (Frenetic_Packet.parse cstruct).dlDst in let srcMac = (Frenetic_Packet.parse cstruct).dlSrc in ( increment counters for packets sent/received per host. ) takeCareOfReceivedCounters dstMac; Controller.update (takeCareOfSentCounters srcMac); handleevents (module Controller) | -> handle_events (module Controller)

let _ = let module Controller = Frenetic_NetKAT_Controller.Make (Frenetic_OpenFlow0x01_Plugin) in Controller.start 6633; Controller.update routingMonitoring; Deferred.don't_wait_for(handle_events (module Controller)); ( Controller.update is equivalent to the OpenFlow Flow Mod call) never_returns (Scheduler.go ());`

On Mon, Jul 17, 2017 at 12:34 PM, Nate Foster notifications@github.com wrote:

Hmm. This looks like a bug. Any chance you could share the example that triggers it?

-N

On Fri, Jul 14, 2017 at 11:38 PM, Ten-Seng Guh <notifications@github.com

wrote:

hello so I'm basically trying to update the policy whenever certain events occur. After the event occurs, the program crashes with the following exception:

(((pid 24589) (thread_id 0)) ((human_readable 2017-07-15T02:21:10-0400) (int63_ns_sinceepoch 1500099670959842000)) "unhandled exception in Async scheduler" ("unhandled exception" ((src/monitor.ml.Error ((exn Not_found) (backtrace ("Raised at file \"src/core_hashtbl.ml\", line 296, characters 29-38" "Called from file \"lib/Frenetic_Vlr.ml\", line 181, characters 24-31" "Called from file \"lib/Frenetic_NetKAT_Compiler.ml\", line 356, characters 38-49" "Called from file \"lib/Frenetic_NetKAT_Compiler.ml\", line 363, characters 18-56" "Called from file \"async/Frenetic_OpenFlow0x01_Plugin.ml\", line 364, characters 16-76" "Called from file \"src/deferred_list.ml\", line 14, characters 22-29" "Called from file \"src/deferred0.ml\", line 57, characters 2-10" "Called from file \"src/deferred0.ml\", line 64, characters 64-69" "Called from file \"src/job_queue.ml\", line 160, characters 6-47" "")) (monitor (((name main) (here ()) (id 1) (has_seen_error true) (is_detached false)))))) ((pid 24589) (thread_id 0)))))

any idea why this is the case?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/frenetic-lang/frenetic/issues/566, or mute the thread https://github.com/notifications/unsubscribe-auth/ ABwi0sdcUbNoLJWPztwPp17VXmpY6U6Bks5sOF57gaJpZM4OY71b .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/frenetic-lang/frenetic/issues/566# issuecomment-315804346, or mute the thread https://github.com/notifications/unsubscribe-auth/ AFJZqg4DIDjmzRAXgPi8Ojh7Yc4iIruWks5sO4z4gaJpZM4OY71b .

-- Thanks, Ten-Seng Guh

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/frenetic-lang/frenetic/issues/566#issuecomment-316880510, or mute the thread https://github.com/notifications/unsubscribe-auth/ABwi0oYKt5Gqdp0kQf8xUldAXidzexpcks5sQAYCgaJpZM4OY71b .