Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault in :newcoords with wrong argument #479

Open
Affonso-Gui opened this issue Jan 12, 2022 · 0 comments
Open

Segmentation fault in :newcoords with wrong argument #479

Affonso-Gui opened this issue Jan 12, 2022 · 0 comments

Comments

@Affonso-Gui
Copy link
Member

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

@Affonso-Gui Affonso-Gui mentioned this issue Sep 21, 2022
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant