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

Should not use tst_brk after calling cleanup_ipc() #537

Closed
fallen opened this issue Jun 4, 2019 · 10 comments
Closed

Should not use tst_brk after calling cleanup_ipc() #537

fallen opened this issue Jun 4, 2019 · 10 comments

Comments

@fallen
Copy link
Contributor

fallen commented Jun 4, 2019

in the process of exiting, after having printed the Summary, do_cleanup() is called.
Which then calls cleanup_ipc(), which unmaps results. See
https://github.com/linux-test-project/ltp/blob/master/lib/tst_test.c#L924
https://github.com/linux-test-project/ltp/blob/master/lib/tst_test.c#L138

But then, afterward, tst_wallclock_restore() is called which itself can call tst_brk upon some syscall failure:

tst_brk(TBROK | TERRNO, "tst_clock_settime() realtime failed");

This is wrong since tst_brk will call do_exit again and will try to de-reference results ( https://github.com/linux-test-project/ltp/blob/master/lib/tst_test.c#L593 ) and this leads to a segfault.

I experienced this segfault while running tests and for some reason the tst_clock_settime call failed.

output example:

Summary:
passed 6
failed 0
skipped 0
warnings 0
tst_wallclock.c:59: BROK: tst_clock_settime() realtime failed: EINVAL

Summary:
Segmentation fault

Another solution would be to make results NULL upon unmapping it.

@metan-ucw
Copy link
Member

I guess that we can move the tst_wallclock_restore() before the call to the cleanup_ipc(), that should fix the problem as well.

@fallen
Copy link
Contributor Author

fallen commented Jun 5, 2019

Yes I agree.

@fallen
Copy link
Contributor Author

fallen commented Jun 5, 2019

But maybe adding some results = NULL upon unmapping would also be a safe thing to do anyway.

@metan-ucw
Copy link
Member

Sure, zeroing results after unmapping sounds good as well.

Will you send a patch or should I do it?

@fallen
Copy link
Contributor Author

fallen commented Jun 5, 2019

I'll send a patch later. Thanks for your answers.
You prefer the patches to be sent to the mailing list, right?

@metan-ucw
Copy link
Member

Yes, mailing list is preferred.

@fallen
Copy link
Contributor Author

fallen commented Jun 6, 2019

Patch sent, email waiting for moderation.

@fallen
Copy link
Contributor Author

fallen commented Jun 11, 2019

Patch arrived on the mailinglist: https://lists.linux.it/pipermail/ltp/2019-June/012292.html

@fallen
Copy link
Contributor Author

fallen commented Jun 14, 2019

re-sent with corrections and missing Signed-off-by line.

metan-ucw pushed a commit that referenced this issue Jun 14, 2019
This fixes issue reported there: #537

Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
@fallen
Copy link
Contributor Author

fallen commented Jun 14, 2019

Thanks!

@fallen fallen closed this as completed Jun 14, 2019
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

2 participants