[0.11.22] [Martin] Crash depend on the system encoding (OSX)
Posted: Thu May 14, 2015 5:02 pm
Hi,
factorio 0.11.22 shall crash while it boots up before producing its log file.
This problem will occur when the system encoding is kCFStringEncodingMacJapanese. (also may occur at other encoding except kCFStringEncodingMacRoman. maybe)
callstack:
#0 0x00007fff89d17732 in strlen ()
#1 0x00000001002a33e9 in Paths::getSystemReadData ()
#2 0x0000000100356c86 in PathMacroReplacer::apply ()
#3 0x0000000100356594 in MacroReplacer::operator() ()
#4 0x0000000100465c95 in boost::re_detail::format_functor1<ReplacerWrapper, boost::match_results<std::__1::__wrap_iter<char const*>, std::__1::allocator<boost::sub_match<std::__1::__wrap_iter<char const*> > > > >::operator()<boost::re_detail::string_out_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > ()
#5 0x000000010045f1db in boost::regex_replace<boost::re_detail::string_out_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::__wrap_iter<char const*>, boost::regex_traits<char, boost::cpp_regex_traits<char> >, char, ReplacerWrapper> ()
#6 0x000000010019123a in MacroReplacer::replace ()
#7 0x00000001002a3516 in Paths::load ()
#8 0x00000001002a23e0 in Paths::Paths ()
#9 0x000000010018fc52 in GlobalContext::init ()
#10 0x000000010027d7f6 in MainLoop::run ()
#11 0x000000010027cc02 in _al_mangled_main ()
#12 0x00000001006af4a7 in +[AllegroAppDelegate app_main:] ()
#13 0x00007fff8522376b in __NSThread__main__ ()
#14 0x00007fff8be89899 in _pthread_body ()
#15 0x00007fff8be8972a in _pthread_start ()
#16 0x00007fff8be8dfc9 in thread_start ()
disassembled and comments:
Dump of assembler code for function _ZN5Paths17getSystemReadDataEv:
0x00000001002a33a0 <_ZN5Paths17getSystemReadDataEv+0>: push %rbp
0x00000001002a33a1 <_ZN5Paths17getSystemReadDataEv+1>: mov %rsp,%rbp
0x00000001002a33a4 <_ZN5Paths17getSystemReadDataEv+4>: push %r15
0x00000001002a33a6 <_ZN5Paths17getSystemReadDataEv+6>: push %r14
0x00000001002a33a8 <_ZN5Paths17getSystemReadDataEv+8>: push %r12
0x00000001002a33aa <_ZN5Paths17getSystemReadDataEv+10>: push %rbx
0x00000001002a33ab <_ZN5Paths17getSystemReadDataEv+11>: sub $0x50,%rsp
0x00000001002a33af <_ZN5Paths17getSystemReadDataEv+15>: mov %rdi,%r14
0x00000001002a33b2 <_ZN5Paths17getSystemReadDataEv+18>: callq 0x1007a094c <dyld_stub_CFBundleGetMainBundle>
0x00000001002a33b7 <_ZN5Paths17getSystemReadDataEv+23>: mov %rax,%rdi
0x00000001002a33ba <_ZN5Paths17getSystemReadDataEv+26>: callq 0x1007a093a <dyld_stub_CFBundleCopyBundleURL>
0x00000001002a33bf <_ZN5Paths17getSystemReadDataEv+31>: mov %rax,%r12
0x00000001002a33c2 <_ZN5Paths17getSystemReadDataEv+34>: xor %esi,%esi
0x00000001002a33c4 <_ZN5Paths17getSystemReadDataEv+36>: mov %r12,%rdi
0x00000001002a33c7 <_ZN5Paths17getSystemReadDataEv+39>: callq 0x1007a09be <dyld_stub_CFURLCopyFileSystemPath>
0x00000001002a33cc <_ZN5Paths17getSystemReadDataEv+44>: mov %rax,%r15
0x00000001002a33cf <_ZN5Paths17getSystemReadDataEv+47>: callq 0x1007a09b8 <dyld_stub_CFStringGetSystemEncoding>
;
; CFStringGetSystemEncoding returns '1' (kCFStringEncodingMacJapanese) on my env
;
0x00000001002a33d4 <_ZN5Paths17getSystemReadDataEv+52>: mov %r15,%rdi
;
; eax has a return value of CFStringGetSystemEncoding: 1
; (Here I break it at here and did 'set $rax=0' on gdb, then factorio runs finely)
;
0x00000001002a33d7 <_ZN5Paths17getSystemReadDataEv+55>: mov %eax,%esi
0x00000001002a33d9 <_ZN5Paths17getSystemReadDataEv+57>: callq 0x1007a09b2 <dyld_stub_CFStringGetCStringPtr>
;
; CFStringGetCStringPtr returns NULL if encoding argument is non-8bits-encoding(like kCGStringEncofingMacJapanese).
;
0x00000001002a33de <_ZN5Paths17getSystemReadDataEv+62>: mov %rax,%rbx
0x00000001002a33e1 <_ZN5Paths17getSystemReadDataEv+65>: mov %rbx,%rdi
;
; It crashes in strlem(NULL).
;
0x00000001002a33e4 <_ZN5Paths17getSystemReadDataEv+68>: callq 0x1007a01d2 <dyld_stub_strlen>
0x00000001002a33e9 <_ZN5Paths17getSystemReadDataEv+73>: lea -0x50(%rbp),%rdi
I think the problem is easy to fix.
HTH,
Mac OSX 10.9.4
factorio 0.11.22 shall crash while it boots up before producing its log file.
This problem will occur when the system encoding is kCFStringEncodingMacJapanese. (also may occur at other encoding except kCFStringEncodingMacRoman. maybe)
callstack:
#0 0x00007fff89d17732 in strlen ()
#1 0x00000001002a33e9 in Paths::getSystemReadData ()
#2 0x0000000100356c86 in PathMacroReplacer::apply ()
#3 0x0000000100356594 in MacroReplacer::operator() ()
#4 0x0000000100465c95 in boost::re_detail::format_functor1<ReplacerWrapper, boost::match_results<std::__1::__wrap_iter<char const*>, std::__1::allocator<boost::sub_match<std::__1::__wrap_iter<char const*> > > > >::operator()<boost::re_detail::string_out_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > ()
#5 0x000000010045f1db in boost::regex_replace<boost::re_detail::string_out_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::__wrap_iter<char const*>, boost::regex_traits<char, boost::cpp_regex_traits<char> >, char, ReplacerWrapper> ()
#6 0x000000010019123a in MacroReplacer::replace ()
#7 0x00000001002a3516 in Paths::load ()
#8 0x00000001002a23e0 in Paths::Paths ()
#9 0x000000010018fc52 in GlobalContext::init ()
#10 0x000000010027d7f6 in MainLoop::run ()
#11 0x000000010027cc02 in _al_mangled_main ()
#12 0x00000001006af4a7 in +[AllegroAppDelegate app_main:] ()
#13 0x00007fff8522376b in __NSThread__main__ ()
#14 0x00007fff8be89899 in _pthread_body ()
#15 0x00007fff8be8972a in _pthread_start ()
#16 0x00007fff8be8dfc9 in thread_start ()
disassembled and comments:
Dump of assembler code for function _ZN5Paths17getSystemReadDataEv:
0x00000001002a33a0 <_ZN5Paths17getSystemReadDataEv+0>: push %rbp
0x00000001002a33a1 <_ZN5Paths17getSystemReadDataEv+1>: mov %rsp,%rbp
0x00000001002a33a4 <_ZN5Paths17getSystemReadDataEv+4>: push %r15
0x00000001002a33a6 <_ZN5Paths17getSystemReadDataEv+6>: push %r14
0x00000001002a33a8 <_ZN5Paths17getSystemReadDataEv+8>: push %r12
0x00000001002a33aa <_ZN5Paths17getSystemReadDataEv+10>: push %rbx
0x00000001002a33ab <_ZN5Paths17getSystemReadDataEv+11>: sub $0x50,%rsp
0x00000001002a33af <_ZN5Paths17getSystemReadDataEv+15>: mov %rdi,%r14
0x00000001002a33b2 <_ZN5Paths17getSystemReadDataEv+18>: callq 0x1007a094c <dyld_stub_CFBundleGetMainBundle>
0x00000001002a33b7 <_ZN5Paths17getSystemReadDataEv+23>: mov %rax,%rdi
0x00000001002a33ba <_ZN5Paths17getSystemReadDataEv+26>: callq 0x1007a093a <dyld_stub_CFBundleCopyBundleURL>
0x00000001002a33bf <_ZN5Paths17getSystemReadDataEv+31>: mov %rax,%r12
0x00000001002a33c2 <_ZN5Paths17getSystemReadDataEv+34>: xor %esi,%esi
0x00000001002a33c4 <_ZN5Paths17getSystemReadDataEv+36>: mov %r12,%rdi
0x00000001002a33c7 <_ZN5Paths17getSystemReadDataEv+39>: callq 0x1007a09be <dyld_stub_CFURLCopyFileSystemPath>
0x00000001002a33cc <_ZN5Paths17getSystemReadDataEv+44>: mov %rax,%r15
0x00000001002a33cf <_ZN5Paths17getSystemReadDataEv+47>: callq 0x1007a09b8 <dyld_stub_CFStringGetSystemEncoding>
;
; CFStringGetSystemEncoding returns '1' (kCFStringEncodingMacJapanese) on my env
;
0x00000001002a33d4 <_ZN5Paths17getSystemReadDataEv+52>: mov %r15,%rdi
;
; eax has a return value of CFStringGetSystemEncoding: 1
; (Here I break it at here and did 'set $rax=0' on gdb, then factorio runs finely)
;
0x00000001002a33d7 <_ZN5Paths17getSystemReadDataEv+55>: mov %eax,%esi
0x00000001002a33d9 <_ZN5Paths17getSystemReadDataEv+57>: callq 0x1007a09b2 <dyld_stub_CFStringGetCStringPtr>
;
; CFStringGetCStringPtr returns NULL if encoding argument is non-8bits-encoding(like kCGStringEncofingMacJapanese).
;
0x00000001002a33de <_ZN5Paths17getSystemReadDataEv+62>: mov %rax,%rbx
0x00000001002a33e1 <_ZN5Paths17getSystemReadDataEv+65>: mov %rbx,%rdi
;
; It crashes in strlem(NULL).
;
0x00000001002a33e4 <_ZN5Paths17getSystemReadDataEv+68>: callq 0x1007a01d2 <dyld_stub_strlen>
0x00000001002a33e9 <_ZN5Paths17getSystemReadDataEv+73>: lea -0x50(%rbp),%rdi
I think the problem is easy to fix.
HTH,
Mac OSX 10.9.4