22 Star 20 Fork 92

OpenHarmony / distributeddatamgr_appdatamgr

 / 详情

移植ohso到三方平台遇到Storage相关错误

Declined
Bug
Opened this issue  
2021-12-24 15:49

【模块名_概率】简要描述:
【Storage_必现】 移植ohso到三方平台遇到Storage相关错误
【环境信息】:

  • 网络环境
  • 硬件开发板型号
    s700
  • 软件版本信息或tag节点
    openharmony LTS3.0 (11月初版本)
  • 测试环境
  • 其他

【预置条件】:
刷机启动
【测试步骤】:
刷机启动
【预期结果】:
显示正常
【实际结果】:
开机动画后白屏
【恢复手段】:

【出现概率】:问题出现次数/实际测试次数
必现
【定位信息】:
E 03900/Ace: [()] [DUMP] InternalError: code: (null), message: assertion (preference != nullptr) failed: failed to call native
01-01 00:02:36.875 492 510 E 03900/Ace: [()] at Storage (native)
01-01 00:02:36.875 492 510 E 03900/Ace: at 214 (pages/EntryView.js)
01-01 00:02:36.875 492 510 E 03900/Ace: at call (native)
01-01 00:02:36.875 492 510 E 03900/Ace: at i (pages/EntryView.js)
01-01 00:02:36.875 492 510 E 03900/Ace: at 954 (pages/EntryView.js)
01-01 00:02:36.875 492 510 E 03900/Ace: at call (native)
01-01 00:02:36.875 492 510 E 03900/Ace: at i (pages/EntryView.js)
01-01 00:02:36.875 492 510 E 03900/Ace: at 545 (pages/EntryView.js)
01-01 00:02:36.875 492 510 E 03900/Ace: at call (native)
01-01 00:02:36.875 492 510 E 03900/Ace: at i (pages/EntryView.js)
01-01 00:02:36.875 492 510 E 03900/Ace: at 552 (pages/EntryView.js)
01-01 00:02:36.875 492 510 E 03900/Ace: at call (native)
01-01 00:02:36.875 492 510 E 03900/Ace: at i (pages/EntryView.js)
01-01 00:02:36.875 492 510 E 03900/Ace: at 717 (pages/EntryView.js)
01-01 00:02:36.875 492 510 E 03900/Ace: at call (native)
01-01 00:02:36.875 492 510 E 03900/Ace: at i (pages/EntryView.js)
01-01 00:02:36.875 492 510 E 03900/Ace: at 451 (pages/EntryView.js)
01-01 00:02:36.875 492 510 E 03900/Ace: at call (native)
01-01 00:02:36.875 492 510 E 03900/Ace: at i (pages/EntryView.js)
01-01 00:02:36.875 492 510 E 03900/Ace: at 985 (pages/EntryView.js)
01-01 00:02:36.875 492 510 E 03900/Ace: at call (native)
01-01 00:02:36.875 492 510 E 03900/Ace: at i (pages/EntryView.js)
01-01 00:02:36.875 492 510 E 03900/Ace: at (pages/EntryView.js)
01-01 00:02:36.875 492 510 E 03900/Ace: at (pages/EntryView.js)
01-01 00:02:36.875 492 510 D 02d08/HISYSEVENT: size=1035, sysevent={"domain_":"ACE","name_":"JS_ERROR","type_":1,"time_":1420070556875,"tz_":"+242136128","pid_":492,"tid_":510,"uid_":2106,"PACKAGE_NAME":"","REASON":"Js Crash","SUMMARY":"Lifetime: 0.000000s\nJs-Engine: Quick JS\nStacktrace: InternalError: code: (null), message: assertion (preference != nullptr) failed: failed to call native\n\n at Storage (native)\n at 214 (pages/EntryView.js)\n at call (native)\n at i (pages/EntryView.js)\n at 954 (pages/EntryView.js)\n at call (native)\n at i (pages/EntryView.js)\n at 545 (pages/EntryView.js)\n at call (native)\n at i (pages/EntryView.js)\n at 552 (pages/EntryView.js)\n at call (native)\n at i (pages/EntryView.js)\n at 717 (pages/EntryView.js)\n at call (native)\n at i (pages/EntryView.js)\n at 451 (pages/EntryView.js)\n at call (native)\n at i (pages/EntryView.js)\n at 985 (pages/EntryView.js)\n at call (native)\n at i (pages/EntryView.js)\n at (pages/EntryView.js)\n at
01-01 00:02:36.875 492 510 D 02d08/HISYSEVENT: reset send buffer size old=212992, new=524288
01-01 00:02:36.876 158 219 D 02d10/HiView-EventServer: Start: receive data from client
01-01 00:02:36.876 158 219 D 02d10/HiView-SysEventSource: Parser: parser raw message size=1035, {"domain_":"ACE","name_":"JS_ERROR","type_":1,"time_":1420070556875,"tz_":"+242136128","pid_":492,"tid_":510,"uid_":2106,"PACKAGE_NAME":"","REASON":"Js Crash","SUMMARY":"Lifetime: 0.000000s\nJs-Engine: Quick JS\nStacktrace: InternalError: code: (null), message: assertion (preference != nullptr) failed: failed to call native\n\n at Storage (native)\n at 214 (pages/EntryView.js)\n at call (native)\n at i (pages/EntryView.js)\n at 954 (pages/EntryView.js)\n at call (native)\n at i (pages/EntryView.js)\n at 545 (pages/EntryView.js)\n at call (native)\n at i (pages/EntryView.js)\n at 552 (pages/EntryView.js)\n at call (native)\n at i (pages/EntryView.js)\n at 717 (pages/EntryView.js)\n at call (native)\n at i (pages/EntryView.js)\n at 451 (pages/EntryView.js)\n at call (native)\n at i (pages/EntryView.js)\n at 985 (pages/EntryView.js)\n at call (native)\n at i (pages/EntryView.js)\n at (pages/Ent
01-01 00:02:36.887 492 510 D 02d08/HISYSEVENT: HiSysEvent send data successful

    1. Log、截图、多媒体文件等,所有和问题有关的信息:
Attachments
wang_qr 2021-12-24 15:49

Comments (7)

wang_qr created缺陷
wang_qr upload filedmesg.txt
wang_qr set priority to P4
Expand operation logs

01-01 00:02:36.871 492 510 D 01650/PreferencesJsKit: Init
01-01 00:02:36.871 492 510 D 01650/PreferencesJsKit: Init end
01-01 00:02:36.871 492 510 D 01650/PreferencesJsKit: getPreferences 1
01-01 00:02:36.872 492 510 D 01650/PreferencesJsKit: New
01-01 00:02:36.872 492 510 E 01650/NativePreferences: Failed to obtain real path, errno:2
01-01 00:02:36.872 492 510 D 01650/PreferencesJsKit: getPreferences end
01-01 00:02:36.873 226 441 I 02b01/CellularCall: [RegisterHandler-(cellular_call_service.cpp:91)] connect core service count: 3
01-01 00:02:36.873 226 441 I 02b01/CellularCall: [RegisterHandler-(cellular_call_service.cpp:96)] connect core service RegisterHandler null or not init
01-01 00:02:36.875 492 510 E 03900/Ace: [()] [DUMP] InternalError: code: (null), message: assertion ( preference != nullptr ) failed: failed to call native

说明:
OS error code 2: No such file or directory
操作系统错误代码2:没有这样的文件或目录

即说明传入getStorage传入时使用的路径不正常。请检查。

MangTsang changed issue state from 待办的 to 已确认
MangTsang set assignee to MangTsang
MangTsang added
 
SIG_DataManagement
label

@MangTsang

输入图片说明
看代码,传入的路径是/data/accounts/account_0/appdata/com.ohos.launcher/sharedPreference/LauncherPreference

getStorageSync() 这个方法是创建文件的把? 帮看下为啥没创建成功

@MangTsang
报错发生在如下代码:
请问下realpath() 这个接口的定义在哪个文件,我再继续追代码看下为什么这个为空

输入图片说明

这个系统库方法。基本可以确认就是getStorage的时候传入的path不存在导致的。

@MangTsang 请问下realpath() 这个接口的定义在哪个文件 ?

我看了板子对应的路径,/data/accounts/account_0/appdata/com.ohos.launcher/sharedPreference 这个是有的,下面圈起来的代码是创建LauncherPreference 文件的吧,但是在75行就err返回了,导致LauncherPreference没有创建

输入图片说明

@MangTsang 我把如下代码的76 77行注掉,我白屏问题就解决了,看来还是realpath()接口的问题,这个具体调用的哪个接口,我跟踪下代码
输入图片说明

函数原型:
char *realpath(const char *path, char *resolved_path)

头文件:
#include <limits.h>
#include <stdlib.h>

函数说明:

  • 将参数path所指的相对路径转换成绝对路径后存于参数resolved_path所指的字符串数组或指针中
  • 如果resolved_path为NULL,则该函数调用malloc分配一块大小为PATH_MAX的内存来存放解析出来的绝对路径,并返回指向这块区域的指针。程序员应调用free来手动释放这块内存。

返回值:

  • 成功则返回指向resolved_path的指针,失败返回NULL,错误代码存于errno
MangTsang changed issue state from 已确认 to 已拒绝

Sign in to comment

Status
Assignees
Projects
Milestones
Pull Requests
Successfully merging a pull request will close this issue.
Branches
Planed to start   -   Planed to end
-
Top level
Priority
Duration (hours)
参与者(2)
2256985 mangtsang 1630294018
1
https://git.oschina.net/openharmony/distributeddatamgr_appdatamgr.git
git@git.oschina.net:openharmony/distributeddatamgr_appdatamgr.git
openharmony
distributeddatamgr_appdatamgr
distributeddatamgr_appdatamgr

Search

103111 552b83b3 1850385 103110 ed87a847 1850385