firebase-cpp-sdk icon indicating copy to clipboard operation
firebase-cpp-sdk copied to clipboard

[Bug] App crash when user home folder contains non latin characters

Open awemvfx opened this issue 4 years ago • 9 comments

[REQUIRED] Please fill in the following fields:

  • Pre-built SDK from the website
  • Firebase C++ SDK version: 8.6.0
  • Problematic Firebase Component: firestore
  • Other Firebase Components in use: auth
  • Platform you are using the C++ SDK on: Windows
  • Platform you are targeting: desktop

[REQUIRED] Please describe the issue here:

(Please list the full steps to reproduce the issue. Include device logs, Unity logs, and stack traces if available.)

Steps to reproduce:

Create user system account with NON LATIN characters in name eg. björn User system home path looks like: "C:\Users\björn\AppData\Local"

  1. App init is ok
  2. Create user account is ok
  3. Listen some collection crash app instantly with error code -529697949

"C:\Users\björn\AppData\Local\firestore" is created but there is no files inside only empty directories "C:\Users\björn\AppData\Local\firebase-heartbeat" is NOT created

What's the issue repro rate? 100%

awemvfx avatar Nov 03 '21 14:11 awemvfx

Thanks for reporting this. I will look into this and see if I can reproduce this behavior.

schmidt-sebastian avatar Nov 03 '21 20:11 schmidt-sebastian

Any update for this issue ?

dawidpietrasina avatar Nov 17 '21 08:11 dawidpietrasina

This is a bit hard to reproduce actually, since my corp laptops always use my username, which does not contain non-ascii chars.

Is it possible for you to extract any logs, stack traces? Can you try turn on Firestore debug logging as well?

wu-hui avatar Nov 18 '21 19:11 wu-hui

Hey @awemvfx. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Nov 25 '21 02:11 google-oss-bot

Exception at 0x7ff89b0f466c, code: 0xe06d7363: C++ exception, flags=0x81
1  RaiseException                                                                     KERNELBASE     0x7ff89b0f466c     
2  CxxThrowException                                                                  VCRUNTIME140D  0x7ff87ff6b460     
3  firebase::firestore::util::Throw                                                   mInstaller     0x7ff781fd8206 
mInstaller!firebase::firestore::util::Throw+0x1c6:
0x7ff781fd8106  <+  454>         lea     eax,[rsp+108h]
0x7ff781fd810d  <+  461>         mov     qword ptr [rsp+20h],rax
0x7ff781fd8112  <+  466>         lea     r9,[rsp+138h]
0x7ff781fd811a  <+  474>         lea     r8,[rsp+168h]
0x7ff781fd8122  <+  482>         lea     rdx,[rsp+198h]
0x7ff781fd812a  <+  490>         lea     rcx,[rsp+48h]
0x7ff781fd812f  <+  495>         call    mInstaller!ILT+78760(??$StrAppend$$BY02Dlts_2020_02_25f_b_abslYAXPEAV?$basic_stringDU?$char_traitsDstdV?$allocatorD (00007ff7`81d943ad)
0x7ff781fd8134  <+  500>         mov     rdx,qword ptr [rsp+300h]
0x7ff781fd813c  <+  508>         lea     rcx,[rsp+1C8h]
0x7ff781fd8144  <+  516>         call    mInstaller!ILT+238965(??$?0V?$allocatorDstdAlphaNumlts_2020_02_25f_b_abslQEAAAEBV?$basic_stringDU?$char_traitsDstdV?$allocatorD (00007ff7`81dbb57a)
0x7ff781fd8149  <+  521>         lea     rdx,[rsp+1C8h]
0x7ff781fd8151  <+  529>         lea     rcx,[rsp+48h]
0x7ff781fd8156  <+  534>         call    mInstaller!ILT+91785(?StrAppendlts_2020_02_25f_b_abslYAXPEAV?$basic_stringDU?$char_traitsDstdV?$allocatorD (00007ff7`81d9768e)
0x7ff781fd815b  <+  539>         mov     ecx,3
0x7ff781fd8160  <+  544>         call    mInstaller!ILT+93860(?LogIsLoggableutilfirestorefirebaseYA_NW4LogLevel (00007ff7`81d97ea9)
0x7ff781fd8165  <+  549>         movzx   eax,al
0x7ff781fd8168  <+  552>         test    eax,eax
0x7ff781fd816a  <+  554>         je      mInstaller!firebase::firestore::util::Throw+0x266 (00007ff7`81fd81a6)
0x7ff781fd816c  <+  556>         lea     r8,[rsp+48h]
0x7ff781fd8171  <+  561>         lea     rdx,[mInstaller!`string'+0x8a0 (00007ff7`8305b098)]
0x7ff781fd8178  <+  568>         lea     rcx,[rsp+208h]
0x7ff781fd8180  <+  576>         call    mInstaller!ILT+162690(??$StringFormatV?$basic_stringDU?$char_traitsDstdV?$allocatorD (00007ff7`81da8b87)
0x7ff781fd8185  <+  581>         nop
0x7ff781fd8186  <+  582>         lea     rdx,[rsp+208h]
0x7ff781fd818e  <+  590>         mov     ecx,3
0x7ff781fd8193  <+  595>         call    mInstaller!ILT+154860(?LogMessageutilfirestorefirebaseYAXW4LogLevel (00007ff7`81da6cf1)
0x7ff781fd8198  <+  600>         nop
0x7ff781fd8199  <+  601>         lea     rcx,[rsp+208h]
0x7ff781fd81a1  <+  609>         call    mInstaller!ILT+48820(??1?$basic_stringDU?$char_traitsDstdV?$allocatorD (00007ff7`81d8ceb9)
0x7ff781fd81a6  <+  614>         xor     eax,eax
0x7ff781fd81a8  <+  616>         test    eax,eax
0x7ff781fd81aa  <+  618>         jne     mInstaller!firebase::firestore::util::Throw+0x21b (00007ff7`81fd815b)
0x7ff781fd81ac  <+  620>         mov     eax,dword ptr [rsp+2E0h]
0x7ff781fd81b3  <+  627>         mov     dword ptr [rsp+2C0h],eax
0x7ff781fd81ba  <+  634>         cmp     dword ptr [rsp+2C0h],0
0x7ff781fd81c2  <+  642>         je      mInstaller!firebase::firestore::util::Throw+0x29a (00007ff7`81fd81da)
0x7ff781fd81c4  <+  644>         cmp     dword ptr [rsp+2C0h],1
0x7ff781fd81cc  <+  652>         je      mInstaller!firebase::firestore::util::Throw+0x2c6 (00007ff7`81fd8206)
0x7ff781fd81ce  <+  654>         cmp     dword ptr [rsp+2C0h],2
0x7ff781fd81d6  <+  662>         je      mInstaller!firebase::firestore::util::Throw+0x2ef (00007ff7`81fd822f)
0x7ff781fd81d8  <+  664>         jmp     mInstaller!firebase::firestore::util::Throw+0x318 (00007ff7`81fd8258)
0x7ff781fd81da  <+  666>         mov     r8d,0Dh
0x7ff781fd81e0  <+  672>         lea     rdx,[rsp+48h]
0x7ff781fd81e5  <+  677>         lea     rcx,[rsp+240h]
0x7ff781fd81ed  <+  685>         call    mInstaller!ILT+273595(??0FirestoreInternalErrorfirestorefirebaseQEAAAEBV?$basic_stringDU?$char_traitsDstdV?$allocatorD (00007ff7`81dc3cc0)
0x7ff781fd81f2  <+  690>         lea     rdx,[mInstaller!TI3?AVFirestoreInternalErrorfirestorefirebase (00007ff7`837b98f0)]
0x7ff781fd81f9  <+  697>         lea     rcx,[rsp+240h]
0x7ff781fd8201  <+  705>         call    mInstaller!CxxThrowException (00007ff7`829928a0)
0x7ff781fd8206  <+  710>         mov     rdx,qword ptr [rsp+300h]
0x7ff781fd820e  <+  718>         lea     rcx,[rsp+290h]
0x7ff781fd8216  <+  726>         call    mInstaller!ILT+130350(??0logic_errorstdQEAAAEBV?$basic_stringDU?$char_traitsDstdV?$allocatorD (00007ff7`81da0d33)
0x7ff781fd821b  <+  731>         lea     rdx,[mInstaller!TI2?AVlogic_errorstd (00007ff7`837b99a0)]
0x7ff781fd8222  <+  738>         lea     rcx,[rsp+290h]
0x7ff781fd822a  <+  746>         call    mInstaller!CxxThrowException (00007ff7`829928a0)
0x7ff781fd822f  <+  751>         mov     rdx,qword ptr [rsp+300h]
0x7ff781fd8237  <+  759>         lea     rcx,[rsp+2A8h]
0x7ff781fd823f  <+  767>         call    mInstaller!ILT+109925(??0invalid_argumentstdQEAAAEBV?$basic_stringDU?$char_traitsDstdV?$allocatorD (00007ff7`81d9bd6a)
0x7ff781fd8244  <+  772>         lea     rdx,[mInstaller!TI3?AVinvalid_argumentstd (00007ff7`837b99e8)]
0x7ff781fd824b  <+  779>         lea     rcx,[rsp+2A8h]
0x7ff781fd8253  <+  787>         call    mInstaller!CxxThrowException (00007ff7`829928a0)
0x7ff781fd8258  <+  792>         call    qword ptr [mInstaller!_imp_abort (00007ff7`8384f2b0)]
0x7ff781fd825e  <+  798>         nop
0x7ff781fd825f  <+  799>         lea     rcx,[rsp+48h]
0x7ff781fd8264  <+  804>         call    mInstaller!ILT+48820(??1?$basic_stringDU?$char_traitsDstdV?$allocatorD (00007ff7`81d8ceb9)
0x7ff781fd8269  <+  809>         mov     rcx,rsp
0x7ff781fd826c  <+  812>         lea     rdx,[mInstaller!`string'+0xb28 (00007ff7`8305b320)]
0x7ff781fd8273  <+  819>         call    mInstaller!ILT+226875(_RTC_CheckStackVars) (00007ff7`81db8640)
0x7ff781fd8278  <+  824>         nop
0x7ff781fd8279  <+  825>         add     rsp,2D0h
0x7ff781fd8280  <+  832>         pop     rdi
0x7ff781fd8281  <+  833>         ret
0x7ff781fd8282  <+  834>         int     3
0x7ff781fd8283  <+  835>         add     byte ptr [rax],al
0x7ff781fd8285  <+  837>         add     byte ptr [rax],al
0x7ff781fd8287  <+  839>         add     byte ptr [rax],al
0x7ff781fd8289  <+  841>         add     byte ptr [rax],al
0x7ff781fd828b  <+  843>         add     byte ptr [rax],al
0x7ff781fd828d  <+  845>         add     byte ptr [rax],al
0x7ff781fd828f  <+  847>         add     ah,cl

awemvfx avatar Nov 26 '21 13:11 awemvfx

FYI This may be the same root cause but surfacing in the Unity SDK: https://github.com/firebase/firebase-unity-sdk/issues/405

dconeybe avatar Dec 02 '21 21:12 dconeybe

I've done some investigation and I've found the root cause, but I'm not sure how to fix it.

The crash happens when opening the LevelDb database in firestore_client.cc. It ultimately calls down to LevelDb's WindowsEnv::CreateDir() which uses the Windows API function CreateDirectoryA() to create the directory.

The problem is that CreateDirectoryA() is the "ANSI" version of the function and can only handle ASCII characters; therefore, this function fails when invoked with non-ASCII characters, such as ö.

At one point there was an attempt to instead use CreateDirectoryW(), the "wide character" companion to CreateDirectoryA(), but that effort appears to have been abandoned: https://github.com/google/leveldb/issues/519.

One interesting comment in that issue is this https://github.com/google/leveldb/issues/519#issuecomment-337366812, which suggests

...following the approach taken by Chromium's LevelDB integration. Chromium builds (and runs) on Windows, and does not require modifications to the rest of the LevelDB.

dconeybe avatar Mar 15 '22 20:03 dconeybe

Any news/progress on this issue? Living in a German-speaking country this issue is quite painful for us.

Girildo avatar May 09 '22 08:05 Girildo

Unfortunately, I don't have any good news about this bug. I haven't been able to find a solution. I did some investigation and tried a few fixes but nothing worked. I'm not making any progress at the moment and I'm not sure when I'll get back to investigating.

dconeybe avatar May 09 '22 14:05 dconeybe

This bug is fixed in v11.1.0 (https://firebase.google.com/support/release-notes/cpp-relnotes#version_1110_-_may_31_2023). Please try it out!

dconeybe avatar Jun 01 '23 20:06 dconeybe