Skip to content
Prev 12522 / 63461 Next

Segfault: .Call and classes with logical slots

I was about to comment with some of the same points Luke makes here. 
It's hard to see how gctorture could be less aggressive and still
guarantee to find problems.  Yes, some of the problems look unlikely,
but that's partly what makes them so insidious.

Two additional small points, one of detail, one about style.

1. A slight expansion on SET_SLOT.  There are two situations:  ordinary
slots and the ".Data" slot, a way to set the "data part" of an object.

The allocation for ordinary slots is trivial and maybe there is a way to
avoid it.  If the name argument is a symbol (as it usually is), SET_SLOT
allocates a corresponding character vector, because that's what
set_attrib wants.  Seems like each symbol could have a corresponding
object of this form (maybe there is one already?) to avoid allocation in
this case.

The .Data case involves much more code.  In this special case, should
SET_SLOT PROTECT the value argument?  or for that matter, would it be a
serious overhead for SET_SLOT to PROTECT the value argument always?

2.  On the other hand, this style of example might be characterized as
"hand compiling" S language code.  Many of us have had the experience
that such hand compiling is very error prone.  I know it's sometimes
strongly motivated, but it's likely to be an unpleasant experience.

If it's at all possible, the long-standing advice applies:  Try to
pre-allocate the data needed and keep the C code to dealing with
existing objects (e.g., DATAPTR() pointers); in particular, so the heavy
C code uses only pointers to data, not R objects.

And hopefully real compiling will eventually relieve us of some of the
need.

John
Luke Tierney wrote: