[matplotlib-devel] Coverity defects in python-basemap

2011-08-01 Thread Pavel Raiskup

 Hi,

I would like to report some issues in python basemap package and 
easy-fixes for
some of them. We would really appreciate if there was somebody who could 
look

on this and consider important bugs to be fixed.

These bugs was found by Coverity scan and we have ran it on Fedora 15
packages (srpm). There was some findings in python basemap package also. 
Coverity
is proprietary software but we can give its result to community (if 
interrested),

possibly we can re-run some tests on srpms on demand.

Patch for next three obvious bugs (plaintext cov. output) is attached:

Error: OVERRUN_STATIC:
basemap-0.99.4/src/pj_gridlist.c:252: overrun-local: Overrunning static 
array "name", with 128 elements, at position 128 with index variable 
"end_char".


Error: UNINIT:
basemap-0.99.4/src/mk_cheby.c:42: var_decl: Declaring variable "T" 
without initializer.
basemap-0.99.4/src/mk_cheby.c:150: uninit_use: Using uninitialized value 
"T".
basemap-0.99.4/src/mk_cheby.c:151: uninit_use: Using uninitialized value 
"T->mu".
basemap-0.99.4/src/mk_cheby.c:152: uninit_use: Using uninitialized value 
"T->cu".
basemap-0.99.4/src/mk_cheby.c:154: uninit_use: Using uninitialized value 
"T->mv".
basemap-0.99.4/src/mk_cheby.c:155: uninit_use: Using uninitialized value 
"T->cv".
basemap-0.99.4/src/mk_cheby.c:163: uninit_use: Using uninitialized value 
"T".


Error: NO_EFFECT:
basemap-0.99.4/src/PJ_sconics.c:52: self_assign: Assignment operation 
"*del = *del" has no effect.


__

But there is more defects (or coding style issues) and some of them are not
so obvious. There could be potential problems -- need to be consulted, e.g.:

Error: EVALUATION_ORDER:
basemap-0.99.4/src/PJ_stere.c:232: write_write_order: In "P->phits = 
(pj_param(P->params, "tlat_ts").i ? P->phits = pj_param(P->params, 
"rlat_ts").f : 1.5708)", "P->phits" is written in "P->phits" (the 
assignment left-hand side) and written in "pj_param(P->params, 
"tlat_ts").i ? P->phits = pj_param(P->params, "rlat_ts").f : 1.5708" but 
the order in which the side effects take place is undefined because 
there is no intervening sequence point.


Error: FORWARD_NULL:
basemap-0.99.4/src/emess.c:29: var_compare_op: Comparing "fmt" to null 
implies that "fmt" might be null.
basemap-0.99.4/src/emess.c:51: var_deref_model: Passing null variable 
"fmt" to function "vfprintf", which dereferences it.


Error: FORWARD_NULL:
basemap-0.99.4/src/pj_gridinfo.c:505: var_compare_op: Comparing "gp" to 
null implies that "gp" might be null.
basemap-0.99.4/src/pj_gridinfo.c:512: alias_transfer: Assigning null: 
"lnk" = "gp".
basemap-0.99.4/src/pj_gridinfo.c:512: var_deref_op: Dereferencing null 
variable "lnk".


Error: FORWARD_NULL:
basemap-0.99.4/src/pj_ell_set.c:30: var_compare_op: Comparing 
"start->next" to null implies that "start->next" might be null.
basemap-0.99.4/src/pj_ell_set.c:92: var_deref_op: Dereferencing null 
variable "start->next".


Coverity test was done on:
http://sourceforge.net/projects/matplotlib/files/matplotlib-toolkits/basemap-0.99.4/basemap-0.99.4.tar.gz

..so svn version is little different (line numbers) but it can be handy for
finding hidden bugs. I can send you full plain-text log if you want.

Pavel


Index: src/mk_cheby.c
===
--- src/mk_cheby.c	(revision 8988)
+++ src/mk_cheby.c	(working copy)
@@ -36,7 +36,7 @@
 mk_cheby(projUV a, projUV b, double res, projUV *resid, projUV (*func)(projUV), 
 	int nu, int nv, int power) {
 	int j, i, nru, nrv, *ncu, *ncv;
-	Tseries *T;
+	Tseries *T = NULL;
 	projUV **w;
 	double cutres;
 
Index: src/pj_gridlist.c
===
--- src/pj_gridlist.c	(revision 8988)
+++ src/pj_gridlist.c	(working copy)
@@ -227,7 +227,7 @@
  s[end_char] != '\0' && s[end_char] != ','; 
  end_char++ ) {}
 
