[IPOL discuss] Serious bug in IPOL's demo system

Miguel Colom colom at cmla.ens-cachan.fr
Wed Dec 12 11:12:33 CET 2012


Dear all,
some months ago a serious bug in the demo system was discovered: if  
two or more concurrent executions of the same demo (technically, the  
same app.py object) are started, only the last execution is correct.

This problem is caused by a race condition in the app.py object, since  
it generates an identifying key to each client but it's overwritten by  
the last client.

It's a design flaw causing this race condition, since the app.py  
object should never try to store any state of the clients, but it's  
the clients that should provide this information.

Moreover, since the app.py object uses the (bad) key to get the  
work_dir and work_url properties, they're not correct at all.

I managed to find a solution for this problem and it seems to work:
- Remove the key property from the app.py
- Remove the work_url and work_dir from the app.py
- When a key is created in app.py, it is propagated to the pages that  
the uses sees and given back to the app.py. The app.py object never  
stores a key, but reads it from the client requests.
- The work_dir and work_url properties are converted into member  
functions of app.py: get_work_dir(key2) and get_work_url(key2). They  
receive the key as an argument.

I've applied these changes into my noise_clinic demo in Purple. The  
other demos aren't affected. Therefore, is possible to apply this  
solution to some demos, allowing for a progressive correction without  
shouting down the server.

I've added new files in the IPOL demo system code:
- base_app2.py
- empty_app2.py
- template/run2.html

The demos should be modified:
- Change app.py in order to use the new classes.
- Change its templates: params2.html, result2.html, wait2.html

You can have a look at these file from here:
http://dev.ipol.im/~colom/ipol_bug/

You can also look how these files are integrated in the Noise Clinic,  
in Purple.

@Nicolas Limare: I know you're working in a solution to this problem.  
This solution I propose seems to work well and can be applied  
progressively. When you come up with your solution, perhaps we can  
combine both, if any of us has missed something or has introduced  
additional flaws.

Best,
Miguel



More information about the discuss mailing list