Re: how to debug when "Segmentation fault"

2005-10-05 Thread Maksim Kasimov

looks sad :(

ok, until the decision not found, i've run my script (if someone have the same 
problem) using sh-script like this:

#!/bin/sh
while true
do
myscript.py
echo "scrip was fault" | mail -s "run.sh" [EMAIL PROTECTED]
done



... still works ;)


Franz Steinhaeusler wrote:
> Tamer, thanks for your tip.
> 
> I tried Jeff's code:
> 
> import marshal
> f = lambda: None
> code =
> marshal.loads(marshal.dumps(f.func_code).replace('d\0\0S','d\xff\xffS'))
> f.func_code = code
> f()
> 
> saved it as foo.py, than
> 
> C:\Python24\Lib>gdb python
> GNU gdb 5.1.1 (mingw experimental)
> Copyright 2002 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you
> are
> welcome to change it and/or distribute copies of it under certain
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for
> details.
> This GDB was configured as "mingw32"...(no debugging symbols found)...
> (gdb) r foo.py
> Starting program: C:\Python24/python.exe foo.py
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x1e027b23 in ?? ()
> (gdb) bt
> #0  0x1e027b23 in ?? ()
> #1  0x00977240 in ?? ()
> #2  0x1e1a82b8 in ?? ()
> Cannot access memory at address 0x7
> (gdb)
> 
> How can I interpret this results? ;)
> 
> Am I right, that I need a debug build of python built with mingw or
> cygwin in Windows?


-- 
Best regards,
Maksim Kasimov
mailto: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to debug when "Segmentation fault"

2005-10-05 Thread jepler
Interesting.  I'd noticed that the metaclass one didn't crash my 2.2, but I
didn't check the marshal one.

This one core dumps in 'Python 2.2.2 (#1, Feb 24 2003, 19:13:11) ... linux2'
but inexplicably prints 'keys' when I ran it on the 2.4.1 I used in my last
post.

>>> import marshal
>>> f = lambda: None
>>> d = marshal.dumps(f.func_code).replace('\0\0S', '~~S')
>>> f.func_code = marshal.loads(d)
>>> f()

This crashes both my 2.2.2 and 2.4.1:
>>> import marshal
>>> f = lambda: None
>>> d = marshal.dumps(f.func_code).replace('\0\0S', '\xff\xffS')
>>> f.func_code = marshal.loads(d)
>>> f()

Jeff


pgpHJKzMCPaq6.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: how to debug when "Segmentation fault"

