octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Segfault at quit with global and DLD type


From: Jason Riedy
Subject: Segfault at quit with global and DLD type
Date: Wed, 25 Feb 2009 17:08:43 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.90 (gnu/linux)

I'm just a font of fun. The following script snippet triggers a segfault
on quit when used with the appended (nigh trivial) tst.cc and PKG_ADD:

global f;
f = handle_open ();
disp (f)

Commenting out the first global f lets this run without segfaulting, so
this likely is a race when destroying things. Tested on fresh tip builds
(from tip about 4 hours ago) on Debian and Fedora.

Jason

#include<octave/oct.h>
#include<octave/ov.h>

class octave_handle : public octave_base_value
{
public:
  int h;

  int get_handle () const { return h; }

  octave_handle () : h (0) {}
  octave_handle (int h) : h (h) {}
  octave_handle (const octave_handle& other) : h (other.h) {}
  ~octave_handle () { }
  bool is_defined () const { return true; }

  virtual void print (std::ostream& os, bool pr_as_read_syntax) const
  { print_raw (os, pr_as_read_syntax); newline (os); }
  virtual void print_raw (std::ostream& os, bool) const
  {
    if (!h) os << "NULL silly handle!";
    else os << "silly handle is " << h;
  }

protected:
  DECLARE_OCTAVE_ALLOCATOR
  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
};

DEFINE_OCTAVE_ALLOCATOR (octave_handle);
DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_handle, "silly handle", "silly 
handle");

DEFUN_DLD(handle_open, args,,"")
{
  octave_handle* octout = new octave_handle (5);
  return octave_value (octout);
}

DEFUN_DLD(handle_close, args,,"") { return octave_value(); }
autoload ("handle_open", fullfile (fileparts (canonicalize_file_name (mfilename 
("fullpath"))), "tst.oct"));
autoload ("handle_close", fullfile (fileparts (canonicalize_file_name 
(mfilename ("fullpath"))), "tst.oct"));

reply via email to

[Prev in Thread] Current Thread [Next in Thread]