null-deref-crash-during-pthread_join.cpp 478 B

123456789101112131415161718192021222324252627
  1. /*
  2. * Copyright (c) 2018-2020, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <pthread.h>
  7. #include <stdio.h>
  8. #include <sys/select.h>
  9. #include <unistd.h>
  10. int main(int, char**)
  11. {
  12. pthread_t tid;
  13. pthread_create(
  14. &tid, nullptr, [](void*) -> void* {
  15. sleep(1);
  16. __builtin_trap();
  17. return nullptr;
  18. },
  19. nullptr);
  20. pthread_join(tid, nullptr);
  21. printf("ok\n");
  22. return 0;
  23. }