Commit 9d63df43 authored by Deepti Gandluri's avatar Deepti Gandluri Committed by Commit Bot

Revert "Add test to show the crashing of TimeZone::AdoptDefault"

This reverts commit 91415227.

Reason for revert: This fails on multiple bots, infra bug let this land - https://logs.chromium.org/logs/v8/buildbucket/cr-buildbucket.appspot.com/8913373605803837584/+/steps/build/0/steps/compile/0/logs/raw_io.output_failure_summary_/0

Original change's description:
> Add test to show the crashing of TimeZone::AdoptDefault
> 
> The ICU DEPS for chromium is landing in
> https://chromium-review.googlesource.com/c/chromium/src/+/1607506
> 
> Bug: chromium:950851
> Change-Id: If16e82d70c319108ead06dd095b22ecda5408a6b
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1601370
> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> Commit-Queue: Frank Tang <ftang@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#61550}

TBR=adamk@chromium.org,jkummerow@chromium.org,jshin@chromium.org,mathias@chromium.org,ftang@chromium.org

Change-Id: I682119db77c569ad7b619375e54309a4ff530273
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:950851
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1613697Reviewed-by: 's avatarDeepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Deepti Gandluri <gdeepti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61554}
parent 795ade88
......@@ -147,7 +147,6 @@ v8_source_set("unittests_sources") {
"compiler/zone-stats-unittest.cc",
"conversions-unittest.cc",
"counters-unittest.cc",
"date-cache-unittest.cc",
"detachable-vector-unittest.cc",
"eh-frame-iterator-unittest.cc",
"eh-frame-writer-unittest.cc",
......
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/base/platform/platform.h"
#include "src/date.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "unicode/strenum.h"
#include "unicode/timezone.h"
namespace v8 {
namespace internal {
// A recent time for the test.
// 2019-05-08T04:16:04.845Z
static const int64_t kStartTime = 1557288964845;
class AdoptDefaultThread final : public base::Thread {
public:
AdoptDefaultThread() : base::Thread(Options("AdoptDefault")) {}
void Run() override {
printf("AdoptDefaultThread Start\n");
std::unique_ptr<icu::StringEnumeration> timezones(
icu::TimeZone::createEnumeration());
UErrorCode status = U_ZERO_ERROR;
const icu::UnicodeString* timezone = timezones->snext(status);
icu::TimeZone::adoptDefault(icu::TimeZone::createTimeZone(*timezone));
printf("AdoptDefaultThread End\n");
}
};
class GetLocalOffsetFromOSThread final : public base::Thread {
public:
explicit GetLocalOffsetFromOSThread(bool utc)
: base::Thread(Options("GetLocalOffsetFromOS")), utc_(utc) {}
void Run() override {
printf("GetLocalOffsetFromOSThread Start\n");
DateCache date_cache;
date_cache.GetLocalOffsetFromOS(kStartTime, utc_);
printf("GetLocalOffsetFromOSThread End\n");
}
private:
bool utc_;
};
class LocalTimezoneThread final : public base::Thread {
public:
LocalTimezoneThread() : base::Thread(Options("LocalTimezone")) {}
void Run() override {
printf("LocalTimezoneThread Start\n");
DateCache date_cache;
date_cache.LocalTimezone(kStartTime);
printf("LocalTimezoneThread End\n");
}
};
TEST(DateCache, AdoptDefaultFirst) {
AdoptDefaultThread t1;
GetLocalOffsetFromOSThread t2(true);
GetLocalOffsetFromOSThread t3(false);
LocalTimezoneThread t4;
// The AdoptDefaultFirst will always pass. Just a test to ensure
// our testing code itself is correct.
// We finish all the operation AdoptDefaultThread before
// running all other thread so it won't show the problem of
// AdoptDefault trashing newly create default.
t1.Start();
t1.Join();
t2.Start();
t3.Start();
t4.Start();
t2.Join();
t3.Join();
t4.Join();
}
TEST(DateCache, AdoptDefaultMixed) {
AdoptDefaultThread t1;
GetLocalOffsetFromOSThread t2(true);
GetLocalOffsetFromOSThread t3(false);
LocalTimezoneThread t4;
// The AdoptDefaultMixed run AdoptDefaultThread concurrently
// with other thread so if the AdoptDefault is not thread safe
// it will cause crash in other thread because the TimeZone
// newly created by createDefault could be trashed by AdoptDefault
// while a deleted DEFAULT_ZONE got cloned.
t1.Start();
t2.Start();
t3.Start();
t4.Start();
t1.Join();
t2.Join();
t3.Join();
t4.Join();
}
} // namespace internal
} // namespace v8
......@@ -42,6 +42,5 @@ int main(int argc, char** argv) {
testing::AddGlobalTestEnvironment(new DefaultPlatformEnvironment);
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
v8::V8::InitializeExternalStartupData(argv[0]);
v8::V8::InitializeICUDefaultLocation(argv[0]);
return RUN_ALL_TESTS();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment