-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
LOG_EVERY_N stops printing when using threads #749
Comments
What does some time mean? Minutes, hours, days? At least logging for a couple of minutes does not show the effect you describe. Also, have you tried the CMake build? Since the Bazel build is untested in contrast to the CMake one, there may be some discrepancy. |
seconds in my case. We have a system based on bazel, so I can't use CMake easily. If the bazel build is untested I will just revert to the release and close this |
/cc @drigz |
I can repro this sometimes after 30s or so but not reliably, so I haven't been able to bisect. I built with ThreadSantizer but it didn't report any problem, and still crashed after a while. I've run a few times under gdb with and without |
Could you change Line 1094 in 503e3de
|
I haven't tried with a signed int but I guess you're on the right track. I caught the bad state in gdb:
A signed int would avoid that problem. OTOH it could plausibly cause undefined behavior through overflows if N is close to MAXINT, but maybe that's just a theoretical concern. |
Thanks. Yes, undefined behavior caused by signed integer overflow is why I changed from @lucabergamini Could you please check the change? |
@drigz Given your analysis, it seems that a typical race condition in the conditional statement occurs because only the increment but not the conditional block as a whole is atomic. This would imply that the problem was always there but was negated by the use of the signed integer. Therefore, changing the following line Line 1098 in 503e3de
to if (LOG_OCCURRENCES_MOD_N++ == n) LOG_OCCURRENCES_MOD_N -= n; and keeping |
I can give it a try later @sergiud, I'm using |
I'm wondering if we can somehow salvage the previous behavior, which was working for a long time. Maybe keeping |
Good points. Switching back to a signed integer is certainly the easiest solution. I'd rather prefer keeping |
Hi,
master is currently not working properly when using
LOG_EVERY_N
andthreads
minimal example to reproduce:
This will only print for some time before stopping.
The current release does not experience this issue, so it's probably due to a regression.
context:
glog version:
503e3dec8d1fe071376befc62119a837c26612a3
compiler:
g++ (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0
bazel:
4.2.1
The text was updated successfully, but these errors were encountered: