Closed Bug 822004 Opened 12 years ago Closed 12 years ago

test failure: test_create_profile.xul | Profile dir has expected name - got ¾Á°, expected ঠাকুর

Categories

(Toolkit :: General, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla20

People

(Reporter: jimm, Assigned: glandium)

References

Details

Attachments

(1 file, 1 obsolete file)

[Parent 2240] ###!!! ASSERTION: iconv failed: 'Error', file ../../../xpcom/io/nsNativeCharsetUtils.cpp, line 535

NS_CopyUnicodeToNative(nsAString_internal const&, nsACString_internal&) [nsNativeCharsetUtils.cpp:826]
nsLocalFile::Append(nsAString_internal const&) [nsLocalFileUnix.cpp:1930]
nsToolkitProfileService::CreateProfileInternal(nsIFile*, nsIFile*, nsACString_internal const&, nsACString_internal const*, nsACString_internal const*, nsACString_internal const*, nsIFile**, bool, nsIToolkitProfile**) [nsTSubstring.h:85]
nsToolkitProfileService::CreateProfile(nsIFile*, nsIFile*, nsACString_internal const&, nsIToolkitProfile**) [nsToolkitProfileService.cpp:705]
NS_InvokeByIndex_P [xptcinvoke_x86_64_unix.cpp:166]
CallMethodHelper::Call() [XPCWrappedNative.cpp:2417]

[Parent 2240] ###!!! ASSERTION: iconv failed: 'Error', file ../../../xpcom/io/nsNativeCharsetUtils.cpp, line 535

NS_CopyUnicodeToNative(nsAString_internal const&, nsACString_internal&) [nsNativeCharsetUtils.cpp:826]
nsLocalFile::Append(nsAString_internal const&) [nsLocalFileUnix.cpp:1930]
nsToolkitProfileService::CreateProfileInternal(nsIFile*, nsIFile*, nsACString_internal const&, nsACString_internal const*, nsACString_internal const*, nsACString_internal const*, nsIFile**, bool, nsIToolkitProfile**) [nsTSubstring.h:85]
nsToolkitProfileService::CreateProfile(nsIFile*, nsIFile*, nsACString_internal const&, nsIToolkitProfile**) [nsToolkitProfileService.cpp:705]
NS_InvokeByIndex_P [xptcinvoke_x86_64_unix.cpp:166]
CallMethodHelper::Call() [XPCWrappedNative.cpp:2417]
XPCWrappedNative::CallMethod(XPCCallContext&, XPCWrappedNative::CallMode) [XPCWrappedNative.cpp:2381]

[Parent 2240] WARNING: conversion from native to utf-16 failed: file ../../../xpcom/io/nsNativeCharsetUtils.cpp, line 463
[Parent 2240] ###!!! ASSERTION: iconv failed: 'Error', file ../../../xpcom/io/nsNativeCharsetUtils.cpp, line 535
NS_CopyUnicodeToNative(nsAString_internal const&, nsACString_internal&) [nsNativeCharsetUtils.cpp:826]
nsLocalFile::CopyTo(nsIFile*, nsAString_internal const&) [nsLocalFileUnix.cpp:1955]
nsToolkitProfileService::CreateProfileInternal(nsIFile*, nsIFile*, nsACString_internal const&, nsACString_internal const*, nsACString_internal const*, nsACString_internal const*, nsIFile**, bool, nsIToolkitProfile**) [nsToolkitProfileService.cpp:800]
nsToolkitProfileService::CreateProfile(nsIFile*, nsIFile*, nsACString_internal const&, nsIToolkitProfile**) [nsToolkitProfileService.cpp:705]
NS_InvokeByIndex_P [xptcinvoke_x86_64_unix.cpp:166]
CallMethodHelper::Call() [XPCWrappedNative.cpp:2417]
XPCWrappedNative::CallMethod(XPCCallContext&, XPCWrappedNative::CallMode) [XPCWrappedNative.cpp:2381]

35972 INFO TEST-PASS | chrome://mochitests/content/chrome/toolkit/profile/test/test_create_profile.xul | Profile ঠাকুর created
35973 INFO TEST-PASS | chrome://mochitests/content/chrome/toolkit/profile/test/test_create_profile.xul | Profile dir created
35974 INFO TEST-PASS | chrome://mochitests/content/chrome/toolkit/profile/test/test_create_profile.xul | Profile dir is a directory
[Parent 2240] WARNING: conversion from native to utf-16 failed: file ../../../xpcom/io/nsNativeCharsetUtils.cpp, line 463
35975 ERROR TEST-UNEXPECTED-FAIL | chrome://mochitests/content/chrome/toolkit/profile/test/test_create_profile.xul | Profile dir has expected name - got  ¾Á°, expected ঠাকুর
[Parent 2240] WARNING: conversion from native to utf-16 failed: file ../../../xpcom/io/nsNativeCharsetUtils.cpp, line 463
[Parent 2240] WARNING: conversion from native to utf-16 failed: file ../../../xpcom/io/nsNativeCharsetUtils.cpp, line 463
This is due to the patch from bug 755724. Here's what happens:
- The code in nsBrowserApp.cpp does this:
   greDir->Clone(getter_AddRefs(appSubdir));
   appSubdir->Append(NS_LITERAL_STRING("browser"));
- which calls NS_CopyUnicodeToNative
- which calls nsNativeCharsetConverter::LazyInit
- which calls nl_langinfo(CODESET), which returns "ANSI_X3.4-1968", which makes us keep gIsNativeUTF8 = false.
- when the test_create_profile.xul test runs, it calls nsToolkitProfileService::CreateProfile
- which uses NS_IsNativeUTF8() to choose between calling nsIFile::AppendNative and nsIFile::Append(NS_ConvertUTF8toUTF16()), but gIsNativeUTF8 is false, so it uses the latter, which is what breaks the test.

Without the patch from bug 755724, nsNativeCharsetConverter::LazyInit is called during the normal startup path, which is:
- after setlocale is called from NS_InitXPCOM2
- after NS_StartupNativeCharsetUtils is called
So nl_langinfo(CODESET) in LazyInit actually returns the locale, which contains UTF-8, and gIsNativeUTF8 ends up true, and nsToolkitProfileService::CreateProfile does the right thing.

Now, the question is: how to best fix this?
I'll add it is disappointing that it's the only test that breaks because we don't consider the locale to be utf-8. We should probably add more tests.
Assignee: nobody → mh+mozilla
Comment on attachment 692706 [details] [diff] [review]
Call NS_StartupNativeCharsetUtils if nsNativeCharsetConverter::LazyInit is called before xpcom initialization

Breaks debug builds :(

###!!! ASSERTION: Release()ing something that hasn't been Acquire()ed: 'chainFront && CallStack::kNone != mDDEntry->mAcquisitionContext', file BlockingResourceBase.cpp, line 160
mozilla::BlockingResourceBase::Release() (/builds/slave/try-lnx-dbg/build/obj-firefox/xpcom/build/BlockingResourceBase.cpp:158)
mozilla::Mutex::Unlock() (/builds/slave/try-lnx-dbg/build/obj-firefox/xpcom/build/BlockingResourceBase.cpp:236)
nsNativeCharsetConverter::Unlock() (/builds/slave/try-lnx-dbg/build/obj-firefox/xpcom/io/../../../xpcom/io/nsNativeCharsetUtils.cpp:282)
NS_CopyUnicodeToNative(nsAString_internal const&, nsACString_internal&) (/builds/slave/try-lnx-dbg/build/obj-firefox/xpcom/io/../../../xpcom/io/nsNativeCharsetUtils.cpp:839)
nsLocalFile::Append(nsAString_internal const&) (/builds/slave/try-lnx-dbg/build/obj-firefox/xpcom/io/../../../xpcom/io/nsLocalFileUnix.cpp:1930)
do_main (/builds/slave/try-lnx-dbg/build/obj-firefox/browser/app/../../../browser/app/nsBrowserApp.cpp:188)
__libc_start_main (/lib/libc.so.6)
Attachment #692706 - Flags: review?(benjamin)
Still awful, but works on opt and debug builds.
Attachment #692731 - Flags: review?(benjamin)
Attachment #692706 - Attachment is obsolete: true
Attachment #692731 - Flags: review?(benjamin) → review+
https://hg.mozilla.org/mozilla-central/rev/f2e4c3f694dd
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla20
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: