Skip to content

Commit

Permalink
Fixes for recording/replaying on windows (#969)
Browse files Browse the repository at this point in the history
  • Loading branch information
bhackett1024 committed May 28, 2023
1 parent 77248eb commit 9877158
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
26 changes: 25 additions & 1 deletion gfx/thebes/gfxDWriteFontList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2456,11 +2456,19 @@ class BundledFontFileEnumerator : public IDWriteFontFileEnumerator {
BundledFontFileEnumerator::BundledFontFileEnumerator(IDWriteFactory* aFactory,
nsIFile* aFontDir)
: mFactory(aFactory), mFontDir(aFontDir) {
mFontDir->GetDirectoryEntries(getter_AddRefs(mEntries));
if (mFontDir) {
mFontDir->GetDirectoryEntries(getter_AddRefs(mEntries));
}
}

IFACEMETHODIMP
BundledFontFileEnumerator::MoveNext(BOOL* aHasCurrentFile) {
// Watch out for missing fonts when replaying.
if (recordreplay::IsReplaying()) {
return S_OK;
}
recordreplay::AutoPassThroughThreadEvents pt;

bool hasMore = false;
if (mEntries) {
if (NS_SUCCEEDED(mEntries->HasMoreElements(&hasMore)) && hasMore) {
Expand All @@ -2475,6 +2483,12 @@ BundledFontFileEnumerator::MoveNext(BOOL* aHasCurrentFile) {

IFACEMETHODIMP
BundledFontFileEnumerator::GetCurrentFontFile(IDWriteFontFile** aFontFile) {
// Watch out for missing fonts when replaying.
if (recordreplay::IsReplaying()) {
return S_OK;
}
recordreplay::AutoPassThroughThreadEvents pt;

nsCOMPtr<nsIFile> file = do_QueryInterface(mCurrent);
if (!file) {
return E_FAIL;
Expand Down Expand Up @@ -2511,6 +2525,16 @@ BundledFontLoader::CreateEnumeratorFromKey(
IDWriteFactory* aFactory, const void* aCollectionKey,
UINT32 aCollectionKeySize,
IDWriteFontFileEnumerator** aFontFileEnumerator) {
// The collection key's contents will be recorded/replayed and we can't dereference
// embedded pointers within it. Workaround this by creating a dummy enumerator when
// we're replaying.
if (recordreplay::IsReplaying()) {
*aFontFileEnumerator = new BundledFontFileEnumerator(aFactory, nullptr);
NS_ADDREF(*aFontFileEnumerator);
return S_OK;
}
recordreplay::AutoPassThroughThreadEvents pt;

nsIFile* fontDir = *(nsIFile**)aCollectionKey;
*aFontFileEnumerator = new BundledFontFileEnumerator(aFactory, fontDir);
NS_ADDREF(*aFontFileEnumerator);
Expand Down
9 changes: 8 additions & 1 deletion intl/icu/source/i18n/numfmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
#include "number_decimalquantity.h"
#include "number_utils.h"

#include "mozilla/RecordReplay.h"

//#define FMT_DEBUG

#ifdef FMT_DEBUG
Expand Down Expand Up @@ -1407,7 +1409,12 @@ NumberFormat::makeInstance(const Locale& desiredLocale,
ns->getName(),
gFormatCldrStyles[style],
status);
pattern = UnicodeString(TRUE, patternPtr, -1);

// Record/replay string length to workaround the length differing when
// replaying for an unknown reason.
int len = mozilla::recordreplay::RecordReplayValue("NumberFormat::makeInstance", u_strlen(patternPtr));

pattern = UnicodeString(TRUE, patternPtr, len);
}
if (U_FAILURE(status)) {
return NULL;
Expand Down
4 changes: 4 additions & 0 deletions mozglue/dllservices/WindowsDllBlocklist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "nsWindowsDllInterceptor.h"
#include "mozilla/CmdLineAndEnvUtils.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/RecordReplay.h"
#include "mozilla/StackWalk_windows.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/UniquePtr.h"
Expand Down Expand Up @@ -353,6 +354,9 @@ static wchar_t* lastslash(wchar_t* s, int len) {
static NTSTATUS NTAPI patched_LdrLoadDll(PWCHAR filePath, PULONG flags,
PUNICODE_STRING moduleFileName,
PHANDLE handle) {
// This code only runs when recording.
recordreplay::AutoPassThroughThreadEvents pt;

// We have UCS2 (UTF16?), we want ASCII, but we also just want the filename
// portion
#define DLLNAME_MAX 128
Expand Down

0 comments on commit 9877158

Please sign in to comment.