AllocateBuffer:332 size must have a size bigger than 0 HarmonyOS 鸿蒙Next

AllocateBuffer:332 size must have a size bigger than 0 HarmonyOS 鸿蒙Next

Device info: OpenHarmony 3.2

Build info: OpenHarmony 3.2.9.1

Module name: com.example.helloworld

Version: 1.0.0

Pid: 675

Uid: 20040004

Reason: Signal: SIGABRT(SI_QUEUE)@0x0131c944000002a3 from: 675:20040004

LastFatalMessage: [gc] AllocateBuffer:332 size must have a size bigger than 0

Thread name: com.example.hel

#00 pc 000000000009fcbf /vendor/aosp/system/lib64/libc.so(abort+191) (2de37b8aa6e96dd64a6cfa51bd78ae6e)

#01 pc 000000000019c66a /system/lib64/libark_jsruntime.so (8ef042f942210dcf45c6431c798421b4)

#02 pc 00000000003533cf /system/lib64/libark_jsruntime.so(panda::ecmascript::JSPandaFileManager::JSPandaFileAllocator::AllocateBuffer(unsigned long)+335) (8ef042f942210dcf45c6431c798421b4)

#03 pc 00000000003503a7 /system/lib64/libark_jsruntime.so(panda::ecmascript::JSPandaFileManager::NewJSPandaFile(panda::panda_file::File const*, std::__h::basic_string<char, std::__h::char_traits<char>, panda::ecmascript::CAddressAllocator<char>> const&)+3735) (8ef042f942210dcf45c6431c798421b4)

#04 pc 000000000034da1f /system/lib64/libark_jsruntime.so(panda::ecmascript::JSPandaFileManager::GenerateJSPandaFile(panda::ecmascript::JSThread*, panda::panda_file::File const*, std::__h::basic_string<char, std::__h::char_traits<char>, panda::ecmascript::CAddressAllocator<char>> const&, std::__h::basic_string_view<char, std::__h::char_traits<char>>)+63) (8ef042f942210dcf45c6431c798421b4)

#05 pc 0000000000351da4 /system/lib64/libark_jsruntime.so(panda::ecmascript::JSPandaFileManager::LoadJSPandaFile(panda::ecmascript::JSThread*, std::__h::basic_string<char, std::__h::char_traits<char>, panda::ecmascript::CAddressAllocator<char>> const&, std::__h::basic_string_view<char, std::__h::char_traits<char>>)+772) (8ef042f942210dcf45c6431c798421b4)

#06 pc 00000000003f8c18 /system/lib64/libark_jsruntime.so(panda::JSNApi::ExecuteModuleBuffer(panda::ecmascript::EcmaVM*, unsigned char const*, int, std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, bool)+1288) (8ef042f942210dcf45c6431c798421b4)

#07 pc 000000000002701c /system/lib64/libace_napi_ark.z.so(ArkNativeEngineImpl::RunScriptBuffer(NativeEngine*, char const*, std::__h::vector<unsigned char, std::__h::allocator<unsigned char>>&)+508) (7af4ed93595e24f8e0baec676522c0b7)

#08 pc 000000000002f685 /system/lib64/libruntime.z.so (40486f61863ab50a1035bc4125c74cf9)

#09 pc 000000000002ddb9 /system/lib64/libruntime.z.so (40486f61863ab50a1035bc4125c74cf9)

#10 pc 000000000002f042 /system/lib64/libruntime.z.so (40486f61863ab50a1035bc4125c74cf9)

#11 pc 000000000002ab6a /system/lib64/libruntime.z.so(OHOS::AbilityRuntime::JsRuntime::LoadModule(std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const&, bool, bool)+1306) (40486f61863ab50a1035bc4125c74cf9)

#12 pc 000000000015df9f /system/lib64/libabilitykit_native.z.so(OHOS::AbilityRuntime::JsAbility::Init(std::__h::shared_ptr<OHOS::AppExecFwk::AbilityInfo> const&, std::__h::shared_ptr<OHOS::AppExecFwk::OHOSApplication>, std::__h::shared_ptr<OHOS::AppExecFwk::AbilityHandler>&, OHOS::sptr<OHOS::IRemoteObject> const&)+1023) (ba0d11cbf270f21fbbc085c80eaaa1be)

#13 pc 00000000001467c9 /system/lib64/libabilitykit_native.z.so(OHOS::AppExecFwk::AbilityImpl::Init(std::__h::shared_ptr<OHOS::AppExecFwk::OHOSApplication>&, std::__h::shared_ptr<OHOS::AppExecFwk::AbilityLocalRecord> const&, std::__h::shared_ptr<OHOS::AppExecFwk::Ability>&, std::__h::shared_ptr<OHOS::AppExecFwk::AbilityHandler>&, OHOS::sptr<OHOS::IRemoteObject> const&, std::__h::shared_ptr<OHOS::AppExecFwk::ContextDeal>&)+1145) (ba0d11cbf270f21fbbc085c80eaaa1be)

#14 pc 0000000000184a1c /system/lib64/libabilitykit_native.z.so(OHOS::AppExecFwk::AbilityThread::Attach(std::__h::shared_ptr<OHOS::AppExecFwk::OHOSApplication>&, std::__h::shared_ptr<OHOS::AppExecFwk::AbilityLocalRecord> const&, std::__h::shared_ptr<OHOS::AppExecFwk::EventRunner> const&, std::__h::shared_ptr<OHOS::AbilityRuntime::Context> const&)+1804) (ba0d11cbf270f21fbbc085c80eaaa1be)

#15 pc 000000000018b1ec /system/lib64/libabilitykit_native.z.so(OHOS::AppExecFwk::AbilityThread::AbilityThreadMain(std::__h::shared_ptr<OHOS::AppExecFwk::OHOSApplication>&, std::__h::shared_ptr<OHOS::AppExecFwk::AbilityLocalRecord> const&, std::__h::shared_ptr<OHOS::AppExecFwk::EventRunner> const&, std::__h::shared_ptr<OHOS::AbilityRuntime::Context> const&)+508) (ba0d11cbf270f21fbbc085c80eaaa1be)

#16 pc 00000000000845d9 /system/lib64/libappkit_native.z.so(OHOS::AppExecFwk::MainThread::HandleLaunchAbility(std::__h::shared_ptr<OHOS::AppExecFwk::AbilityLocalRecord> const&)+713) (94ca62b6337e500de1050d413f61e30c)

#17 pc 000000000009233b /system/lib64/libappkit_native.z.so (94ca62b6337e500de1050d413f61e30c)

#18 pc 0000000000010ca9 /system/lib64/platformsdk/libeventhandler.z.so(OHOS::AppExecFwk::EventHandler::DistributeEvent(std::__h::unique_ptr<OHOS::AppExecFwk::InnerEvent, void (*)(OHOS::AppExecFwk::InnerEvent*)> const&)+505) (6dd02bcdad70c6551a80ce5f415f6603)

#19 pc 000000000001ad52 /system/lib64/platformsdk/libeventhandler.z.so (6dd02bcdad70c6551a80ce5f415f6603)

#20 pc 00000000000196a8 /system/lib64/platformsdk/libeventhandler.z.so(OHOS::AppExecFwk::EventRunner::Run()+56) (6dd02bcdad70c6551a80ce5f415f6603)

#21 pc 0000000000087ce0 /system/lib64/libappkit_native.z.so(OHOS::AppExecFwk::MainThread::Start()+480) (94ca62b6337e500de1050d413f61e30c)

#22 pc 000000000001572c /system/bin/appspawn (2778b21557cf967b8bf23975a093a84f)

#23 pc 0000000000015825 /system/bin/appspawn (2778b21557cf967b8bf23975a093a84f)

#24 pc 0000000000014f7c /system/bin/appspawn (2778b21557cf967b8bf23975a093a84f)

#25 pc 000000000002c44a /system/lib64/libbegetutil.z.so (aa9b33d17515ab6026831e5e0aeb274f)

#26 pc 000000000002c173 /system/lib64/libbegetutil.z.so (aa9b33d17515ab6026831e5e0aeb274f)

#27 pc 0000000000029f85 /system/lib64/libbegetutil.z.so(ProcessEvent+85) (aa9b33d17515ab6026831e5e0aeb274f)

#28 pc 0000000000029af1 /system/lib64/libbegetutil.z.so (aa9b33d17515ab6026831e5e0aeb274f)

#29 pc 00000000000141e6 /system/bin/appspawn (2778b21557cf967b8bf23975a093a84f)

#30 pc 00000000000125ca /system/bin/appspawn (2778b21557cf967b8bf23975a093a84f)

#31 pc 0000000000090cf9 /vendor/aosp/system/lib64/libc.so(__libc_init+89) (2de37b8aa6e96dd64a6cfa51bd78ae6e)

更多关于AllocateBuffer:332 size must have a size bigger than 0 HarmonyOS 鸿蒙Next的实战教程也可以访问 https://www.itying.com/category-93-b0.html

4 回复

有大佬知道怎么解决吗?

更多关于AllocateBuffer:332 size must have a size bigger than 0 HarmonyOS 鸿蒙Next的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


也这样,就创建了一个hello world工程,你解决了吗。

我把项目删除,重新建了个项目就好了。

在鸿蒙Next系统中,AllocateBuffer:332 size must have a size bigger than 0 错误提示表明在分配缓冲区时,传入的大小参数必须大于0。这通常发生在开发者调用相关API时,传入的缓冲区大小为0或负数,导致系统无法正确分配内存。

鸿蒙Next系统在内存管理方面有严格的检查机制,确保资源的合理分配和使用。当调用AllocateBuffer等类似函数时,系统会验证传入的大小参数,如果不符合要求,就会抛出该错误。

要解决此问题,开发者需确保在调用AllocateBuffer函数时,传入的大小参数为正整数。可以检查调用该函数的代码逻辑,确保在分配缓冲区之前,大小参数已经正确计算和验证。

此外,鸿蒙Next系统提供了一系列内存管理API,开发者应按照官方文档的指导,正确使用这些API,避免类似错误的发生。

回到顶部