[AstroPy] pywcs problem on Linux

Michael Droettboom mdroe at stsci.edu
Wed May 6 11:19:48 EDT 2009


That's a very strange traceback.

The problem is obviously here:

PyType_IsSubtype (a=0xfff688d8fff688d8, b=0x2a9579a500)

"a" is a bogus pointer.  But the inputs to PyArg_ParseTupleAndKeywords 
seem fine.

I just tested this on two other Linux machines -- RHEL 3 32-bit, and 
RHEL 4 64-bit -- both have no problems.  So there's some environmental 
or build difference about your machine.

Do you have valgrind installed?  If so, can you send me the output of 
the following command?  It may help track down where the memory 
corruption is happening.

  valgrind --tool=memcheck python test.py tmp

Cheers,
Mike

OKUMURA, Akira wrote:
> Hello Mike,
>
> The build log is here.
> http://www-utheal.phys.s.u-tokyo.ac.jp/~oxon/build.log
>
> Would you investigate it, please?
>
> 0)
> $ gcc --version
> gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-10)
> $ uname -a
> Linux yashi 2.6.9-78.0.1.ELsmp #1 SMP Tue Aug 5 13:53:03 CDT 2008 
> x86_64 x86_64 x86_64 GNU/Linux
> $ python
> Python 2.5.4 (r254:67916, May  6 2009, 07:09:17)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-10)] on linux2
>
> 1)
> $ sudo rm -rf /usr/local/lib/python2.5/site-packages/pywcs*
>
> 2)
> $ cd sw/pywcs-1.4-4.3
> $ rm -rf build
> $ python setup.py build > build.log 2>&1
> # => see the above link
> $ sudo python setup.py install
> $ python
> >>> import pywcs
> >>> pywcs.__path__
> ['/usr/local/lib/python2.5/site-packages/pywcs']
>
> 3)
> $ gdb python
> GNU gdb Red Hat Linux (6.3.0.0-1.159.el4rh)
> 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 "x86_64-redhat-linux-gnu"...Using host 
> libthread_db library "/lib64/tls/libthread_db.so.1".
>
> (gdb) run test.py tmp
> Starting program: /usr/local/bin/python test.py tmp
> [Thread debugging using libthread_db enabled]
> [New Thread 182896753024 (LWP 22366)]
> =========================================================================== 
>
> tmp/model_total_ICHII_bin00.fits
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 182896753024 (LWP 22366)]
> PyType_IsSubtype (a=0xfff688d8fff688d8, b=0x2a9579a500)
>     at Objects/typeobject.c:827
> 827        if (!(a->tp_flags & Py_TPFLAGS_HAVE_CLASS))
> (gdb) bt
> #0  PyType_IsSubtype (a=0xfff688d8fff688d8, b=0x2a9579a500)
>     at Objects/typeobject.c:827
> #1  0x0000002a9562ba08 in PyArg_ParseTupleAndKeywords (args=0x2a9aaeb4d0,
>     keywords=0x2a95661058, format=0x2a9a1f0006 "Oi:p2s", 
> kwlist=0x7fbfffd650)
>     at Python/getargs.c:1242
> #2  0x0000002a9a1a7773 in PyWcsprm_p2s (self=0x7e44d0,
>     args=0xfff688d8fff688d8, kwds=0x2a9579a500) at src/wcslib_wrap.c:746
> #3  0x0000002a95615fa4 in PyEval_EvalFrameEx (f=0x7e9020, 
> throwflag=Variable "throwflag" is not available.
> )
>     at Python/ceval.c:3612
> #4  0x0000002a95617335 in PyEval_EvalCodeEx (co=0x2a9a126c60, 
> globals=Variable "globals" is not available.
> )
>     at Python/ceval.c:2875
> #5  0x0000002a95616026 in PyEval_EvalFrameEx (f=0x7e8bd0, 
> throwflag=Variable "throwflag" is not available.
> )
>     at Python/ceval.c:3707
> #6  0x0000002a95617335 in PyEval_EvalCodeEx (co=0x2a9a126b70, 
> globals=Variable "globals" is not available.
> )
>     at Python/ceval.c:2875
> #7  0x0000002a955b7444 in function_call (func=0x2a9a13f1b8, 
> arg=0x2a958498e8,
>     kw=0x7c8e40) at Objects/funcobject.c:517
> #8  0x0000002a95597a33 in PyObject_Call (func=0xfff688d8fff688d8,
>     arg=0x2a9579a500, kw=0x2a9562b9cf) at Objects/abstract.c:1861
> #9  0x0000002a9561425b in PyEval_EvalFrameEx (f=0x7e89e0, 
> throwflag=Variable "throwflag" is not available.
> )
>     at Python/ceval.c:3892
> #10 0x0000002a95617335 in PyEval_EvalCodeEx (co=0x2a9a126cd8, 
> globals=Variable "globals" is not available.
> )
>     at Python/ceval.c:2875
> ---Type <return> to continue, or q <return> to quit---
> #11 0x0000002a95616026 in PyEval_EvalFrameEx (f=0x7dddc0, 
> throwflag=Variable "throwflag" is not available.
> )
>     at Python/ceval.c:3707
> #12 0x0000002a95616834 in PyEval_EvalFrameEx (f=0x74a0b0, 
> throwflag=Variable "throwflag" is not available.
> )
>     at Python/ceval.c:3698
> #13 0x0000002a95616834 in PyEval_EvalFrameEx (f=0x56ff50, 
> throwflag=Variable "throwflag" is not available.
> )
>     at Python/ceval.c:3698
> #14 0x0000002a95617335 in PyEval_EvalCodeEx (co=0x2a95860030, 
> globals=Variable "globals" is not available.
> )
>     at Python/ceval.c:2875
> #15 0x0000002a956174b2 in PyEval_EvalCode (co=0xfff688d8fff688d8,
>     globals=0x2a9579a500, locals=0x2a9562b9cf) at Python/ceval.c:514
> #16 0x0000002a9563934c in PyRun_FileExFlags (fp=0x501010,
>     filename=0x7fbffff113 "test.py", start=Variable "start" is not 
> available.
> ) at Python/pythonrun.c:1273
> #17 0x0000002a95639fd3 in PyRun_SimpleFileExFlags (fp=0x501010,
>     filename=0x7fbffff113 "test.py", closeit=1, flags=0x7fbfffec2c)
>     at Python/pythonrun.c:879
> #18 0x0000002a95645288 in Py_Main (argc=Variable "argc" is not available.
> ) at Modules/main.c:532
> #19 0x00000032b951c40b in __libc_start_main () from /lib64/tls/libc.so.6
> #20 0x00000000004006ba in _start ()
> #21 0x0000007fbfffedb8 in ?? ()
> #22 0x000000000000001c in ?? ()
> #23 0x0000000000000003 in ?? ()
> #24 0x0000007fbffff0fd in ?? ()
> #25 0x0000007fbffff113 in ?? ()
> ---Type <return> to continue, or q <return> to quit---
> #26 0x0000007fbffff11b in ?? ()
> #27 0x0000000000000000 in ?? ()
>
> Regards,
>
> OKUMURA, Akira oxon at ceres.phys.s.u-tokyo.ac.jp
> Department of Physics, The University of Tokyo
> 7-3-1 Hongo, Bunkyo-ku, Tokyo 113-0033
> TEL/FAX +81 3-5841-4173/4059
> Skype : okumura.akira
>
> On 2009/05/06, at 23:29, Michael Droettboom wrote:
>
>> Hmmm... I'm not seeing this problem here with your linked fits file 
>> and test.py.
>>
>> Occasionally the distutils build script that pywcs uses doesn't 
>> rebuild enough.  Try deleting the build directory and then rebuilding 
>> and installing.
>>
>> If that still doesn't work, can you send the following:
>>
>> - Your version of gcc
>> - The output of the build
>> - A gdb backtrace
>>
>> This last can be obtained by running "gdb python" and the command 
>> prompt.  Then "run test.py ." (assuming test.py and the fits file are 
>> in the current directory).  When it crashes, type "bt" to get a 
>> backtrace.
>>
>> Cheers,
>> Mike
>>
>> OKUMURA, Akira wrote:
>>> Hello again,
>>>
>>> ver 1.4-4.3 runs properly with the sample FITS and the modified 
>>> script  on my Mac (10.5). So the problem seems to happen only with 
>>> Linux.
>>>
>>>
>>> On 2009/05/06, at 23:07, OKUMURA, Akira wrote:
>>>
>>>
>>>> Hello Mike and Thomas,
>>>>
>>>> I modified test.py to use the second or third argument, but still I
>>>> get a seg fault after calling wcs_pix2sky. And wcs.wcs.fix() always
>>>> cause a seg fault. I have uploaded my sample FITS and modified  
>>>> test.py.
>>>>
>>>> http://www-utheal.phys.s.u-tokyo.ac.jp/~oxon/model_total_ICHII_bin00.fits 
>>>>
>>>> http://www-utheal.phys.s.u-tokyo.ac.jp/~oxon/test.py
>>>>
>>>> Could you investigate it?
>>>>
>>>> Regards,
>>>>
>>>> OKUMURA, Akira oxon at ceres.phys.s.u-tokyo.ac.jp
>>>> Department of Physics, The University of Tokyo
>>>> 7-3-1 Hongo, Bunkyo-ku, Tokyo 113-0033
>>>> TEL/FAX +81 3-5841-4173/4059
>>>> Skype : okumura.akira
>>>>
>>>> On 2009/05/06, at 22:30, Michael Droettboom wrote:
>>>>
>>>>
>>>>> It looks as if your new traceback is related to an API change -- all
>>>>> of the transformation functions now require an "offset" argument,
>>>>> which should be 0 for C/Numpy indexing or 1 for Fortran/FITS  
>>>>> indexing.
>>>>>
>>>>> If that change doesn't work for you, can you send me a FITS file and
>>>>> script to reproduce this off list?  I'll see if I can reproduce what
>>>>> you're seeing here.
>>>>>
>>>>> Mike
>>>>>
>>>>>
>>>>>
>>>>> OKUMURA, Akira wrote:
>>>>>
>>>>>> Hello Nadia,
>>>>>>
>>>>>> Thank you for your reply. I didn't know that new version has been
>>>>>> released recently. I installed pywcs-1.4-4.3.tar.gz and tried
>>>>>> test.py  in the package. But I got errors again.
>>>>>>
>>>>>> 1)
>>>>>> $ ./test.py .
>>>>>> = = =
>>>>>> =
>>>>>> =
>>>>>> =
>>>>>> = 
>>>>>> ====================================================================
>>>>>> ./cmap.fits
>>>>>> zsh: segmentation fault  ./test.py .
>>>>>>
>>>>>> the line wcs.wcs.fix() causes the seg fault.
>>>>>>
>>>>>> 2) comment out wcs.wcs.fix()
>>>>>> $ ./test.py .
>>>>>> = = =
>>>>>> =
>>>>>> =
>>>>>> =
>>>>>> = 
>>>>>> ====================================================================
>>>>>> ./cmap.fits
>>>>>> Traceback (most recent call last):
>>>>>> File "./test.py", line 82, in <module>
>>>>>>   run_directory(directory)
>>>>>> File "./test.py", line 74, in run_directory
>>>>>>   test_file(filepath)
>>>>>> File "./test.py", line 38, in test_file
>>>>>>   world = wcs.wcs_pix2sky(data3)
>>>>>> File "/usr/local/lib/python2.5/site-packages/pywcs/pywcs.py",
>>>>>> line  419, in wcs_pix2sky
>>>>>>   *args, **kwargs)
>>>>>> File "/usr/local/lib/python2.5/site-packages/pywcs/pywcs.py",
>>>>>> line  378, in _array_converter
>>>>>>   raise TypeError("Expected 2 or 3 arguments, %d given" %
>>>>>> len(args))
>>>>>> TypeError: Expected 2 or 3 arguments, 1 given
>>>>>>
>>>>>> I tried several FITS files but I got the same errors. Do you have
>>>>>> any  idea?
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> OKUMURA, Akira oxon at ceres.phys.s.u-tokyo.ac.jp
>>>>>> Department of Physics, The University of Tokyo
>>>>>> 7-3-1 Hongo, Bunkyo-ku, Tokyo 113-0033
>>>>>> TEL/FAX +81 3-5841-4173/4059
>>>>>> Skype : okumura.akira
>>>>>>
>>>>>> On 2009/05/06, at 20:47, Nadezhda Dencheva wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> You are running an older version of pywcs.
>>>>>>> I believe an upgrade to the latest release will fix this.
>>>>>>>
>>>>>>>
>>>>>>> Nadia Dencheva
>>>>>>>
>>>>>>> ---- Original message ----
>>>>>>>
>>>>>>>
>>>>>>>> Date: Wed, 6 May 2009 15:30:23 +0900
>>>>>>>> From: astropy-bounces at scipy.org (on behalf of "OKUMURA, Akira" 
>>>>>>>> <oxon at ceres.phys.s.u-tokyo.ac.jp
>>>>>>>>
>>>>>>>>> )
>>>>>>>>>
>>>>>>>>>
>>>>>>>> Subject: [AstroPy] pywcs problem on Linux
>>>>>>>> To: astropy at scipy.org
>>>>>>>>
>>>>>>>> Hello all,
>>>>>>>>
>>>>>>>> I have installed pywcs in two environments.
>>>>>>>> (1) Scientific Linux 4.7 (64 bit)
>>>>>>>> + Python 2.5.4 (r254:67916, May  6 2009, 07:09:17)
>>>>>>>> + GCC 3.4.6 20060404 (Red Hat 3.4.6-10)] on linux2
>>>>>>>> + pyfits-1.3
>>>>>>>> + pywcs-1.3a1-4.3
>>>>>>>> (2) Red Hat Enterprise Linux 4 (32 bit).
>>>>>>>> + Python 2.5.1 (r251:54863, Aug 24 2007, 16:22:50)
>>>>>>>> + GCC 3.4.3 (TWW)] on linux2
>>>>>>>> + pywcs-1.3a1-4.3
>>>>>>>> + pyfits-2.1.1
>>>>>>>>
>>>>>>>> But I got following errors even though it runs properly on Mac  
>>>>>>>> OS X
>>>>>>>> 10.5.
>>>>>>>> === Error on (1) ===
>>>>>>>>
>>>>>>>>
>>>>>>>>>>> hdulist = pyfits.open("cmap.fits")
>>>>>>>>>>> wcs = pywcs.WCS(hdulist[0].header)
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>> zsh: segmentation fault  python
>>>>>>>>
>>>>>>>> === Error on (2) ===
>>>>>>>>
>>>>>>>>
>>>>>>>>>>> hdulist = pyfits.open("cmap.fits")
>>>>>>>>>>> wcs = pywcs.WCS(hdulist[0].header)
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>> Traceback (most recent call last):
>>>>>>>> File "<stdin>", line 1, in <module>
>>>>>>>> File "/u/gl/oxon/tmp/lib/python2.5/site-packages/pywcs/pywcs.py",
>>>>>>>> line 155, in __init__
>>>>>>>> self.footprint = self._calcFootprint(header)
>>>>>>>> File "/u/gl/oxon/tmp/lib/python2.5/site-packages/pywcs/pywcs.py",
>>>>>>>> line 181, in _calcFootprint
>>>>>>>> return self.all_pix2sky(corners)
>>>>>>>> File "/u/gl/oxon/tmp/lib/python2.5/site-packages/pywcs/pywcs.py",
>>>>>>>> line 307, in all_pix2sky
>>>>>>>> return self._array_converter(self._all_pix2sky, *args, **kwargs)
>>>>>>>> File "/u/gl/oxon/tmp/lib/python2.5/site-packages/pywcs/pywcs.py",
>>>>>>>> line 294, in _array_converter
>>>>>>>> return func(args[0], **kwargs)
>>>>>>>> SystemError: Python/getargs.c:1246: bad argument to internal
>>>>>>>> function
>>>>>>>>
>>>>>>>> Is there any tips on running pywcs with Linux ?
>>>>>>>>
>>>>>>>> The FITS is as follows.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>>> print hdulist[0].header
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>> SIMPLE  =                    T / File conforms to NOST standard
>>>>>>>> BITPIX  =                   32 / Bits per pixel
>>>>>>>> NAXIS   =                    2 / No data is associated with this
>>>>>>>> header
>>>>>>>> NAXIS1  =                  160 / Length of data axis 1
>>>>>>>> NAXIS2  =                  160 / Length of data axis 2
>>>>>>>> EXTEND  =                    T / Extensions may be present
>>>>>>>> COMMENT   FITS (Flexible Image Transport System) format is
>>>>>>>> defined in
>>>>>>>> 'Astronomy
>>>>>>>> COMMENT   and Astrophysics', volume 376, page 359; bibcode:
>>>>>>>> 2001A&A...
>>>>>>>> 376..359H
>>>>>>>> CTYPE1  = 'GLON-AIT'           / RA---%%%, %%% represents the
>>>>>>>> projection method
>>>>>>>> CRPIX1  =                 80.5 / Reference pixel
>>>>>>>> CRVAL1  =                 211. / RA at the reference pixel
>>>>>>>> CDELT1  =                -0.25 / X-axis incr per pixel of physical
>>>>>>>> coord at posi
>>>>>>>> CUNIT1  = 'deg     '           / Physical unit of X-axis
>>>>>>>> CTYPE2  = 'GLAT-AIT'           / DEC---%%%, %%% represents the
>>>>>>>> projection method
>>>>>>>> CRPIX2  =                 80.5 / Reference pixel
>>>>>>>> CRVAL2  =                 -17. / DEC at the reference pixel
>>>>>>>> CDELT2  =                 0.25 / Y-axis incr per pixel of physical
>>>>>>>> coord at posi
>>>>>>>> CUNIT2  = 'deg     '           / Physical unit of Y-axis
>>>>>>>> CROTA2  =                   0. / Image rotation (deg)
>>>>>>>> DATE    = '2009-04-01T15:34:22' / file creation date (YYYY-MM-
>>>>>>>> DDThh:mm:ss U
>>>>>>>> FILENAME= 'cmap.fits'          /
>>>>>>>> TELESCOP= 'GLAST   '           /  name of telescope generating  
>>>>>>>> data
>>>>>>>> INSTRUME= 'LAT     '           /  name of instrument generating
>>>>>>>> data
>>>>>>>> DATE-OBS= '2009-03-11T21:33:18.000' / start date and time of the
>>>>>>>> observation (U
>>>>>>>> DATE-END= '2009-03-17T16:26:38.000' / end date and time of the
>>>>>>>> observation (UTC
>>>>>>>> NDSKEYS =                    5
>>>>>>>> EQUINOX =                2000. / Equinox of RA & DEC  
>>>>>>>> specifications
>>>>>>>> OBSERVER= 'Peter Michelson'    /  GLAST/LAT PI
>>>>>>>> CREATOR = 'gtbin   '           / Software and version creating  
>>>>>>>> file
>>>>>>>> HISTORY                   LatCountMapTemplate,v 1.3 2005/04/05
>>>>>>>> 21:06:39 peachey
>>>>>>>> HISTORY Exp
>>>>>>>> CHECKSUM= 'c8JZf8JXc8JXc8JX'   / HDU checksum updated
>>>>>>>> 2009-04-01T06:34:22
>>>>>>>> DATASUM = '182648  '           / data unit checksum updated
>>>>>>>> 2009-04-01T06:34:22
>>>>>>>> DSTYP1  = 'TIME    '
>>>>>>>> DSUNI1  = 's       '
>>>>>>>> DSVAL1  = 'TABLE   '
>>>>>>>> DSREF1  = ':GTI    '
>>>>>>>> DSTYP2  = 'POS(RA,DEC)'
>>>>>>>> DSUNI2  = 'deg     '
>>>>>>>> DSVAL2  = 'CIRCLE(86.81257852,-6.005536809,20)'
>>>>>>>> DSTYP3  = 'CTBCLASSLEVEL'
>>>>>>>> DSUNI3  = 'dimensionless'
>>>>>>>> DSVAL3  = '3:      '
>>>>>>>> DSTYP4  = 'ENERGY  '
>>>>>>>> DSUNI4  = 'MeV     '
>>>>>>>> DSVAL4  = '200:20000'
>>>>>>>> DSTYP5  = 'ZENITH_ANGLE'
>>>>>>>> DSUNI5  = 'deg     '
>>>>>>>> DSVAL5  = '0:100   '
>>>>>>>>
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>>
>>>>>>>> OKUMURA, Akira oxon at ceres.phys.s.u-tokyo.ac.jp
>>>>>>>> Department of Physics, The University of Tokyo
>>>>>>>> 7-3-1 Hongo, Bunkyo-ku, Tokyo 113-0033
>>>>>>>> TEL/FAX +81 3-5841-4173/4059
>>>>>>>> Skype : okumura.akira
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> AstroPy mailing list
>>>>>>>> AstroPy at scipy.org
>>>>>>>> http://mail.scipy.org/mailman/listinfo/astropy
>>>>>>>>
>>>>>>>>
>>>>>> _______________________________________________
>>>>>> AstroPy mailing list
>>>>>> AstroPy at scipy.org
>>>>>> http://mail.scipy.org/mailman/listinfo/astropy
>>>>>>
>>>>>>
>>>>> -- 
>>>>> Michael Droettboom
>>>>> Science Software Branch
>>>>> Operations and Engineering Division
>>>>> Space Telescope Science Institute
>>>>> Operated by AURA for NASA
>>>>>
>>>>>
>>>> _______________________________________________
>>>> AstroPy mailing list
>>>> AstroPy at scipy.org
>>>> http://mail.scipy.org/mailman/listinfo/astropy
>>>>
>>>
>>>
>>>
>>>
>>> Regards,
>>>
>>> OKUMURA, Akira oxon at ceres.phys.s.u-tokyo.ac.jp
>>> Department of Physics, The University of Tokyo
>>> 7-3-1 Hongo, Bunkyo-ku, Tokyo 113-0033
>>> TEL/FAX +81 3-5841-4173/4059
>>> Skype : okumura.akira
>>>
>>> _______________________________________________
>>> AstroPy mailing list
>>> AstroPy at scipy.org
>>> http://mail.scipy.org/mailman/listinfo/astropy
>>>
>>
>> -- 
>> Michael Droettboom
>> Science Software Branch
>> Operations and Engineering Division
>> Space Telescope Science Institute
>> Operated by AURA for NASA
>>
>

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA




More information about the AstroPy mailing list