This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/6380: Internal compiler error involving fstream and xsub (perl c++ wrapper code)



>Number:         6380
>Category:       c++
>Synopsis:       Internal compiler error involving fstream and xsub (perl c++ wrapper code)
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 19 15:06:02 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Ron Steinke
>Release:        3.0.4 (Debian testing/unstable)
>Organization:
>Environment:
System: Linux ouroboros 2.4.17 #10 Fri Mar 8 01:21:59 PST 2002 i686 unknown
Architecture: i686, Debian woody, using perl 5.6.1
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux
>Description:
	Internal compiler error, happens in both g++-2.95.4 and g++-3.0.4.
	I was attempting to produce a test case for some lockups that
	were happening when I wrapped a c++ library which used iostreams
	in an xsub so it could be called from perl. The test case
	produced an internal error.
>How-To-Repeat:
	I am including both the file Conflict.xs with the original code,
	and the generated Conflict.c file (really a c++ file) with the
	c++ code. The compilation command which originally produced the
	error was:

	g++ -c  -DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2   -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -fPIC -I/usr/lib/perl/5.6.1/CORE  Conflict.c

	I tried again with all the flags except for -I/usr/lib/perl/5.6.1/CORE
	removed, and the behavior was the same.

	--- begin Conflict.xs ---
#include <fstream>
#include <sstream>
#include <iostream>

extern "C" {
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
}

class Log {
 public:
  Log()
  {
    std::ostringstream ost;
    ost << "tmp/file" << filenum++;

    _log.open(ost.str().c_str(), std::ios::out | std::ios::app);
    _log << "testing\n";
  }

  ~Log() {_log.close();}

 private:
  std::fstream _log;

  static int filenum;
}

Log::filenum = 0;

MODULE = Conflict		PACKAGE = Conflict		

Log*
Log::new()

void
Log::DESTROY()
	--- end Conflict.xs, begin Conflict.c ---
/*
 * This file was generated automatically by xsubpp version 1.9508 from the 
 * contents of Conflict.xs. Do not edit this file, edit Conflict.xs instead.
 *
 *	ANY CHANGES MADE HERE WILL BE LOST! 
 *
 */

#line 1 "Conflict.xs"
#include <fstream>
#include <sstream>
#include <iostream>

extern "C" {
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
}

class Log {
 public:
  Log()
  {
    std::ostringstream ost;
    ost << "tmp/file" << filenum++;

    _log.open(ost.str().c_str(), std::ios::out | std::ios::app);
    _log << "testing\n";
  }

  ~Log() {_log.close();}

 private:
  std::fstream _log;

  static int filenum;
}

Log::filenum = 0;

#line 42 "Conflict.c"
XS(XS_Conflict_new)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Conflict::new(CLASS)");
    {
	char *	CLASS = (char *)SvPV(ST(0),PL_na);
	Log *	RETVAL;

	RETVAL = new Log();
	ST(0) = sv_newmortal();
	sv_setref_pv( ST(0), CLASS, (void*)RETVAL );

    }
    XSRETURN(1);
}

XS(XS_Conflict_DESTROY)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: Conflict::DESTROY(THIS)");
    {
	Log *	THIS;

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		THIS = (Log *)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "Conflict::DESTROY() -- THIS is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	delete THIS;
    }
    XSRETURN_EMPTY;
}

#ifdef __cplusplus
extern "C"
#endif
XS(boot_Conflict)
{
    dXSARGS;
    char* file = __FILE__;

    XS_VERSION_BOOTCHECK ;

        newXS("Conflict::new", XS_Conflict_new, file);
        newXS("Conflict::DESTROY", XS_Conflict_DESTROY, file);
    XSRETURN_YES;
}
	--- end Conflict.c ---
>Fix:
	None known
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]