Skip to content

Segmentation fault in :newcoords with wrong argument #479

Open
@Affonso-Gui

Description

@Affonso-Gui

How to reproduce:

(send (make-coords) :newcoords 10)

What is happening:
The newcoords method is using a macro slot accessor without checking the class of the argument. https://github.com/euslisp/EusLisp/blob/master/lisp/l/coordinates.l#L58-L62
When on interpreter the object class is verified, but when compiled this is replaced by a simple address, which could be any value or a null pointer, thus causing the segmentation fault.

Possible solutions
We could add a coordinates-p check, use the dot accessor (which is translated differently and still works normally after compiled), or update the compiler to verify the classes at macro accessors.

;; test.l
(defun foo (c)
  (coordinates-rot c))

(defun bar (c)
  (c . rot))
// test.c

/*foo*/
static pointer F120foo(ctx,n,argv,env)
register context *ctx;
register int n; register pointer argv[]; pointer env;
{ register pointer *local=ctx->vsp, w, *fqv=qv;
  numunion nu;
	if (n!=1) maerror();
	w = argv[0]->c.obj.iv[1];  /* HERE! */
	local[0]= w;
BLK122:
	ctx->vsp=local; return(local[0]);}

/*bar*/
static pointer F121bar(ctx,n,argv,env)
register context *ctx;
register int n; register pointer argv[]; pointer env;
{ register pointer *local=ctx->vsp, w, *fqv=qv;
  numunion nu;
	if (n!=1) maerror();
	w = *(ovafptr(argv[0],fqv[0])); /* HERE! */
	local[0]= w;
BLK123:
	ctx->vsp=local; return(local[0]);}

@a-ichikura
jsk-ros-pkg/euslime#5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions