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

[FEATURE] mechanism to ensure the consistent locking order #15446

Open
1 task done
yamt opened this issue Jan 7, 2025 · 4 comments
Open
1 task done

[FEATURE] mechanism to ensure the consistent locking order #15446

yamt opened this issue Jan 7, 2025 · 4 comments
Labels
Type: Enhancement New feature or request

Comments

@yamt
Copy link
Contributor

yamt commented Jan 7, 2025

Is your feature request related to a problem? Please describe.

it would be nice to have some debug feature which can detect issues like #15314

Describe the solution you'd like

precedents:
https://man.freebsd.org/cgi/man.cgi?witness(4)
https://docs.kernel.org/locking/lockdep-design.html

Describe alternatives you've considered

although adhoc local assertions like yamt@ac3dda4
can work, it would be nicer to have a generic mechanism in the upstream.

Verification

  • I have verified before submitting the report.
@yamt yamt added the Type: Enhancement New feature or request label Jan 7, 2025
@xiaoxiang781216
Copy link
Contributor

@yamt
Copy link
Contributor Author

yamt commented Jan 7, 2025

@yamt can you try https://github.com/apache/nuttx/blob/master/sched/misc/deadlock.c?

glancing at the code, it requires you to actually make a deadlock happen, and then somehow trigger an assertion failure.
is it right?

reproducing a deadlock is not always easy.
well, if you know how to reproduce a deadlock, i guess you likely already know the problem well. just fix it. :-)

what i want to see is something more aggressive.
eg. detect locking attempts with a wrong order. (in most cases it might not actually cause a deadlock. but it can cause a deadlock.)

@xiaoxiang781216
Copy link
Contributor

@yamt can you try https://github.com/apache/nuttx/blob/master/sched/misc/deadlock.c?

glancing at the code, it requires you to actually make a deadlock happen, and then somehow trigger an assertion failure. is it right?

Yes, the code assume that the deadlock will trigger panic finally. but it's easy to expose a nsh command to trigger the check periodly.

reproducing a deadlock is not always easy. well, if you know how to reproduce a deadlock, i guess you likely already know the problem well. just fix it. :-)

in a complex system, it's hard to know which mutexs and threads participant the deadlock chain, this tool help people identify the problem mutex and thread after the deadlock happen.

what i want to see is something more aggressive. eg. detect locking attempts with a wrong order. (in most cases it might not actually cause a deadlock. but it can cause a deadlock.)

this feature requires to record the locking order.

@yamt
Copy link
Contributor Author

yamt commented Jan 7, 2025

what i want to see is something more aggressive. eg. detect locking attempts with a wrong order. (in most cases it might not actually cause a deadlock. but it can cause a deadlock.)

this feature requires to record the locking order.

yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants