thliebig / openEMS-Project

openEMS is a free and open electromagnetic field solver using the FDTD method.
427 stars 77 forks source link

openEMS crashes on the Rect_Waveguide.py example #232

Open yurivict opened 3 months ago

yurivict commented 3 months ago
$ python3.11 Rect_Waveguide.py
 ---------------------------------------------------------------------- 
 | openEMS 64bit -- version v0.0.36
 | (C) 2010-2023 Thorsten Liebig <thorsten.liebig@gmx.de>  GPL license
 ---------------------------------------------------------------------- 
        Used external libraries:
                CSXCAD -- Version: v0.6.3
                hdf5   -- Version: 1.12.2
                          compiled against: HDF5 library version: 1.12.2
                tinyxml -- compiled against: 2.6.2
                fparser
                boost  -- compiled against: 1_84
                vtk -- Version: 9.2.6
                       compiled against: 9.2.6

Create FDTD operator (compressed SSE + multi-threading)
FDTD simulation size: 27x12x132 --> 42768 FDTD cells 
FDTD timestep is: 5.18459e-13 s; Nyquist rate: 37 timesteps @2.60648e+10 Hz
Excitation signal length is: 1842 timesteps (9.55001e-10s)
Max. number of timesteps: 10000 ( --> 5.42888 * Excitation signal length)
Create FDTD engine (compressed SSE + multi-threading)
Running FDTD engine... this may take a while... grab a cup of coffee?!?
[@        4s] Timestep:          882 || Speed:    9.4 MC/s (4.538e-03 s/TS) || Energy: ~2.71e-22 (- 0.00dB)
Abort trap

Version: 0.0.36 FreeBSD 14.1

yurivict commented 3 months ago

After some debugging it appears that this Abort is caused by the uncaught exception:

#0  __cxa_throw (thrown_exception=0x78c00080, tinfo=0x77cdafb8 <typeinfo for boost::thread_interrupted>, dest=0x0) at /disk-samsung/freebsd-src/contrib/libcxxrt/exception.cc:821
821             __cxa_exception *ex = __cxa_init_primary_exception(thrown_exception, tinfo, dest);
(gdb) bt
#0  __cxa_throw (thrown_exception=0x78c00080, tinfo=0x77cdafb8 <typeinfo for boost::thread_interrupted>, dest=0x0) at /disk-samsung/freebsd-src/contrib/libcxxrt/exception.cc:821
#1  0x0000000077c80d0f in boost::detail::interruption_checker::check_for_interruption (this=0x7fffdeff5e40) at /usr/local/include/boost/thread/pthread/thread_data.hpp:199
#2  0x0000000077c80796 in boost::detail::interruption_checker::interruption_checker (this=0x7fffdeff5e40, cond_mutex=0x7860b418, cond=0x7860b420)
    at /usr/local/include/boost/thread/pthread/thread_data.hpp:213
#3  0x0000000077c803d3 in boost::condition_variable::wait (this=0x7860b418, m=...) at /usr/local/include/boost/thread/pthread/condition_variable.hpp:76
#4  0x0000000077c7e385 in boost::barrier::wait (this=0x7860b410) at /usr/local/include/boost/thread/barrier.hpp:234
#5  0x0000000077c7da22 in NS_Engine_Multithread::thread::operator() (this=0x7872eeb8) at /usr/ports/science/openems/work/openEMS-0.0.36/FDTD/engine_multithread.cpp:327
#6  0x0000000077c8510c in boost::detail::thread_data<NS_Engine_Multithread::thread>::run (this=0x7872ee00) at /usr/local/include/boost/thread/detail/thread.hpp:120
#7  0x0000000074020a5d in ?? () from /usr/local/lib/libboost_thread.so.1.84.0
#8  0x000000002c4f6bb5 in thread_start (curthread=0x7372de00) at /disk-samsung/freebsd-src/lib/libthr/thread/thr_create.c:289
#9  0x0000000000000000 in ?? ()
Backtrace stopped: Cannot access memory at address 0x7fffdeff6000
193│             void check_for_interruption()
194│             {
195│ #ifndef BOOST_NO_EXCEPTIONS
196│                 if(thread_info->interrupt_requested)
197│                 {
198│                     thread_info->interrupt_requested=false;
199├───────────────────> throw thread_interrupted(); // BOOST_NO_EXCEPTIONS protected
200│                 }
201│ #endif
202│             }
205│         public:
206│             explicit interruption_checker(pthread_mutex_t* cond_mutex,pthread_cond_t* cond):
207│                 thread_info(detail::get_current_thread_data()),m(cond_mutex),
208│                 set(thread_info && thread_info->interrupt_enabled), done(false)
209│             {
210│                 if(set)
211│                 {
212│                     lock_guard<mutex> guard(thread_info->data_mutex);
213├───────────────────> check_for_interruption();
214│                     thread_info->cond_mutex=cond_mutex;
215│                     thread_info->current_cond=cond;
216│                     BOOST_VERIFY(!posix::pthread_mutex_lock(m));
217│                 }
218│                 else
219│                 {
220│                     BOOST_VERIFY(!posix::pthread_mutex_lock(m));
221│                 }
222│             }
 66│ #if defined BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
 67│         if(! m.owns_lock())
 68│         {
 69│             boost::throw_exception(condition_error(-1, "boost::condition_variable::wait() failed precondition mutex not owned"));
 70│         }
 71│ #endif
 72│         int res=0;
 73│         {
 74│ #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
 75│             thread_cv_detail::lock_on_exit<unique_lock<mutex> > guard;
 76├───────────> detail::interruption_checker check_for_interruption(&internal_mutex,&cond);
 77│             pthread_mutex_t* the_mutex = &internal_mutex;
 78│             guard.activate(m);
 79│             res = posix::pthread_cond_wait(&cond,the_mutex);
 80│             check_for_interruption.unlock_if_locked();
 81│             guard.deactivate();
 82│ #else
 83│             pthread_mutex_t* the_mutex = m.mutex()->native_handle();
 84│             res = posix::pthread_cond_wait(&cond,the_mutex);
 85│ #endif
224│       {
225│         m_generation++;
226│         m_count = static_cast<unsigned int>(fct_());
227│         BOOST_ASSERT(m_count != 0);
228│         lock.unlock();
229│         m_cond.notify_all();
230│         return true;
231│       }
232│
233│       while (gen == m_generation)
234├───────> m_cond.wait(lock);
235│       return false;
236│     }
237│
238│     void count_down_and_wait()
239│     {
240│       wait();
241│     }
323│         while (!m_enginePtr->m_stopThreads)
324│         {
325│                 // wait for start
326│                 //DBG().cout() << "Thread " << m_threadID << " (" << boost::this_thread::get_id() << ") waiting..." << endl;
327├───────────────> m_enginePtr->m_startBarrier->wait();
328│                 //cout << "Thread " << boost::this_thread::get_id() << " waiting... started." << endl;
329│
330│                 if (m_enginePtr->m_stopThreads)
331│                 {
332│                         //DBG().cout() << "Thread " << m_threadID << " (" << boost::this_thread::get_id() << ") stop!." << endl;
333│                         return;
334│                 }
335│
336│                 DEBUG_TIME( Timer timer1 );
118│             void run()
119│             {
120├───────────────> f();
121│             }