Hi Fink Developers..

I've posted on this subject before, more or less, but I thought it might 
be worth recasting a bit and trying again. ;-)

The thing is I'm trying to get vpython working with MacOSX. I've got it 
basically working (and I even have an info file that works for me), but 
annoyingly, it crashes periodically with an exception thrown by the 
Numeric module. I discovered that the exception in Numeric was happening 
at the end of a "ufuncobject" call when the Numeric module checks the 
value of "errno". Now.. here's the thing, if I just run the code in a 
single thread, this *never* happens. However, if I run a Tkinter thread 
that only *reads* the values from a Numeric array (but uses a lock to 
avoid reading at the same time Numeric is writing) I still occasionally 
get errno set. I've hacked Numeric to get more information about the 
error, and it claims its "resource temporarily unavailable". I just need 
some hints to track this down. Can I set up gdb to break when errno is 
set? Any other ideas?

thanks!
-steve

P.S. Here was one version of my original message.

From: Steve Spicklemire <[EMAIL PROTECTED]>
Date: Wed Feb 27, 2002  07:28:37  AM America/Indianapolis
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: errno, threads, Numeric etc...  how to debug this?


Hi Folks,

I'm trying to build Numeric on MacOSX and while it basically works... it 
seems there are some problems. When I try to run the Demos/NumTut 
examples (using xfree86 and python2.2 from fink) I get random 
"unexpected math error" exceptions.

I checked the source and discovered that the errors are occuring in 
ufuncmodule. I edited ufuncmodule to get more info like so:

[spicklemire:~/Packages] steve% diff -c 
Numeric-20.3-orig/Src/ufuncobject.c Numeric-20.3/Src/ufuncobject.c
*** Numeric-20.3-orig/Src/ufuncobject.c Tue Aug 14 11:18:24 2001
--- Numeric-20.3/Src/ufuncobject.c      Mon Feb 25 15:42:08 2002
***************
*** 470,477 ****
         if (self->check_return) check_array(mps[i]);
       }

!     if (self->check_return && errno != 0) {math_error(); return -1;}
!
       return 0;
   }

--- 470,488 ----
         if (self->check_return) check_array(mps[i]);
       }

!     if (self->check_return && (errno != 0))
!       {
!       if ((errno == EDOM) || (errno == ERANGE))
!         {
!           math_error(); return -1;
!         }
!       else
!         {
!           fprintf(stderr, "Hmm.. error encountered -> %i\n", errno);
!           perror("error in ufunc generic function:");
!         }
!       }
!
       return 0;
   }


Now when I try to run the NumTut demo I see:

[spicklemire:~/Packages/Numeric-20.3/Demo] steve% python -c "import 
NumTut;NumTut.test()"
 >>> view(greece)
 >>> view(1.0-greece)
Hmm.. error encountered -> 35
error in ufunc generic function:: Resource temporarily unavailable
 >>> view(greeceBW)
 >>> view(greece*xgrade)
 >>> view(greece*ygrade)
 >>> negative = 1.0 - greece
 >>> view(greece*xgrade + negative*ygrade)
 >>> view(red)
 >>> view(green)
 >>> view(blue)
 >>> sine = sin(xgrade*6*pi)
 >>> view(green*sine + red*(1.0-sine))
 >>> view(green + red[::-1])
 >>> view(transpose(greece, (1,0,2)))
[spicklemire:~/Packages/Numeric-20.3/Demo] steve% python -c "import 
NumTut;NumTut.test()"
 >>> view(greece)
 >>> view(1.0-greece)
 >>> view(greeceBW)
 >>> view(greece*xgrade)
 >>> view(greece*ygrade)
 >>> negative = 1.0 - greece
 >>> view(greece*xgrade + negative*ygrade)
 >>> view(red)
 >>> view(green)
 >>> view(blue)
 >>> sine = sin(xgrade*6*pi)
 >>> view(green*sine + red*(1.0-sine))
 >>> view(green + red[::-1])
 >>> view(transpose(greece, (1,0,2)))
[spicklemire:~/Packages/Numeric-20.3/Demo] steve% python -c "import 
NumTut;NumTut.test()"
 >>> view(greece)
 >>> view(1.0-greece)
Hmm.. error encountered -> 35
error in ufunc generic function:: Resource temporarily unavailable
 >>> view(greeceBW)
 >>> view(greece*xgrade)
 >>> view(greece*ygrade)
 >>> negative = 1.0 - greece
 >>> view(greece*xgrade + negative*ygrade)
 >>> view(red)
 >>> view(green)
 >>> view(blue)
 >>> sine = sin(xgrade*6*pi)
 >>> view(green*sine + red*(1.0-sine))
 >>> view(green + red[::-1])
 >>> view(transpose(greece, (1,0,2)))

So... ufuncs just multiply, divide and suchlike! What "resources" are 
not available? It's fairly clear that it's thread related, since all the 
Numeric tests pass every time in a non-threaded example, as well as my 
own non-threaded testing to attempt to reproduce what I thought 
originally was a linking problem.

So... how can I track down where errno is actually getting set? Does the 
fact that it happens "randomly" mean that it's not due to some numerical 
computation, but more likely about timing between threads?

Also.. it seems that on MacOSX there is a separate "errno" value for 
each thread... so how could they be confused?

thanks for any insight. ;-)

-steve


_______________________________________________
Fink-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/fink-devel

Reply via email to