2005-10-05 Thread Maksim Kasimov
[EMAIL PROTECTED] wrote:
> I've rewritten your middle example to be clearer.
> $ python2.4
> Python 2.4.1 (#1, May 16 2005, 15:15:14) 
> [GCC 4.0.0 20050512 (Red Hat 4.0.0-5)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> 
type("Y", (type,), {"mro": lambda x: [float]})("X", (), {})

on my machines:
 >>> type("Y", (type,), {"mro": lambda x: [float]})("X", (), {})



> 
> 
> and here's another one for you to enjoy:
> 
import marshal
f = lambda: None
code = 
marshal.loads(marshal.dumps(f.func_code).replace('d\0\0S','d\xff\xffS'))
f.func_code = code
f()

just no any output

 >>> dir(code)
['__class__', '__cmp__', '__delattr__', '__doc__', '__getattribute__', 
'__hash__', '__init__', '__new__', '__reduce__', '__repr__', '__setattr__', 
'__str__', 'co_argcount', 'co_cellvars', 'co_code', 'co_consts', 'co_filename', 
'co_firstlineno', 'co_flags', 'co_freevars', 'co_lnotab', 'co_name', 
'co_names', 'co_nlocals', 'co_stacksize', 'co_varnames']


Python 2.2.3 (#1, Oct 22 2004, 03:10:44)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4


-- 
Best regards,
Maksim Kasimov
mailto: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to debug when "Segmentation fault"

2005-10-05 Thread Franz Steinhaeusler
On Wed, 05 Oct 2005 14:53:45 +0200, Tamer Fahmy
<[EMAIL PROTECTED]> wrote:

>On Tue, 04 Oct 2005 19:13:10 +0300, Maksim Kasimov wrote:
>> my programm sometime gives "Segmentation fault" message (no matter how
>> long the programm had run (1 day or 2 weeks). And there is nothing in
>> log-files that can points the problem. My question is how it possible to
>> find out where is the problem in the code? Thanks for any help.
>> 
>> Python 2.2.3
>> FreeBSD
>
>you could start your program within a gdb session like so:
>
>$ gdb python
>GNU gdb 6.1.1 [FreeBSD]
>Copyright 2004 Free Software Foundation, Inc. GDB is free software,
>covered by the GNU General Public License, and you are welcome to change
>it and/or distribute copies of it under certain conditions. Type "show
>copying" to see the conditions. There is absolutely no warranty for GDB. 
>Type "show warranty" for details. This GDB was configured as
>"i386-marcel-freebsd"...(no debugging symbols found)...
>(gdb) r foo.py
>Starting program: /usr/bin/python foo.py ...
>
>once your progmam segfaults you can then inspect the stack through:
>
>(gdb) bt
>
>cheers,
>  tamer.


Tamer, thanks for your tip.

I tried Jeff's code:

import marshal
f = lambda: None
code =
marshal.loads(marshal.dumps(f.func_code).replace('d\0\0S','d\xff\xffS'))
f.func_code = code
f()

saved it as foo.py, than

C:\Python24\Lib>gdb python
GNU gdb 5.1.1 (mingw experimental)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "mingw32"...(no debugging symbols found)...
(gdb) r foo.py
Starting program: C:\Python24/python.exe foo.py

Program received signal SIGSEGV, Segmentation fault.
0x1e027b23 in ?? ()
(gdb) bt
#0  0x1e027b23 in ?? ()
#1  0x00977240 in ?? ()
#2  0x1e1a82b8 in ?? ()
Cannot access memory at address 0x7
(gdb)

How can I interpret this results? ;)

Am I right, that I need a debug build of python built with mingw or
cygwin in Windows?
-- 
Franz Steinhaeusler
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to debug when "Segmentation fault"

2005-10-05 Thread Tamer Fahmy
On Tue, 04 Oct 2005 19:13:10 +0300, Maksim Kasimov wrote:
> my programm sometime gives "Segmentation fault" message (no matter how
> long the programm had run (1 day or 2 weeks). And there is nothing in
> log-files that can points the problem. My question is how it possible to
> find out where is the problem in the code? Thanks for any help.
> 
> Python 2.2.3
> FreeBSD

you could start your program within a gdb session like so:

$ gdb python
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc. GDB is free software,
covered by the GNU General Public License, and you are welcome to change
it and/or distribute copies of it under certain conditions. Type "show
copying" to see the conditions. There is absolutely no warranty for GDB. 
Type "show warranty" for details. This GDB was configured as
"i386-marcel-freebsd"...(no debugging symbols found)...
(gdb) r foo.py
Starting program: /usr/bin/python foo.py ...

once your progmam segfaults you can then inspect the stack through:

(gdb) bt

cheers,
  tamer.

-- 
  hardware, n: The parts of a computer system that can be kicked.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to debug when "Segmentation fault"

2005-10-05 Thread Pierre Barbier de Reuille
Maksim Kasimov a écrit :
> 
> yes, to generete core dump is the best way,
> 
> but the command "$ ulimit -c 50" don't make python to generete core
> dump in the time of crush.
> 
> I would like to know how to run python script so if it crushes than core
> dump will be genereted.
> 
> Thanks
> 
> 

If it does not, that probably means the core file is larger ... try a
larger value or even "unlimited" :

$ ulimit -c unlimited

Pierre
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: how to debug when "Segmentation fault"

2005-10-05 Thread Maksim Kasimov

yes, to generete core dump is the best way,

but the command "$ ulimit -c 50" don't make python to generete core dump in 
the time of crush.

I would like to know how to run python script so if it crushes than core dump 
will be genereted.

Thanks


Pierre Barbier de Reuille wrote:
> Maksim Kasimov a écrit :
> 
>>Hello,
>>
>>my programm sometime gives "Segmentation fault" message (no matter how
>>long the programm had run (1 day or 2 weeks). And there is nothing in
>>log-files that can points the problem.
>>My question is how it possible to find out where is the problem in the
>>code? Thanks for any help.
>>
>>Python 2.2.3
>>FreeBSD
>>
> 
> 
> Well, your best bet is to generate a core file !
> To do so, in the shell launching the program, you need to accept core
> files. The command is :
> 
> $ ulimit -c 
> 
> For example:
> $ ulimit -c 50
> 
> For a 500MB max file.
> 
> Then, if your program crash, you should see a file named "core."
> where  is the PID of the process. You can know exactly where the
> program crashed using gbd :
> 
> $ gdb --core=core.
> 
> Then, depending on the debug information you have in your executables
> you may (or may not) be able to know what happened :)
> 
> Pierre


-- 
Best regards,
Maksim Kasimov
mailto: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: how to debug when "Segmentation fault"

2005-10-04 Thread jepler
I've rewritten your middle example to be clearer.
$ python2.4
Python 2.4.1 (#1, May 16 2005, 15:15:14) 
[GCC 4.0.0 20050512 (Red Hat 4.0.0-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> type("Y", (type,), {"mro": lambda x: [float]})("X", (), {})

and here's another one for you to enjoy:
>>> import marshal
>>> f = lambda: None
>>> code = 
>>> marshal.loads(marshal.dumps(f.func_code).replace('d\0\0S','d\xff\xffS'))
>>> f.func_code = code
>>> f()

Jeff


pgpJRlU4jt6JK.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: how to debug when "Segmentation fault"

2005-10-04 Thread Michael Ekstrand
On Oct 4, 2005, at 2:08 PM, Jp Calderone wrote:
> On Tue, 4 Oct 2005 11:22:24 -0500, Michael Ekstrand 
> <[EMAIL PROTECTED]> wrote:
>> I've never seen "stock" Python (stable release w/ only included 
>> modules)
>> segfault, but did see a segfault with an extension module I was using
>> the other week (lxml IIRC, but I'm not sure).
>>
>
> [EMAIL PROTECTED]:~$ python
> Python 2.4.2c1 (#2, Sep 24 2005, 00:48:19)
> [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
 import sys
 sys.setrecursionlimit(1e9)
> __main__:1: DeprecationWarning: integer argument expected, got float
 (lambda f: f(f))(lambda f: f(f))
> Segmentation fault
> [EMAIL PROTECTED]:~$ python
> Python 2.4.2c1 (#2, Sep 24 2005, 00:48:19)
> [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
 class foo(type):
> ... def mro(self):
> ... return [float]
> ...
 class bar:
> ... __metaclass__ = foo
> ...
> Segmentation fault
> [EMAIL PROTECTED]:~$ python
> Python 2.4.2c1 (#2, Sep 24 2005, 00:48:19)
> [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
 import dl
 dl.open('libc.so.6').call('memcpy', 0, 0, 1024)
> Segmentation fault
> [EMAIL PROTECTED]:~$

I stand corrected.

Except for the 2nd one, where I'm not quite sure what's going on, I'd 
say I have yet to see the Python interpreter crash when doing "normal" 
things not involving C esoteria (for some definition of normal not 
including setting the recursion limit to 1e9).

Or  maybe my total faith in Python to keep me from ever having to think 
about memory problems when doing high-level coding is misplaced, but 
I'd like to think not...

- Michael

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to debug when "Segmentation fault"

2005-10-04 Thread Jp Calderone
On Tue, 4 Oct 2005 11:22:24 -0500, Michael Ekstrand <[EMAIL PROTECTED]> wrote:
>On Tuesday 04 October 2005 11:13, Maksim Kasimov wrote:
>> my programm sometime gives "Segmentation fault" message (no matter
>> how long the programm had run (1 day or 2 weeks). And there is
>> nothing in log-files that can points the problem. My question is how
>> it possible to find out where is the problem in the code? Thanks for
>> any help.
>
>What extension modules are you using?
>
>I've never seen "stock" Python (stable release w/ only included modules)
>segfault, but did see a segfault with an extension module I was using
>the other week (lxml IIRC, but I'm not sure).
>

[EMAIL PROTECTED]:~$ python
Python 2.4.2c1 (#2, Sep 24 2005, 00:48:19) 
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.setrecursionlimit(1e9)
__main__:1: DeprecationWarning: integer argument expected, got float
>>> (lambda f: f(f))(lambda f: f(f))
Segmentation fault
[EMAIL PROTECTED]:~$ python
Python 2.4.2c1 (#2, Sep 24 2005, 00:48:19) 
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class foo(type):
... def mro(self):
... return [float]
... 
>>> class bar:
... __metaclass__ = foo
... 
Segmentation fault
[EMAIL PROTECTED]:~$ python
Python 2.4.2c1 (#2, Sep 24 2005, 00:48:19) 
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dl
>>> dl.open('libc.so.6').call('memcpy', 0, 0, 1024)
Segmentation fault
[EMAIL PROTECTED]:~$ 

Though to be honest, even I consider the 3rd example a bit of a cheat ;)

Jp
-- 
http://mail.python.org/mailman/listinfo/python-list


[OT] Re: how to debug when "Segmentation fault"

2005-10-04 Thread Inyeol Lee
On Tue, Oct 04, 2005 at 11:22:24AM -0500, Michael Ekstrand wrote:
[...]
> I've never seen "stock" Python (stable release w/ only included modules) 
> segfault, but did see a segfault with an extension module I was using 
> the other week (lxml IIRC, but I'm not sure).
> 
> - Michael

So far, this is the simplest way to crash stock python, at least in
Unix/Linux;

$ python < /bin

If you redirect directory instead of file, python crashes. I think this bug was
introduced around 2.1 or 2.2, and not yet fixed as of 2.4.1.

- Inyeol
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to debug when "Segmentation fault"

2005-10-04 Thread Pierre Barbier de Reuille
Maksim Kasimov a écrit :
> 
> Hello,
> 
> my programm sometime gives "Segmentation fault" message (no matter how
> long the programm had run (1 day or 2 weeks). And there is nothing in
> log-files that can points the problem.
> My question is how it possible to find out where is the problem in the
> code? Thanks for any help.
> 
> Python 2.2.3
> FreeBSD
> 

Well, your best bet is to generate a core file !
To do so, in the shell launching the program, you need to accept core
files. The command is :

$ ulimit -c 

For example:
$ ulimit -c 50

For a 500MB max file.

Then, if your program crash, you should see a file named "core."
where  is the PID of the process. You can know exactly where the
program crashed using gbd :

$ gdb --core=core.

Then, depending on the debug information you have in your executables
you may (or may not) be able to know what happened :)

Pierre
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: how to debug when "Segmentation fault"

2005-10-04 Thread Maksim Kasimov

there are a lot of packeges under suspicion:

cPickle, select, threading, logging, socket, struct


Michael Ekstrand wrote:
> On Tuesday 04 October 2005 11:13, Maksim Kasimov wrote:
> 
>>my programm sometime gives "Segmentation fault" message (no matter
>>how long the programm had run (1 day or 2 weeks). And there is
>>nothing in log-files that can points the problem. My question is how
>>it possible to find out where is the problem in the code? Thanks for
>>any help.
> 
> 
> What extension modules are you using?
> 
> I've never seen "stock" Python (stable release w/ only included modules) 
> segfault, but did see a segfault with an extension module I was using 
> the other week (lxml IIRC, but I'm not sure).
> 
> - Michael


-- 
Best regards,
Maksim Kasimov
mailto: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to debug when "Segmentation fault"

2005-10-04 Thread Michael Ekstrand
On Tuesday 04 October 2005 11:13, Maksim Kasimov wrote:
> my programm sometime gives "Segmentation fault" message (no matter
> how long the programm had run (1 day or 2 weeks). And there is
> nothing in log-files that can points the problem. My question is how
> it possible to find out where is the problem in the code? Thanks for
> any help.

What extension modules are you using?

I've never seen "stock" Python (stable release w/ only included modules) 
segfault, but did see a segfault with an extension module I was using 
the other week (lxml IIRC, but I'm not sure).

- Michael
-- 
http://mail.python.org/mailman/listinfo/python-list


how to debug when "Segmentation fault"

2005-10-04 Thread Maksim Kasimov

Hello,

my programm sometime gives "Segmentation fault" message (no matter how long the 
programm had run (1 day or 2 weeks). And there is nothing in log-files that can 
points the problem.
My question is how it possible to find out where is the problem in the code? 
Thanks for any help.

Python 2.2.3
FreeBSD

-- 
Best regards,
Maksim Kasimov
mailto: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list