On Tue, Aug 17, 2010 at 09:42:47PM +0530, Balbir Singh wrote:
> * Jason Baron <[email protected]> [2010-08-17 11:45:59]:
> 
> > On Tue, Aug 17, 2010 at 08:31:35PM +0530, Balbir Singh wrote:
> > > * Jason Baron <[email protected]> [2010-08-17 10:37:25]:
> > > 
> > > > On Sat, Aug 14, 2010 at 10:38:27AM +0530, Balbir Singh wrote:
> > > > > >> I have the python wrapper working to a large degree
> > > > > >>
> > > > > >
> > > > > > cool!
> > > > > >
> > > > > >> 1. Please provide input if it works at your end
> > > > > >
> > > > > > hmmm...I'm getting a Segmentation fault, which is coming from the 
> > > > > > inner
> > > > > > read stats loop. If I comment out the inner loop, I get a correct
> > > > > > listing of the directories.
> > > > > >
> > > > > > Haven't been able to narrow it down more than that yet...using 
> > > > > > libcgroup
> > > > > > libcgroup-0.36.2-2.fc15.i686. However, my python pkg might be 
> > > > > > outdated
> > > > > > i'm using: Python 2.6.4. I'll re-test after upgrading.
> > > > > >
> > > > > 
> > > > > Could you please narrow down using gdb and see where the dump is
> > > > > coming from. Are you suggesting that ret, p =
> > > > > cgroup_read_stats_next(p, cg_stat) in python code is causing the
> > > > > problem? python 2.6.4 is good, 2.7 would require movement to the
> > > > > capsule module in python. What version of swig are you using?
> > > > > 
> > > > > Balbir
> > > > 
> > > > Hi,
> > > > 
> > > > so the output from the unmodified script is:
> > > > 
> > > > "
> > > > $ ./try.py 
> > > > 
> 
> I assume try.py is the python script I posted? I presume you are
> setting back the handle by using the form
>         ret, p = cgroup_read_stats_begin()
> 

that's right. it's the same script you posted, here it is for reference:


#!/usr/bin/python

from libcgroup import *
from ctypes import *

cgroup_init()
#
# Add the correct controllers based on the mount point
#
cg_stat = cgroup_stat()
tree_handle = c_void_p()
info = cgroup_file_info()
lvl = new_intp()
ret1, tree_handle = cgroup_walk_tree_begin("memory", "/", 0,
tree_handle, info, lvl)
root_len = len(info.full_path) - 1
while ret1 != ECGEOF:
        if (info.type == CGROUP_FILE_TYPE_DIR):
                dir = info.full_path[root_len:]
                print "\nDirectory %s\n" %(dir)

                p = c_void_p()
                ret, p = cgroup_read_stats_begin("memory", dir, p, cg_stat)
                while ret != ECGEOF:
                        print "%s:%s" %(cg_stat.name, cg_stat.value.strip('\n'))
                        ret, p = cgroup_read_stats_next(p, cg_stat)

                cgroup_read_stats_end(p)
        ret1, tree_handle = cgroup_walk_tree_next(0, tree_handle,
info, intp_value(lvl))

cgroup_walk_tree_end(tree_handle)
delete_intp(lvl)


> > > > Directory /
> > > > 
> > > > :
> > > > Segmentation fault (core dumped)
> > > > "
> > > > 
> > > > running gdb on the resulting core:
> > > > 
> > > > Core was generated by `/usr/bin/python ./try.py'.
> > > > Program terminated with signal 11, Segmentation fault.
> > > > #0  0x002c31b8 in _IO_getdelim (lineptr=0xbf9fb8dc, n=0xbf9fb8d8,
> > > > delimiter=10, fp=0xb776fb78) at iogetdelim.c:58
> > > > 58        _IO_acquire_lock (fp);
> > > > (gdb) bt
> > > > #0  0x002c31b8 in _IO_getdelim (lineptr=0xbf9fb8dc, n=0xbf9fb8d8,
> > > > delimiter=10, fp=0xb776fb78) at iogetdelim.c:58
> > > 
> > > I am sure the fp here is invalid, does print *fp at frame 0 give
> > > anything useful?
> > > 
> > 
> > (gdb) p fp
> > $2 = (_IO_FILE *) 0xb776fb78
> > (gdb) p *fp
> > $3 = {_flags = 37, _IO_read_ptr = 0x738c20 "R", _IO_read_end = 0x1
> > <Address 0x1 out of bounds>, 
> >   _IO_read_base = 0x567ea871 <Address 0x567ea871 out of bounds>,
> > _IO_write_base = 0x1 <Address 0x1 out of bounds>, 
> >   _IO_write_ptr = 0x670070 "", _IO_write_end = 0x2 <Address 0x2 out of
> > bounds>, _IO_buf_base = 0x738c20 "R", 
> >   _IO_buf_end = 0x3 <Address 0x3 out of bounds>, _IO_save_base =
> > 0x1326ccc8 <Address 0x1326ccc8 out of bounds>, 
> >   _IO_backup_base = 0x1 <Address 0x1 out of bounds>, _IO_save_end =
> > 0x707574 "C\203\004\002O\n\r\004\306\303A\305\016\004A\v(", 
> >   _markers = 0x1, _chain = 0x738c20, _fileno = 2, _flags2 = -1,
> > _old_offset = 0, _cur_column = 256, _vtable_offset = 0 '\000', 
> >   _shortbuf = "", _lock = 0x3, _offset = 8597507104, _codecvt =
> > 0xaa3d09e9, _wide_data = 0x1, _freeres_list = 0x7273, 
> >   _freeres_buf = 0x1, _freeres_size = 7572512, _mode = 2, 
> >   _unused2 =
> > "\377\377\377\377\000\000\000\000\000\001\000\000\001\000\000\000
> > \214s\000\002\000\000\000??\376#\001\000\000\000bs\000\000\001\000\000"}
> >
> 
> The generated code looks fine to me, the fp looks invalid, (_offset,
> _fileno seem incorrect).
>  

hmm....I'll try retesting with an older version of swig...but not sure
what's going on...

thanks,

-Jason

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to