Skip to content

Commit

Permalink
Merge pull request #97 from mw66/fix
Browse files Browse the repository at this point in the history
fix crash: move stack var bufs and targets into class as static fields
  • Loading branch information
zoujiaqing authored Feb 8, 2023
2 parents 89e9331 + 00135b3 commit 82f6bb1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions source/hunt/util/DateTime.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module hunt.util.DateTime;
import core.atomic;
import core.stdc.time;
import core.thread : Thread;
import std.array;
import std.datetime;
import std.format : formattedWrite;
import std.string;
Expand Down Expand Up @@ -403,11 +404,10 @@ class DateTime {
private __gshared Thread dateThread;
private static shared bool _isClockRunning = false;

shared static this() {
import std.array;
private static Appender!(char[])[2] bufs;
private static const(char)[][2] targets;

Appender!(char[])[2] bufs;
const(char)[][2] targets;
shared static this() {

void tick(size_t index) {
bufs[index].clear();
Expand All @@ -425,8 +425,8 @@ class DateTime {
while (_isClockRunning) {
tick(cur);
cur = 1 - cur;
// BUG: Reported defects -@zhangxueping at 2021-05-12T19:17:53+08:00
// crashed
// TODO: this should be fixed by https://github.com/huntlabs/hunt/pull/97, remove these comments after some time
// BUG: Reported defects -@zhangxueping at 2021-05-12T19:17:53+08:00 crashed
Thread.sleep(1.seconds);
}
});
Expand Down

0 comments on commit 82f6bb1

Please sign in to comment.