Comments (4)
您是实际遇到过因为这样hardfault的情况吗?能否提供问题复现的场景?
from tobudos.
您好,我是在实际项目中遇到的这个问题。场景如下:
在at_parser
任务中释放了at_echo->__expect_notify
信号量,并且在at_echo_buffer_copy
之前发生了任务调度,任务切换到了tos_at_cmd_exec_until
中,成功获取了echo->__expect_notify
信号量,随后执行了AT_AGENT->echo = K_NULL;
,等任务再切换回at_parser
时,at_echo
已经为空,此时再拷贝就会出现hardfault。
将拷贝放到释放信号之前则不会出现该问题。
__STATIC__ void at_parser(void *arg)
{
...
if (at_parse_status == AT_PARSE_STATUS_EXPECT) {
at_echo->status = AT_ECHO_STATUS_EXPECT;
if (at_echo->__is_expecting) {
tos_sem_post(&at_echo->__expect_notify);
}
} else if (at_parse_status == AT_PARSE_STATUS_NEWLINE &&
at_echo->status == AT_ECHO_STATUS_NONE) {
at_echo_status_set(at_echo);
}
if (at_echo->buffer) {
at_echo_buffer_copy(recv_cache, at_echo);
}
...
}
__API__ int tos_at_cmd_exec_until(at_echo_t *echo, uint32_t timeout, const char *cmd, ...)
{
...
if (ret != 0) {
AT_AGENT->echo = K_NULL;
return -1;
}
if (tos_sem_pend(&echo->__expect_notify, tos_millisec2tick(timeout)) != K_ERR_NONE) {
ret = -1;
}
tos_sem_destroy(&echo->__expect_notify);
AT_AGENT->echo = K_NULL;
return ret;
}
from tobudos.
这确实是一个问题,我提交一个bugfix。您那边可以暂时先把语句顺序调换一下,copy动作放到sem_post之前,应该可以规避这个问题。
from tobudos.
我提问下,
tos_at_cmd_exec_until 和 at_parser 是两个不同的任务在同时操作 echo,如果 tos_at_cmd_exec_until 执行 tos_sem_pend超时,AT_AGENT->echo 直接被清空,如果这时候执行到 at_parser 对AT_AGENT->echode 操作,应该也会生成一个hardfault,
发生的条件需要执行到 if (!at_echo) 判断后,进行了tos_sem_pend超时引起的任务切换 AT_AGENT->echo被清空;
对于 if (!at_echo) 后的对于echo的操作需要原子保护
from tobudos.
Related Issues (20)
- TentcentOS是否支持15.4或ble通信
- 在nrf52840上开发TencentOS HOT 1
- 请问OTA是否只能差分升级,可以全量包升级吗 HOT 1
- 建议内核类型中新增布尔类型定义k_bool_t HOT 1
- explorer sdk中单个事件的json不对 HOT 1
- 在使用tickless时,发生了其他中断如何做时间补偿
- tos_vfs_readdir代码有错误
- KV组件在设备上跑了半个月,偶现bug需check HOT 1
- tos_fault.c 编译出错 HOT 2
- 关于TencentOS-tiny ota_diff ring =1 时的patch_test 错误 HOT 1
- TencentOS Tiny 捐赠开放原子开源基金会后第一次导师会议纪要
- cortex-m0+ 是arm-v6m架构但被分在了arm-v7m里
- 接收的消息同时含有期望的字符串和“OK”时,at_echo->__expect_notify还没来得及获取,at_echo->status = AT_ECHO_STATUS_EXPECT;就立马有被任务“at_parser”更新成at_echo->status = AT_ECHO_STATUS_OK; HOT 3
- NUCLEO-H723ZG调用osDelay()会进入HardFault_Handler() HOT 3
- SAL层的AT架构好像不是线程安全的 HOT 2
- 是否有关于TencentOS-tiny较为完善的Log系统设计需求 HOT 1
- Driver_USBH.c文件中有大量函数为空,疑似缺失漏写,是否需要完善? HOT 1
- Tencentos-tiny是否支持C++ HOT 1
- How can I build a system with GUI and other kinds of senor, please tell me.
- 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tobudos.