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

Dubious code in testsuite #6516

Closed
vicuna opened this issue Aug 15, 2014 · 1 comment
Closed

Dubious code in testsuite #6516

vicuna opened this issue Aug 15, 2014 · 1 comment
Assignees
Labels

Comments

@vicuna
Copy link

vicuna commented Aug 15, 2014

Original bug ID: 6516
Reporter: @stedolan
Assigned to: @lefessan
Status: closed (set by @xavierleroy on 2016-12-07T10:34:28Z)
Resolution: fixed
Priority: low
Severity: minor
Fixed in version: 4.03.0+dev / +beta1
Category: misc
Monitored by: @gasche

Bug description

tests / lib-dynlink-bytecode / stub1.c contains the following code:

value stub1() {
  CAMLlocal1(x);
  printf("This is stub1!\n"); fflush(stdout);
  x = caml_copy_string("ABCDEF");
  return x;
}

This uses CAMLlocal1 incorrectly, without CAMLparam0 or CAMLreturn. I'm working on an experimental branch of the runtime with multicore support, where this test actually crashes. It seems to work on trunk, but I think this is just by coincidence.

Am I correct in thinking this code is broken? It seems to keep the address of an out-of-scope local.

Steps to reproduce

Bug doesn't trigger on trunk, but you can observe that caml_local_roots contains a dangling pointer to the out-of-scope local x after stub1() returns.

@vicuna
Copy link
Author

vicuna commented Aug 17, 2014

Comment author: @lefessan

I committed a new version:
value stub1() {
CAMLparam0();
CAMLlocal1(x);
printf("This is stub1!\n"); fflush(stdout);
x = caml_copy_string("ABCDEF");
CAMLreturn(x);
}
I hope it's correct now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants