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

Data races and philosopher dies when we make 200 threads #2

Open
vasilisalmpanis opened this issue Sep 6, 2023 · 2 comments
Open

Comments

@vasilisalmpanis
Copy link

vasilisalmpanis commented Sep 6, 2023

Compiling with -fsanitize=thread gives the following error on the school mac

WARNING: ThreadSanitizer: data race (pid=2438)
  Write of size 4 at 0x7ffee1d15760 by thread T54 (mutexes: write M244, write M16):
    \#0 messages <null>:2 (philo:x86_64+0x1000038bc)
    #1 supervisor <null>:2 philo:x86_64+0x1000030fa)

  Previous read of size 4 at 0x7ffee1d15760 by thread T10:
    \#0 supervisor <null>:2 (philo:x86_64+0x10000306a)

  Location is stack of main thread.

  Mutex M244 (0x7ba800000c58) created at:
    \#0 pthread_mutex_init <null>:3 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2e913)
    \#1 init_philos <null>:2 (philo:x86_64+0x1000022a1)
    \#2 init <null>:2 (philo:x86_64+0x10000274e)
    \#3 main <null>:2 (philo:x86_64+0x1000019ab)

  Mutex M16 (0x7ffee1d157d8) created at:
    \#0 pthread_mutex_init <null>:3 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2e913)
    \#1 init_data <null>:2 (philo:x86_64+0x10000265d)
    \#2 init <null>:2 (philo:x86_64+0x1000026f4)
    \#3 main <null>:2 (philo:x86_64+0x1000019ab)

  Thread T54 (tid=91819, running) created by thread T53 at:
    \#0 pthread_create <null>:3 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2d8fd)
    \#1 routine <null>:2 (philo:x86_64+0x100003334)

  Thread T10 (tid=91775, running) created by thread T9 at:
    \#0 pthread_create <null>:3 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2d8fd)
    \#1 routine <null>:2 (philo:x86_64+0x100003334)

SUMMARY: ThreadSanitizer: data race (philo:x86_64+0x1000038bc) in messages+0x16c
==================
ThreadSanitizer: reported 1 warnings
[1]    2438 abort      ./philo 200 800 200 200

also when running the below prompt : ./philo 200 800 200 200
a philosopher dies but he is not supposed to according to the subject.

@TommyJD93
Copy link
Owner

TommyJD93 commented Oct 23, 2023

Sorry for the late response. Right now I'm kinda busy with the 42 common core so I don't have much time to review this "old" code. But I will asap. Apologies if I couldn't help you out. And thanks for the issue :)

@vasilisalmpanis
Copy link
Author

Hey. No worries i just pointed out that the project is not working as it should according to the subject. Have a nice day

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