public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16219] New: Exception not caught
@ 2004-06-26 15:37 jss at ast dot cam dot ac dot uk
  2004-06-26 16:24 ` [Bug c++/16219] " jss at ast dot cam dot ac dot uk
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: jss at ast dot cam dot ac dot uk @ 2004-06-26 15:37 UTC (permalink / raw)
  To: gcc-bugs

I know I'm not following the bug reporting guidelines. I'm afraid I can't
reproduce the bug when the program is cut down to the parts that fail. It also
goes away when I try to remove the library dependencies. I spent most of a day
removing parts of the program but it goes away. I'd like advice how I can report
this bug.

gcc -v:
Reading specs from /home/jss/devel/lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: ../gcc-3.4.0/configure --prefix=/home/jss/devel
--enable-languages=c,c++
Thread model: posix
gcc version 3.4.0


The problem is that I throw an exception in a class in one compilation, and
catch exception in main().

int main()
{
  try{
...
}
  catch(pfits::Exception &e)
    {
      std::cerr << e() << '\n';
    }


The exception isn't caught by the catch, even though the exception class is
descended from pfits::Exception:

namespace pfits
{
  // all our exceptions derive from this one
  class Exception
  {
  public:
    Exception(const std::string& str) : _str(str) {}
    const std::string& operator() () const { return _str; }

  private:
    const std::string _str;
  };

  // thrown if fitsio reports an error
  class FITSIOError : public Exception
  {
  public:
    FITSIOError(const std::string& str)
      : Exception(str) {}
  };

}

The exception is thrown in:

namespace pfits
{
  // throw if error
  inline void check_error(_InternalFile file, const int status)
  {
    if( status != 0 )
      {
	throw FITSIOError( error_string(file, status) );
      }
  }
}

If I debug in gdb:

terminate called after throwing an instance of 'pfits::FITSIOError'
 
#0  0xffffe002 in ?? ()
#1  0x42028c55 in abort () from /lib/tls/libc.so.6
#2  0x400c7e01 in __gnu_cxx::__verbose_terminate_handler() ()
    at ../../../../gcc-3.4.0/libstdc++-v3/libsupc++/vterminate.cc:96
#3  0x400c59a5 in __cxxabiv1::__terminate(void (*)()) (
    handler=0x400c7d00 <__gnu_cxx::__verbose_terminate_handler()>)
    at ../../../../gcc-3.4.0/libstdc++-v3/libsupc++/eh_terminate.cc:43
#4  0x400c5882 in __gxx_personality_v0 (version=1, actions=6,
    exception_class=5138137972254386944, ue_header=0x0, context=0xbfffd8f0)
    at ../../../../gcc-3.4.0/libstdc++-v3/libsupc++/eh_personality.cc:434
#5  0x40129573 in _Unwind_RaiseException_Phase2 (exc=0x8178ea0,
    context=0xbfffd8f0) at unwind.inc:66
#6  0x401296e4 in _Unwind_RaiseException (exc=0x8178ea0) at unwind.inc:136
#7  0x400c5b55 in __cxa_throw (obj=0x8178ea0, tinfo=0x0, dest=0)
    at ../../../../gcc-3.4.0/libstdc++-v3/libsupc++/eh_throw.cc:75
#8  0x0804c36e in pfits::check_error(pfits::_InternalFile, int) (file=
      {_file = 0x8178ee0}, status=252) at privutil.hh:40
#9  0x0804c06f in pfits::File::close() (this=0xbfffdae0) at file.cc:56
#10 0x0804c01b in ~File (this=0xbfffdae0) at file.cc:45
#11 0x0804ce43 in main () at test.cc:31
#12 0x42015704 in __libc_start_main () from /lib/tls/libc.so.6


Any ideas how to debug this? Is it possible it is caused by the libraries linked
to the code? The exception doesn't pass through the library. I compiled the
program with -O0 -g -Wall (also tried -O2).

-- 
           Summary: Exception not caught
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jss at ast dot cam dot ac dot uk
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16219


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/16219] Exception not caught
  2004-06-26 15:37 [Bug c++/16219] New: Exception not caught jss at ast dot cam dot ac dot uk
@ 2004-06-26 16:24 ` jss at ast dot cam dot ac dot uk
  2004-06-26 19:44 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jss at ast dot cam dot ac dot uk @ 2004-06-26 16:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jss at ast dot cam dot ac dot uk  2004-06-26 16:20 -------
I also tried adding a catch(...) all statement:

  catch(...)
    {
      std::cerr << "Not caught\n";
    }

The exception is still not caught by this!

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16219


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/16219] Exception not caught
  2004-06-26 15:37 [Bug c++/16219] New: Exception not caught jss at ast dot cam dot ac dot uk
  2004-06-26 16:24 ` [Bug c++/16219] " jss at ast dot cam dot ac dot uk
@ 2004-06-26 19:44 ` pinskia at gcc dot gnu dot org
  2004-06-27 13:47 ` jss at ast dot cam dot ac dot uk
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-26 19:44 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-26 19:42 -------
Are you sure that one of the functions are not marked as non-throw?
Also are you sure that the FILE allocation/deallocation is inside the try?

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16219


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/16219] Exception not caught
  2004-06-26 15:37 [Bug c++/16219] New: Exception not caught jss at ast dot cam dot ac dot uk
  2004-06-26 16:24 ` [Bug c++/16219] " jss at ast dot cam dot ac dot uk
  2004-06-26 19:44 ` pinskia at gcc dot gnu dot org
@ 2004-06-27 13:47 ` jss at ast dot cam dot ac dot uk
  2004-08-31  5:37 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jss at ast dot cam dot ac dot uk @ 2004-06-27 13:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jss at ast dot cam dot ac dot uk  2004-06-27 12:49 -------
None of the functions in the code have exception specifications - so the code
should expect any exception can be thrown.

There isn't any code outside the try block. All the file handling is inside.

One thought is that the library used by the code (CFITSIO) might mess up the
call stack (though it is written in standard C). I tried running the code with
valgrind, but it couldn't detect any errors.

If you want to try the (small) code download
http://www-xray.ast.cam.ac.uk/~jss/data/gcc-except.tar.gz  (13KB)

To compile the code use the Makefile. Unfortunately you need to have the
following to libraries installed:

Blitz++:      http://www.oonumerics.org/blitz/
CFITSIO:      http://heasarc.gsfc.nasa.gov/docs/software/fitsio/fitsio.html

They're both fairly easy to build, however.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16219


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/16219] Exception not caught
  2004-06-26 15:37 [Bug c++/16219] New: Exception not caught jss at ast dot cam dot ac dot uk
                   ` (2 preceding siblings ...)
  2004-06-27 13:47 ` jss at ast dot cam dot ac dot uk
@ 2004-08-31  5:37 ` pinskia at gcc dot gnu dot org
  2004-11-30  0:46 ` pinskia at gcc dot gnu dot org
  2004-11-30  9:31 ` jss at ast dot cam dot ac dot uk
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-31  5:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-31 05:37 -------
What binutils version are you using?

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16219


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/16219] Exception not caught
  2004-06-26 15:37 [Bug c++/16219] New: Exception not caught jss at ast dot cam dot ac dot uk
                   ` (3 preceding siblings ...)
  2004-08-31  5:37 ` pinskia at gcc dot gnu dot org
@ 2004-11-30  0:46 ` pinskia at gcc dot gnu dot org
  2004-11-30  9:31 ` jss at ast dot cam dot ac dot uk
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-30  0:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-30 00:46 -------
No feedback in 3 months.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16219


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/16219] Exception not caught
  2004-06-26 15:37 [Bug c++/16219] New: Exception not caught jss at ast dot cam dot ac dot uk
                   ` (4 preceding siblings ...)
  2004-11-30  0:46 ` pinskia at gcc dot gnu dot org
@ 2004-11-30  9:31 ` jss at ast dot cam dot ac dot uk
  5 siblings, 0 replies; 7+ messages in thread
From: jss at ast dot cam dot ac dot uk @ 2004-11-30  9:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jss at ast dot cam dot ac dot uk  2004-11-30 09:31 -------
Apologies. I've upgraded my system and I've been working on other projects
recently. I'll try to check it still exists on a recent binutils..

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16219


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-11-30  9:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-26 15:37 [Bug c++/16219] New: Exception not caught jss at ast dot cam dot ac dot uk
2004-06-26 16:24 ` [Bug c++/16219] " jss at ast dot cam dot ac dot uk
2004-06-26 19:44 ` pinskia at gcc dot gnu dot org
2004-06-27 13:47 ` jss at ast dot cam dot ac dot uk
2004-08-31  5:37 ` pinskia at gcc dot gnu dot org
2004-11-30  0:46 ` pinskia at gcc dot gnu dot org
2004-11-30  9:31 ` jss at ast dot cam dot ac dot uk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).