SCIRun User Mailing List

Text archives Help


Re: [SCIRUN-USERS] pthreads and SCIRun objects (from Simon smyau@nyu)


Chronological Thread 
  • From: Michael Callahan <callahan@sci.utah.edu>
  • To: "J. Davison de St. Germain" <dav@sci.utah.edu>
  • Cc: scirun-users@sci.utah.edu
  • Subject: Re: [SCIRUN-USERS] pthreads and SCIRun objects (from Simon smyau@nyu)
  • Date: Tue, 13 Jun 2006 17:32:04 -0600

SCIRun should work with pthreads.  The thread library is a thin layer on
top of pthreads for those systems where that is supported.

It's not clear exactly where this is crashing from the given stack
trace.  However you could replace the compute_new_generation() function
in Core/Datatypes/Datatype.cc with something that doesn't use an
AtomicCounter.  Using an AtomicCounter is functionally redundant given
that we use a Mutex to create it (but may be more efficient).  You can
instead make current_generation be a static int, then lock the init_lock
and increment it.  Give something like this a try:

int
Datatype::compute_new_generation()
{
  static int counter = 0;
  init_lock.lock();
  const int result = counter++;
  init_lock.unlock();
  return result;
}

See if that gets you further along.

  Michael

On Tue, 2006-06-13 at 14:23 -0600, J. Davison de St. Germain wrote:
> [Note: The following message is from smyau@access2.cims.nyu.edu.
> Simon, please send email to the SCIRun-Users mailing list from the
> account you registered to receive mail at.  SCIRun-Users automatically
> rejects email from non-list members... hence the reason I needed to
> forward this message on.]
> 
> 
> Dear all,
> 
> I am new to developing scirun modules, and I am trying to write a SCIRun
> module around a package that uses pthreads. I discovered that we cannot
> create SCIRun objects (DenseMatrix, etc) within these newly spawned
> pthreads, as they will segfault with a null pointer (I've attached the
> stack trace at the end).
> 
> I've been looking through the documentation but couldn't find references
> to pthreads compatibility with SCIRun. I'm wondering if that means we
> can
> only create SCIRun object from within SCIRun threads? Or are there ways
> to
> work around this problem?
> 
> Any help is appreciated,
> 
> Thank you.
> 
> - Simon
> 
> P.S., Stack trace of the seg fault:
> 
> Thread "idle or main"(pid 3759) caught signal SIGSEGV at address (nil)
> (segmentation violation)
> Backtrace:
> /home/smyau/srcs/scirun2/SCIRun/linux32debug/lib/
> libCore_Thread.so(_ZN6SCIRun6Thread9niceAbortEPv+0x18)
> [0x401ce2ec]
> /home/smyau/srcs/scirun2/SCIRun/linux32debug/lib/libCore_Thread.so
> [0x401d32fc]
> /lib/tls/libpthread.so.0 [0x400758f8]
> /home/smyau/srcs/scirun2/SCIRun/linux32debug/lib/
> libCore_Thread.so(_ZN6SCIRun13AtomicCounterppEi+0x13)
> [0x401d18ff]
> /home/smyau/srcs/scirun2/SCIRun/linux32debug/lib/
> libCore_Datatypes.so(_ZN6SCIRun8Datatype22compute_new_generationEv+0x1f)
> [0x413f88f7]
> /home/smyau/srcs/scirun2/SCIRun/linux32debug/lib/
> libCore_Datatypes.so(_ZN6SCIRun8DatatypeC2Ev+0x2f)
> [0x413f899b]
> /home/smyau/srcs/scirun2/SCIRun/linux32debug/lib/
> libCore_Datatypes.so(_ZN6SCIRun15PropertyManagerC2Ev+0x12)
> [0x41419912]
> /home/smyau/srcs/scirun2/SCIRun/linux32debug/lib/
> libCore_Datatypes.so(_ZN6SCIRun11DenseMatrixC1Eii+0x11)
> [0x413fe329]
> /home/smyau/srcs/scirun2/SCIRun/linux32debug/lib/
> libPackages_SimonTest_Dataflow_Modules_DataIO.so(_ZN9SimonTest23g_TestMo
> duleAThreadFuncEPv+0x60)
> [0x437428b8]
> /lib/tls/libpthread.so.0 [0x40070484]
> /lib/tls/libc.so.6(__clone+0x57) [0x420df147]
>     1105658272: main (state = blocking on semaphore, main wait)
>     1074133808: internal service manager (detached, state = blocking,
> connection_list_condition_variable)
>     1114450736: TCL main event loop (detached, state = running)
>     1135196976: Scheduler (daemon, detached, state = blocking,
> NetworkEditor
> request FIFO, Mailbox empty condition)
>     1135332144: TestModuleA (state = running)
> 
> Abort signalled by pid: 3759
> With NULL thread pointer.
> resume(r)/dbx(d)/cvd(c)/kill thread(k)/exit(e)? e
> 
> ===========================================================================
> == The SCIRun Users mailing list: send email to majordomo@sci.utah.edu   ==
> == for more details.                                                     ==
> == Please acknowledge use of SCIRun in your papers and reports:          ==
> ==   see http://software.sci.utah.edu/scirun-biopse_citation.bib         ==
> ===========================================================================

===========================================================================
== The SCIRun Users mailing list: send email to majordomo@sci.utah.edu   ==
== for more details.                                                     ==
== Please acknowledge use of SCIRun in your papers and reports:          ==
==   see http://software.sci.utah.edu/scirun-biopse_citation.bib         ==
===========================================================================





Archive powered by MHonArc 2.6.16.

Top of page