-if( end_char > sizeof(name) )
+if( end_char >= sizeof(name) )
 {
 pj_errno = -38;
 pj_release_lock();
Index: src/PJ_sconics.c
===
--- src/PJ_sconics.c	(revision 8988)
+++ src/PJ_sconics.c	(working copy)
@@ -46,7 +46,6 @@
 		*del = 0.5 * (p2 - p1);
 		P->sig = 0.5 * (p2 + p1);
 		err = (fabs(*del) < EPS || fabs(P->sig) < EPS) ? -42 : 0;
-		*del = *del;
 	}
 	return err;
 }
--
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] Fwd: IOError: [Errno 4] Interrupted system call (Qt4 backend)

2011-08-01 Thread Tony Yu
I probably should have sent this to the devel list instead of the user list.
Is anyone else running into a similar problem with Qt, or is something in my
install screwy?

Thanks,
-Tony

-- Forwarded message --
From: Tony Yu 
Date: Mon, Jul 18, 2011 at 5:58 PM
Subject: IOError: [Errno 4] Interrupted system call (Qt4 backend)
To: matplotlib-users 


When using the Qt4 backend, I'm getting an IOError similar to the one
detailed in:
http://old.nabble.com/matplotlib-with-Qt4-backend-td26311369.html
But it's definitely a separate issue (see Traceback below). This issue also
seems specific to Qt (I couldn't reproduce it on 'macosx', 'tkagg', or 'agg'
backends).

I found a number of other people who ran into similar problems with Qt.
Their solutions tend to be: catch the error and just try running the process
again.

I'm on Qt 4.7.3, OS X 10.6.8, Matplotlib trunk. Any help would be much
appreciated.

-Tony


Script reproducing issue

import matplotlib
matplotlib.use('qt4agg')
import matplotlib.pyplot as plt

for n in xrange(300):
plt.plot([0, 1])
plt.savefig('test.jpg')
# Since it's a signaling issue, it gets triggered randomly, so the attached
# script may or not reproduce the issue.

Traceback
=

traceback (most recent call last):
  File "qterror.py", line 8, in 
plt.savefig('test.jpg')
  File "/Users/Tony/python/devel/mpl/lib/matplotlib/pyplot.py", line 428, in
savefig
return fig.savefig(*args, **kwargs)
  File "/Users/Tony/python/devel/mpl/lib/matplotlib/figure.py", line 1162,
in savefig

self.canvas.print_figure(*args, **kwargs)
  File
"/Users/Tony/python/devel/mpl/lib/matplotlib/backends/backend_qt4agg.py",
line
 153, in print_figure
FigureCanvasAgg.print_figure(self, *args, **kwargs)
  File "/Users/Tony/python/devel/mpl/lib/matplotlib/backend_bases.py", line
1979, in
print_figure
**kwargs)
  File "/Users/Tony/python/devel/mpl/lib/matplotlib/backend_bases.py", line
1799, in
print_jpg
buf, size = agg.print_to_buffer()
  File
"/Users/Tony/python/devel/mpl/lib/matplotlib/backends/backend_agg.py", line
45
7, in print_to_buffer
FigureCanvasAgg.draw(self)
  File
"/Users/Tony/python/devel/mpl/lib/matplotlib/backends/backend_agg.py", line
40
0, in draw
self.renderer = self.get_renderer()
  File
"/Users/Tony/python/devel/mpl/lib/matplotlib/backends/backend_agg.py", line
41
1, in get_renderer
self.renderer = RendererAgg(w, h, self.figure.dpi)
  File
"/Users/Tony/python/devel/mpl/lib/matplotlib/backends/backend_agg.py", line
51
, in __init__
RendererBase.__init__(self)
  File "/Users/Tony/python/devel/mpl/lib/matplotlib/backend_bases.py", line
114, in _
_init__
self._text2path = textpath.TextToPath()
   File "/Users/Tony/python/devel/mpl/lib/matplotlib/textpath.py", line 37,
in __init_
_
self._adobe_standard_encoding = self._get_adobe_standard_encoding()
  File "/Users/Tony/python/devel/mpl/lib/matplotlib/textpath.py", line 41,
in _get_ad
obe_standard_encoding
enc_name = dviread.find_tex_file('8a.enc')
  File "/Users/Tony/python/devel/mpl/lib/matplotlib/dviread.py", line 837,
in find_te
x_file
 result = pipe.communicate()[0].rstrip()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subpro
cess.py", line 663, in communicate
stdout = self.stdout.read()
IOError: [Errno 4] Interrupted system call
--
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Coverity defects in python-basemap

2011-08-01 Thread Benjamin Root
2011/7/28 Pavel Raiskup 

