Mail Archives: cygwin/2000/09/07/11:54:26
------=_NextPart_000_0014_01C018EB.B4288730
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hi,
I have a tiny bit more information on this problem.
- I reproduced it on my own NT box, with cygwin 1.1.4 (it does NOT happen
with B20.1)
- I can reproduce it with a file (attached) that does not need linking with
any other file (except standard libs).
* If I do a normal "g++ dynamic_cast8.cxx", the program runs fine
* If I link it with another file I have "g++ dynamic_cast8.cxx bla.o" it
crashes.
The other file is also compiled with the same gcc (it's not specific to
which file exactly).
Weird.
Suggestions ?
Kris
> -----Original Message-----
> From: Kris Thielemans [mailto:kris DOT thielemans AT ic DOT ac DOT uk]
> Sent: 31 August 2000 15:58
> To: Gnuwin
> Subject: problem with dynamic_cast
>
>
> Hi,
>
> I have a problem with some of our own C++ software when compiled
> with gcc on cygwin cygwin v.1.1.4 on Windows NT4.00.1381 (Finnish
> language). Note that this program runs fine on my own NT 4.0 sp5
> or sp6 machines running cygwin B20.1 with gcc 2.95.2, and on
> Solaris with gcc 2.95.2, and on AIX with gcc 2.8.1).
>
> The problem occurs when executing a dynamic_cast on a pointer.
> Any suggestions ?
>
>
> details:
> ---------
> The program generates the following error:
> 0 [main] test_VoxelsOnCartesianGrid 1039 handle_exceptions: Exception:
> STATUS_ACCESS_VIOLATION
> 974 [main] test_VoxelsOnCartesianGrid 1039 stackdump: Dumping
> stack trace
> to test_VoxelsOnCartesianGrid.exe.stackdump
> make: *** [run_tests] Segmentation fault (core dumped)
>
> The file where it crashes is compiled as follows:
> g++ -g -D_DEBUG -g -Wall -I/home/PPhead/include -o
> debug/VoxelsOnCartesianGrid.o -c VoxelsOnCartesianGrid.cxx
>
>
> When running the program in gdb, the stack trace after the crash is:
> Program received signal SIGSEGV, Segmentation fault.
> 0x611e4 in ?? ()
> (gdb) info stack
> #0 0x611e4 in ?? ()
> #1 0x41e484 in __si_type_info::dcast (this=0x460520, to=@0x4604c0,
> require_public=1, addr=0xa057e90, sub=0x460280, subptr=0xa057e90)
> at /cygnus/netrel/src/gcc-2.95.2-2/gcc/cp/tinfo.cc:76
> #2 0x41e6d3 in __dynamic_cast (
> from=0x441658 <Tomo::ProjDataInfoCylindricalArcCorr type_info
> function>,
> to=0x4415a4 <Tomo::ProjDataInfoCylindrical type_info function>,
> require_public=1, address=0xa057e90,
> sub=0x441544 <Tomo::ProjDataInfo type_info function>,
> subptr=0xa057e90)
> at /cygnus/netrel/src/gcc-2.95.2-2/gcc/cp/tinfo2.cc:38
> #3 0x40ddda in Tomo::find_sampling_and_z_size (z_sampling=@0x266f898,
> s_sampling=@0x266f894, z_size=@0x266f89c,
> proj_data_info_ptr=0xa057e90)
> at VoxelsOnCartesianGrid.cxx:45
> #4 0x4325e8 in
> Tomo::VoxelsOnCartesianGrid<float>::VoxelsOnCartesianGrid (
> this=0x266fc00, proj_data_info=@0xa057e90, zoom=2.29999995,
> origin=@0x266fd10, make_xy_size_odd=false) at
> VoxelsOnCartesianGrid.cxx:138
> #5 0x4022a6 in Tomo::VoxelsOnCartesianGridTests::run_tests
> (this=0x266fd60)
> at test_VoxelsOnCartesianGrid.cxx:103
> #6 0x403174 in main () at test_VoxelsOnCartesianGrid.cxx:180
> #7 0x61002272 in _size_of_stack_reserve__ ()
> #8 0x61002805 in _size_of_stack_reserve__ ()
> #9 0x61002843 in _size_of_stack_reserve__ ()
> #10 0x41cdd5 in cygwin_crt0 ()
>
>
> This seems to say there is something wrong in the dynamic_cast
> statement on that line, which looks as follows:
> if (const ProjDataInfoCylindrical*
> proj_data_info_cyl_ptr =
> dynamic_cast<const ProjDataInfoCylindrical*>(proj_data_info_ptr))
> { ...}
>
> By the way, if you check the stack trace, you'll see that the
> dynamic cast is from a ProjDataInfoCylindricalArcCorr * to a
> ProjDataInfoCylindrical *, where ProjDataInfoCylindricalArcCorr
> is derived from ProjDataInfoCylindrical. (Not that it should
> crash in any case).
>
>
> Thanks !
>
>
>
> Kris Thielemans
> (kris DOT thielemans AT ic DOT ac DOT uk)
> MRC Cyclotron Unit,
> Hammersmith Hospital,
> DuCane Rd,London W12 0NN, United Kingdom
>
> Phone on : +44 (020)8383 3731
> FAX on : +44 (020)8383 2029
>
> NEW web site address:
> http://www.cu.mrc.ac.uk/~kris
------=_NextPart_000_0014_01C018EB.B4288730
Content-Type: application/octet-stream;
name="dynamic_cast8.cxx"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="dynamic_cast8.cxx"
#define END_NAMESPACE_TOMO
#define START_NAMESPACE_TOMO
#define USING_NAMESPACE_TOMO
=20
template <class NUMBER>=20
inline NUMBER square(const NUMBER &x) { return x*x; }
#include <iostream>
#ifndef __ProjDataInfo_H__
#define __ProjDataInfo_H__
START_NAMESPACE_TOMO
template <typename elemT> class Sinogram;
template <typename elemT> class Viewgram;
template <typename elemT> class SegmentByView;
template <typename elemT> class SegmentBySinogram;
template <typename elemT> class RelatedViewgrams;
class DataSymmetriesForViewSegmentNumbers;
class ViewSegmentNumbers;
class PMessage;
class ProjDataInfo
{
=20
public:
=20
=20
/************ constructors ***********/
// TODO should probably be protected
//! Construct an empty object
inline ProjDataInfo();
//! Standard trick for a 'virtual copy-constructor'=20
virtual ProjDataInfo* clone() const =3D 0;
//! Destructor
virtual ~ProjDataInfo() {}
/**************** member functions *********/
// TODOdoc coordinate system
//! Get tangent of the co-polar angle, tan(theta)
virtual float get_tantheta(int segment_num,int view_num,int =
axial_position_num, int transaxial_position_num) const =3D0;
//! Get azimuthal angle phi
virtual float get_phi(int segment_num,int view_num,int =
axial_position_num, int transaxial_position_num) const =3D0;
=20
//! Get value of the (roughly) axial coordinate in the projection =
plane (in mm)
virtual float get_t(int segment_num,int view_num,int =
axial_position_num, int transaxial_position_num) const =3D0;
//! Get value of the tangential coordinate in the projection plane (in =
mm)
virtual float get_s(int segment_num,int view_num,int =
axial_position_num, int transaxial_position_num) const =3D0;
=20
=20
private:
int min_view_num;
int max_view_num;
int min_tangential_pos_num;
int max_tangential_pos_num;
=20
};
END_NAMESPACE_TOMO
//#include "ProjDataInfo.inl"
//
// @(#)ProjDataInfo.inl 1.1: 00/06/14
//
START_NAMESPACE_TOMO
ProjDataInfo::ProjDataInfo()
{}
=20
END_NAMESPACE_TOMO
#endif // __ProjDataInfo_H__
#ifndef __ProjDataInfoCylindrical_H__
#define __ProjDataInfoCylindrical_H__
//#include"ProjDataInfo.h"
START_NAMESPACE_TOMO
/*!
\ingroup buildblock=20
\brief projection data info for data corresponding to a=20
'cylindrical' sampling.
These data are organised by ring differences (allowing for
merging of some ring differences into 1 segment). It is general
enough to have both the CTI 'spanned' format, and the GE Advance
format.
*/
// TODOdoc more
class ProjDataInfoCylindrical: public ProjDataInfo
{
public:
//! Constructors
inline ProjDataInfoCylindrical();
=20
inline float get_phi(int segment_num,int view_num,int =
axial_position_num, int transaxial_position_num) const;=20
=20
inline float get_t(int segment_num,int view_num,int =
axial_position_num, int transaxial_position_num) const;
protected:
float azimuthal_angle_sampling;
float ring_radius;
private:
float ring_spacing;
};
END_NAMESPACE_TOMO
//#include "ProjDataInfoCylindrical.inl"
//
// @(#)ProjDataInfoCylindrical.inl 1.1: 00/06/14
//
START_NAMESPACE_TOMO
ProjDataInfoCylindrical::ProjDataInfoCylindrical()
{}
float
ProjDataInfoCylindrical::get_phi(int segment_num,int view_num,int =
axial_position_num, int transaxial_position_num)const
{ return view_num*azimuthal_angle_sampling;}
float
ProjDataInfoCylindrical::get_t(int segment_num,int view_num,int =
axial_position_num, int transaxial_position_num) const
{return axial_position_num;}
END_NAMESPACE_TOMO
=20
#endif
#ifndef __ProjDataInfoCylindricalArcCorr_H__
#define __ProjDataInfoCylindricalArcCorr_H__
//#include "ProjDataInfoCylindrical.h"
START_NAMESPACE_TOMO
/*!
\ingroup buildblock=20
\brief projection data info for arc-corrected data
*/
class ProjDataInfoCylindricalArcCorr : public ProjDataInfoCylindrical
{
public:
//! Constructors
inline ProjDataInfoCylindricalArcCorr();
=20
inline virtual float get_tantheta(int segment_num,int view_num,int =
axial_position_num, int transaxial_position_num) const;=20
inline virtual float get_s(int segment_num,int view_num,int =
axial_position_num, int transaxial_position_num) const;
inline ProjDataInfo* clone() const;
private:
=20
float bin_size;
=20
};
END_NAMESPACE_TOMO
//#include "ProjDataInfoCylindricalArcCorr.inl"
//
// @(#)ProjDataInfoCylindricalArcCorr.inl 1.1: 00/06/14
//
START_NAMESPACE_TOMO
ProjDataInfoCylindricalArcCorr:: ProjDataInfoCylindricalArcCorr()
{}
float
ProjDataInfoCylindricalArcCorr::get_s(int segment_num,int view_num,int =
axial_position_num, int transaxial_position_num) const
{return transaxial_position_num*bin_size;}
float
ProjDataInfoCylindricalArcCorr::get_tantheta(int segment_num,int =
view_num,int axial_position_num, int transaxial_position_num) const
{
return
=
(2*sqrt(square(ring_radius)-square(get_s(segment_num,view_num,axial_posit=
ion_num, transaxial_position_num))));
=20
}
ProjDataInfo*
ProjDataInfoCylindricalArcCorr::clone() const
{
return static_cast<ProjDataInfo*>(new =
ProjDataInfoCylindricalArcCorr(*this));
}
END_NAMESPACE_TOMO
#endif
//#include "ProjDataInfoCylindricalArcCorr.h"
USING_NAMESPACE_TOMO
// a local help function to find appropriate sizes etc.
static void find_sampling_and_z_size(
const ProjDataInfo* proj_data_info_ptr)
{
// first z- things
const ProjDataInfoCylindrical*
proj_data_info_cyl_ptr =3D=20
dynamic_cast<const ProjDataInfoCylindrical*>(proj_data_info_ptr);
if (proj_data_info_cyl_ptr)
{
std::cerr << "OK !\n";
}
else
{
std::cerr << " Not OK!\n";
}
}
int main()
{
ProjDataInfo * proj_data_info_ptr =3D=20
new ProjDataInfoCylindricalArcCorr;
find_sampling_and_z_size(proj_data_info_ptr);
return 0;
}
------=_NextPart_000_0014_01C018EB.B4288730
Content-Type: text/plain; charset=us-ascii
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
------=_NextPart_000_0014_01C018EB.B4288730--
- Raw text -