nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

Fix the bug and add tls cleanup in that netlink

Open wangchen61698 opened this issue 1 year ago • 2 comments

Summary

1.Fix the bug that netlink receive wait does not hang up 2.add tls cleanup protection to protect waitsem in netlink_get_response

Impact

netlink

Testing

Manual verification

wangchen61698 avatar Aug 20 '24 07:08 wangchen61698

@wangchen61698 please fix the issue:

netlink/netlink_conn.c: In function 'netlink_get_response':
Error: netlink/netlink_conn.c:535:11: error: implicit declaration of function 'tls_cleanup_push' [-Werror=implicit-function-declaration]
  535 |           tls_cleanup_push(tls_get_info(), netlink_notifier_teardown, conn);
      |           ^~~~~~~~~~~~~~~~
Error: netlink/netlink_conn.c:537:11: error: implicit declaration of function 'tls_cleanup_pop' [-Werror=implicit-function-declaration]
  537 |           tls_cleanup_pop(tls_get_info(), 0);
      |           ^~~~~~~~~~~~~~~

acassis avatar Aug 20 '24 13:08 acassis

@xiaoxiang781216 The life cycle of the socket should be managed with file descriptor. If an abnormal exit causes an exception, then the VFS needs to be further enhanced. If all subsystems depends on TLS when exiting, then the entire kernel will be surrounded by TLS. The implementation of the protocol stack should further learn from the Linux kernel instead of applying these ugly patches!

anchao avatar Aug 21 '24 00:08 anchao

@xiaoxiang781216 The life cycle of the socket should be managed with file descriptor. If an abnormal exit causes an exception, then the VFS needs to be further enhanced. If all subsystems depends on TLS when exiting, then the entire kernel will be surrounded by TLS. The implementation of the protocol stack should further learn from the Linux kernel instead of applying these ugly patches!

@anchao but this is the resource allocated in the current stack frame, not the resource bind to the file descriptor. The different life cycle resource need clear up by different approach. tls_cleanup_push/tls_cleanup_pop is a standard method to clear up the stack resource: https://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread_cleanup_push.html Do you have better suggestion?

xiaoxiang781216 avatar Oct 31 '24 09:10 xiaoxiang781216