>  Hi,
>
> I would like to report some issues in python basemap package and easy-fixes
> for
> some of them. We would really appreciate if there was somebody who could
> look
> on this and consider important bugs to be fixed.
>
> These bugs was found by Coverity scan and we have ran it on Fedora 15
> packages (srpm). There was some findings in python basemap package also.
> Coverity
> is proprietary software but we can give its result to community (if
> interrested),
> possibly we can re-run some tests on srpms on demand.
>
> Patch for next three obvious bugs (plaintext cov. output) is attached:
>
> Error: OVERRUN_STATIC:
> basemap-0.99.4/src/pj_**gridlist.c:252: overrun-local: Overrunning static
> array "name", with 128 elements, at position 128 with index variable
> "end_char".
>
> Error: UNINIT:
> basemap-0.99.4/src/mk_cheby.c:**42: var_decl: Declaring variable "T"
> without initializer.
> basemap-0.99.4/src/mk_cheby.c:**150: uninit_use: Using uninitialized value
> "T".
> basemap-0.99.4/src/mk_cheby.c:**151: uninit_use: Using uninitialized value
> "T->mu".
> basemap-0.99.4/src/mk_cheby.c:**152: uninit_use: Using uninitialized value
> "T->cu".
> basemap-0.99.4/src/mk_cheby.c:**154: uninit_use: Using uninitialized value
> "T->mv".
> basemap-0.99.4/src/mk_cheby.c:**155: uninit_use: Using uninitialized value
> "T->cv".
> basemap-0.99.4/src/mk_cheby.c:**163: uninit_use: Using uninitialized value
> "T".
>
> Error: NO_EFFECT:
> basemap-0.99.4/src/PJ_sconics.**c:52: self_assign: Assignment operation
> "*del = *del" has no effect.
>
> __
>
> But there is more defects (or coding style issues) and some of them are not
> so obvious. There could be potential problems -- need to be consulted,
> e.g.:
>
> Error: EVALUATION_ORDER:
> basemap-0.99.4/src/PJ_stere.c:**232: write_write_order: In "P->phits =
> (pj_param(P->params, "tlat_ts").i ? P->phits = pj_param(P->params,
> "rlat_ts").f : 1.5708)", "P->phits" is written in "P->phits" (the assignment
> left-hand side) and written in "pj_param(P->params, "tlat_ts").i ? P->phits
> = pj_param(P->params, "rlat_ts").f : 1.5708" but the order in which the side
> effects take place is undefined because there is no intervening sequence
> point.
>
> Error: FORWARD_NULL:
> basemap-0.99.4/src/emess.c:29: var_compare_op: Comparing "fmt" to null
> implies that "fmt" might be null.
> basemap-0.99.4/src/emess.c:51: var_deref_model: Passing null variable "fmt"
> to function "vfprintf", which dereferences it.
>
> Error: FORWARD_NULL:
> basemap-0.99.4/src/pj_**gridinfo.c:505: var_compare_op: Comparing "gp" to
> null implies that "gp" might be null.
> basemap-0.99.4/src/pj_**gridinfo.c:512: alias_transfer: Assigning null:
> "lnk" = "gp".
> basemap-0.99.4/src/pj_**gridinfo.c:512: var_deref_op: Dereferencing null
> variable "lnk".
>
> Error: FORWARD_NULL:
> basemap-0.99.4/src/pj_ell_set.**c:30: var_compare_op: Comparing
> "start->next" to null implies that "start->next" might be null.
> basemap-0.99.4/src/pj_ell_set.**c:92: var_deref_op: Dereferencing null
> variable "start->next".
>
> Coverity test was done on:
> http://sourceforge.net/**projects/matplotlib/files/**
> matplotlib-toolkits/basemap-0.**99.4/basemap-0.99.4.tar.gz
>
> ..so svn version is little different (line numbers) but it can be handy for
> finding hidden bugs. I can send you full plain-text log if you want.
>
> Pavel
>
>
Pavel,

Coverity is an interesting product and I heard of it before on
TheDailyWTF.com (in positive light, of course!).  However, it appears that
you were scanning an outdated version of our software.  The current release
version is v1.0.1, and we are poised to do another release soon.  The
current version of our software can be found at
https://github.com/matplotlib/ (there are separate matplotlib and basemap
repos).  I would certainly be interested in the results on that.

However, if RedHat is interested in packaging matplotlib in a release of
RHEL (I know a lot of people at NOAA, NWS and NSSL who would appreciate
that) and there is a particular version of matplotlib that you have selected
for packaging, we can certainly work with you on that.

Ben Root
--
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Matplotlib-devel Digest, Vol 63, Issue 1

2011-08-01 Thread David Kaplan
Hi,

I will be on vacation with limited email from July 14 to August 7, 2011.

Bonjour,

Je serai en conge du 14 juillet jusqu'au 7 aout, 2011.

--
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel