Skip to content

Commit

Permalink
kernel: deal with T_DATOBJ instances without type (#5654)
Browse files Browse the repository at this point in the history
Some kernel extension (EDIM, float) create T_DATOBJ instances for
use as internal buffers without ever setting a typeobj. This
mostly works as long as the buffer stays 100% local. But at least
in EDIM, one of the buffers gets retyped into a plist, which used
to be fine, except now we perform some sanity checks in
`PrecheckRetypeBag`.

Arguably the "correct" way to deal with this is to change affected
packages to use `NewKernelBuffer`. But it seems prudent to also
deal with this case directly in GAP itself. Especially since we
also still created a ton of T_DATOBJ directly in GAP and I think
we don't set a type for all of them either.
  • Loading branch information
fingolfin authored Feb 27, 2024
1 parent 3ad9341 commit af9e3f6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ typedef struct {
static Int lastFreePackageTNUM = FIRST_PACKAGE_TNUM;


static Obj TYPE_KERNEL_OBJECT;


/****************************************************************************
**
*V NameOfType[<type>] . . . . . . . . . . . . . . . . . . . . names of types
Expand Down Expand Up @@ -1498,7 +1501,8 @@ BOOL IsbPosObj(Obj obj, Int idx)
*/
static Obj TypeDatObj(Obj obj)
{
return TYPE_DATOBJ( obj );
Obj type = TYPE_DATOBJ( obj );
return type ? type : TYPE_KERNEL_OBJECT;
}

void SetTypeDatObj( Obj obj, Obj type)
Expand Down Expand Up @@ -1549,8 +1553,6 @@ static Obj FuncSET_TYPE_DATOBJ(Obj self, Obj obj, Obj type)
**
*F NewKernelBuffer( <size> ) . . . . . . . . . . return a new kernel buffer
*/
static Obj TYPE_KERNEL_OBJECT;

Obj NewKernelBuffer(UInt size)
{
Obj obj = NewBag(T_DATOBJ, size);
Expand Down

0 comments on commit af9e3f6

Please sign in to comment.