#6128: [with patch; needs review] Bug - sage-cleaner failed due to NULLs in
spawned-processes files written by cleaner.py
--------------------+-------------------------------------------------------
 Reporter:  was     |       Owner:  cwitty    
     Type:  defect  |      Status:  new       
 Priority:  major   |   Milestone:  sage-4.0.1
Component:  misc    |    Keywords:            
--------------------+-------------------------------------------------------
 From: adavid (on sage-devel)
 {{{
 After building 4.0rc0 overnight, on my laptop, I started make test
 the next morning. . I shutdown the laptop before completion as I had
 to rush out the door (suspend would have been a good idea...).

 Regardless, I ended up with a temporary file structure with a number
 of
 spawned_processes files consisting of NULLs which triggers the bug as
 detailed below.

 Why is there NULLs instead of numeric string? <--rhetorical question

 $SAGE_BASE/sage-main/sage/interfaces/cleaner.py writes the PID

 Async I/O means the PID may or may not be written on a shutdown/power
 outage etc.

 Patch:
 (against 4.0rc0)

 # HG changeset patch
 # User Anthony David <[email protected]>
 # Date 1243176398 -36000
 # Node ID 958178a11b9e809788f1eda0cc29107c456a1bbe
 # Parent  b25ac645ae77e49db250243280eab38c2431937a
 Improve write assurance of spawned_processes file by local/bin/sage-
 cleaner

 diff -r b25ac645ae77 -r 958178a11b9e sage/interfaces/cleaner.py
 --- a/sage/interfaces/cleaner.py Thu May 21 07:10:11 2009 -0700
 +++ b/sage/interfaces/cleaner.py Mon May 25 00:46:38 2009 +1000
 @@ -28,6 +28,8 @@
             return
         o = open(F,'w')
     o.write('%s %s\n'%(pid, cmd))
 +    o.flush()
 +    os.fsync(f.fileno())
     o.close()
     start_cleaner_if_not_running()



 Notes:


 - Linux carbonate 2.6.18-4-686 #1 SMP Mon Mar 26 17:17:36 UTC 2007
 i686 GNU/Linux
 - Debian GNU/Linux 5.0

 - tested patch with a shutdown during a make test, 82 spawned-
 processes files created.
 Successful sage-cleaner invocation on sage  startup.

 - no tests yet on other OSes/arches etc

 -  The sage-cleaner statement i=L.find(' ') in kill_spawned_jobs fails
 to find any spaces

 - could fix the above problem but it is better to attack the root
 cause,
 hence the patch to cleaner.py and not sage-cleaner

 - patch could be improved by creating a temporary file and them
 performing
 a rename after the close.

 - The debug print statements in sage-cleaner were uncommented to
 assist with
 defining the problem

 - Don't have access to TRAC

 - This is not a specific 4.0rc0 bug

 Bug:


 antho...@carbonate:~/sage-4.0.rc0$ ./sage
 ----------------------------------------------------------------------
 | Sage Version 4.0.rc0, Release Date: 2009-05-21                     |
 | Type notebook() for the GUI, and license() for information.        |
 ----------------------------------------------------------------------
 starting the cleaner
 sage: doing a cleanup
 checking on 4306
 it is no longer running, so we clean up
 SAGE Cleaner: deleting /home/anthonyd/.sage//temp/carbonate//4306
 checking on 4623
 it is running
 checking on 31727
 it is no longer running, so we clean up
 killing 31727's spawned jobs

 SAGE-Cleaner: trying to kill  with parent 31727

 Traceback (most recent call last):
  File "/home/anthonyd/sage-4.0.rc0/local/bin/sage-cleaner", line 108,
 in <module>
    while cleanup() > 0:
  File "/home/anthonyd/sage-4.0.rc0/local/bin/sage-cleaner", line 53,
 in cleanup
    if not e or (e and kill_spawned_jobs(spawned_processes,
 parent_pid)):
  File "/home/anthonyd/sage-4.0.rc0/local/bin/sage-cleaner", line 75,
 in kill_spawne\
 d_jobs
    os.killpg(int(pid), 9)
 ValueError: invalid literal for int() with base 10: ''


 ...

 $ ls -laR /home/anthonyd/.sage/temp/carbonate/31727/
 /home/anthonyd/.sage/temp/carbonate/31727/:
 total 12
 drwxr-xr-x 3 anthonyd anthonyd    46 2009-05-24 06:58 .
 drwxr-xr-x 9 anthonyd anthonyd 12288 2009-05-24 22:26 ..
 drwxr-xr-x 2 anthonyd anthonyd    21 2009-05-24 06:58 interface
 -rw-r--r-- 1 anthonyd anthonyd    10 2009-05-24 06:58
 spawned_processes

 /home/anthonyd/.sage/temp/carbonate/31727/interface:
 total 4
 drwxr-xr-x 2 anthonyd anthonyd  21 2009-05-24 06:58 .
 drwxr-xr-x 3 anthonyd anthonyd  46 2009-05-24 06:58 ..
 -rw-r--r-- 1 anthonyd anthonyd 110 2009-05-24 06:58 tmp31727

  od -xc /home/anthonyd/.sage/temp/carbonate/31727/spawned_processes
 0000000 0000 0000 0000 0000 0000
         \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
 0000012
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/6128>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to