Check V programs against data races #11699
Replies: 1 comment
-
According with @krolaw dynamic creation of threads from a loop is the Achilles. Indeed, threads launched at run time dynamically based on a decision matrix(if then else) will be analyzed based on static graph layout and might trigger false positive actions. // TO DO o add a new field FN_GO as a flag (Y / N) and extend the framework to all objects and functions. o cannot alter the value of an object declared immutable by 'contract'/ function signature
special case(s) //2 do not allow multiple pointers to the same object, with 'val' ref. capability inside any go fn() |
Beta Was this translation helpful? Give feedback.
-
We shall implement two fundamental laws of concurrency
1) Read Law: If I can read, no other go fn() can write.
2) Write Law: If I can write, no other go fn() can read.
I have an idea how to check all variables/objects versus all functions/ go routines in order of detecting at compile time data races. This action could be activated using a special compiler flag.
scope: create a graph with 2 types of nodes, and store it in tabular layout
a) only one node for object
b) go function nodes, all functions who process the variable of point a) over a know time frame
Example
obj_a => go fn1() => go fn2() => go fn3() => go fn4()
obj_b => go fn20() => go fn21() => go fn22() => go fn44()
// interleaved tree of go fn() and regular fn()
obj_c => go fn101() => fn102() => fn78() => fn99() => go fn21() => go fn22() => go fn44()
First step is to fill he following data structure (DATA STRUCTURE OF ALL VARs AND ALL GO FUNCTIONS)
Comments:
Each program is divided in time frames, all user space threads (go fn()) run in a unique time frame.
time frame start = first program line under main function where go fn() is read
time frame end = first program line after last go fn() is read
Group all calls to user space threads before a wait() function is detected
We assign a unique ID to a directed acyclic graph build with all go functions able to run in parallel/concurrent.
fn main() {
go fn1_root() // 1st concurrent time frame is starting here
go fn_matrix_mul()
wg.wait() // 1st concurrent time frame is ending here
}
fn1_root() {
go fn2()
}
fn2() {
go fn3()
}
fn3() {
go fn4()
}
fn4() {
}
In scope are the following go functions
fn1_root()
fn2()
fn3()
fn4()
fn_matrix_mul()
Comments:
each variable/object get assigned a unique ID;
cannot be 2 objects with the same ID computed for all V modules & files in scope
Comments:
can be more than 2 objects having the same name
Comments:
each object is linked to mutable / immutable status
Comments:
Mark each function in order to know if would run in concurrent mode or not
Comments:
name of the object taken from function definition
for a function with 3 parameters, will be 3 records, one for each parameter
Comments:
object capability taken from function definition
p_a1 := &a1
- define a pointer to object )Comments:
pointer/reference to object find inside function
Comments:
If object is written inside the function
a = 25
a++
a--
in general seek for object on left side of ‘=’
Comments:
the next function in chain where first var of principal function is used
the smallest granularity is at variable level, should create a linked chain of functions with root as variable
I did a small PoC using SQL, on V other approach is needed
Check invalid combinations of objects vs functions capability
Will return variable 7744 used on function fn2 get an error - impedance mismatch between object definition and how is defined on function signature.
Following query will find all objects having data race issues.
Beta Was this translation helpful? Give feedback.
All reactions