Compare commits

..

6 Commits

Author SHA1 Message Date
openharmony_ci
1eb753cd25 !1075 【挑单】time相关系统调用内核栈信息泄露排查
Merge pull request !1075 from zhushengle/OpenHarmony_1.0.1_release
2022-11-23 08:14:13 +00:00
zhushengle
19769f795b fix: time相关系统调用内核栈信息泄露排查
Close #I620AB
Signed-off-by: zhushengle <zhushengle@huawei.com>
2022-11-19 11:26:04 +08:00
openharmony_ci
5b44332cff !642 解决release1.0.1分支内核关闭中断后在写BUFF满了后卡住问题
Merge pull request !642 from wanghao-free/OpenHarmony_1.0.1_release
2021-09-30 01:56:11 +00:00
wanghao-free
0d50fad855 fix:解决release1.0.1分支内核关闭中断后在写BUFF满了后卡住问题
主干存在该问题,release分支先合入

添加cnt==0以及关中断的判断条件,在符合这种情况时跳出死循环,避免卡住

Signed-off-by: wanghao-free <wanghao453@huawei.com>
2021-09-28 20:10:13 -07:00
openharmony_ci
a37c850d1b !622 解决OsLockDepCheckIn异常处理中存在锁嵌套调用 导致死锁异常信息不正常输出问题
Merge pull request !622 from wanghao-free/OpenHarmony_1.0.1_release
2021-09-22 06:50:00 +00:00
wanghao-free
1eca7a502a fix: 解决OsLockDepCheckIn异常处理中存在锁嵌套调用
导致死锁异常信息不正常输出问题

主干存在该问题,修改同步release分支

新增加异常信息打印输出函数,用局部数组保存输出信息,避免锁嵌套问题

Close #I457ZZ

Signed-off-by: wanghao-free <wanghao453@huawei.com>
2021-09-14 23:35:56 -07:00
3 changed files with 58 additions and 30 deletions

View File

@@ -44,6 +44,8 @@ extern "C" {
#if (LOSCFG_KERNEL_SMP_LOCKDEP == YES)
#define PRINT_BUF_SIZE 256
#define LOCKDEP_GET_NAME(lockDep, index) (((SPIN_LOCK_S *)((lockDep)->heldLocks[(index)].lockPtr))->name)
#define LOCKDEP_GET_ADDR(lockDep, index) ((lockDep)->heldLocks[(index)].lockAddr)
@@ -107,6 +109,31 @@ WEAK VOID OsLockDepPanic(enum LockDepErrType errType)
while (1) {}
}
STATIC VOID OsLockDepPrint(const CHAR *fmt, va_list ap)
{
UINT32 len;
CHAR buf[PRINT_BUF_SIZE] = {0};
len = vsnprintf_s(buf, PRINT_BUF_SIZE, PRINT_BUF_SIZE - 1, fmt, ap);
if ((len == -1) && (*buf == '\0')) {
/* parameter is illegal or some features in fmt dont support */
UartPuts("OsLockDepPrint is error\n", strlen("OsLockDepPrint is error\n") + 1, 0);
return;
}
*(buf + len) = '\0';
UartPuts(buf, len, 0);
}
STATIC VOID OsPrintLockDepInfo(const CHAR *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
OsLockDepPrint(fmt, ap);
va_end(ap);
}
STATIC VOID OsLockDepDumpLock(const LosTaskCB *task, const SPIN_LOCK_S *lock,
const VOID *requestAddr, enum LockDepErrType errType)
{
@@ -114,24 +141,24 @@ STATIC VOID OsLockDepDumpLock(const LosTaskCB *task, const SPIN_LOCK_S *lock,
const LockDep *lockDep = &task->lockDep;
const LosTaskCB *temp = task;
PrintExcInfo("lockdep check failed\n");
PrintExcInfo("error type : %s\n", OsLockDepErrorStringGet(errType));
PrintExcInfo("request addr : 0x%x\n", requestAddr);
OsPrintLockDepInfo("lockdep check failed\n");
OsPrintLockDepInfo("error type : %s\n", OsLockDepErrorStringGet(errType));
OsPrintLockDepInfo("request addr : 0x%x\n", requestAddr);
while (1) {
PrintExcInfo("task name : %s\n", temp->taskName);
PrintExcInfo("task id : %u\n", temp->taskID);
PrintExcInfo("cpu num : %u\n", temp->currCpu);
PrintExcInfo("start dumping lockdep infomation\n");
OsPrintLockDepInfo("task name : %s\n", temp->taskName);
OsPrintLockDepInfo("task id : %u\n", temp->taskID);
OsPrintLockDepInfo("cpu num : %u\n", temp->currCpu);
OsPrintLockDepInfo("start dumping lockdep infomation\n");
for (i = 0; i < lockDep->lockDepth; i++) {
if (lockDep->heldLocks[i].lockPtr == lock) {
PrintExcInfo("[%d] %s <-- addr:0x%x\n", i, LOCKDEP_GET_NAME(lockDep, i),
OsPrintLockDepInfo("[%d] %s <-- addr:0x%x\n", i, LOCKDEP_GET_NAME(lockDep, i),
LOCKDEP_GET_ADDR(lockDep, i));
} else {
PrintExcInfo("[%d] %s \n", i, LOCKDEP_GET_NAME(lockDep, i));
OsPrintLockDepInfo("[%d] %s \n", i, LOCKDEP_GET_NAME(lockDep, i));
}
}
PrintExcInfo("[%d] %s <-- now\n", i, lock->name);
OsPrintLockDepInfo("[%d] %s <-- now\n", i, lock->name);
if (errType == LOCKDEP_ERR_DEAD_LOCK) {
temp = lock->owner;
@@ -144,7 +171,6 @@ STATIC VOID OsLockDepDumpLock(const LosTaskCB *task, const SPIN_LOCK_S *lock,
}
}
OsLockDepPanic(errType);
}
STATIC BOOL OsLockDepCheckDependancy(const LosTaskCB *current, LosTaskCB *lockOwner)
@@ -172,7 +198,7 @@ VOID OsLockDepCheckIn(SPIN_LOCK_S *lock)
{
UINT32 intSave;
enum LockDepErrType checkResult = LOCKDEP_SUCEESS;
VOID *requestAddr = (VOID *)__builtin_return_address(0);
VOID *requestAddr = (VOID *)__builtin_return_address(1);
LosTaskCB *current = OsCurrTaskGet();
LockDep *lockDep = &current->lockDep;
LosTaskCB *lockOwner = NULL;
@@ -211,11 +237,12 @@ OUT:
lockDep->waitLock = lock;
lockDep->heldLocks[lockDep->lockDepth].lockAddr = requestAddr;
lockDep->heldLocks[lockDep->lockDepth].waitTime = OsLockDepGetCycles(); /* start time */
} else {
OsLockDepDumpLock(current, lock, requestAddr, checkResult);
OsLockDepRelease(intSave);
return;
}
OsLockDepDumpLock(current, lock, requestAddr, checkResult);
OsLockDepRelease(intSave);
OsLockDepPanic(checkResult);
}
VOID OsLockDepRecord(SPIN_LOCK_S *lock)
@@ -253,7 +280,7 @@ VOID OsLockDepCheckOut(SPIN_LOCK_S *lock)
UINT32 intSave;
INT32 depth;
enum LockDepErrType checkResult = LOCKDEP_SUCEESS;
VOID *requestAddr = (VOID *)__builtin_return_address(0);
VOID *requestAddr = (VOID *)__builtin_return_address(1);
LosTaskCB *current = OsCurrTaskGet();
LosTaskCB *owner = NULL;
LockDep *lockDep = NULL;
@@ -265,7 +292,8 @@ VOID OsLockDepCheckOut(SPIN_LOCK_S *lock)
if (owner == SPINLOCK_OWNER_INIT) {
checkResult = LOCKDEP_ERR_UNLOCK_WITOUT_LOCK;
OsLockDepDumpLock(current, lock, requestAddr, checkResult);
goto OUT;
OsLockDepRelease(intSave);
OsLockDepPanic(checkResult);
}
lockDep = &owner->lockDep;
@@ -294,7 +322,6 @@ VOID OsLockDepCheckOut(SPIN_LOCK_S *lock)
lock->cpuid = (UINT32)(-1);
lock->owner = SPINLOCK_OWNER_INIT;
OUT:
OsLockDepRelease(intSave);
}

View File

@@ -98,7 +98,7 @@ STATIC VOID ConsoleOutput(const CHAR *str, UINT32 len)
for (;;) {
cnt = write(STDOUT_FILENO, str + writen, (size_t)toWrite);
if ((cnt < 0) || (toWrite == cnt)) {
if ((cnt < 0) || ((cnt == 0) && OS_INT_ACTIVE) || (toWrite == cnt)) {
break;
}
writen += cnt;

View File

@@ -108,7 +108,7 @@ int SysSetiTimer(int which, const struct itimerval *value, struct itimerval *ova
{
int ret;
struct itimerval svalue;
struct itimerval sovalue;
struct itimerval sovalue = { 0 };
if (value == NULL) {
errno = EINVAL;
@@ -136,7 +136,7 @@ int SysSetiTimer(int which, const struct itimerval *value, struct itimerval *ova
int SysGetiTimer(int which, struct itimerval *value)
{
int ret;
struct itimerval svalue;
struct itimerval svalue = { 0 };
if (value == NULL) {
errno = EINVAL;
@@ -188,7 +188,7 @@ int SysTimerCreate(clockid_t clockID, struct sigevent *evp, timer_t *timerID)
int SysTimerGettime(timer_t timerID, struct itimerspec *value)
{
int ret;
struct itimerspec svalue;
struct itimerspec svalue = { 0 };
if (value == NULL) {
errno = EINVAL;
@@ -212,7 +212,7 @@ int SysTimerSettime(timer_t timerID, int flags, const struct itimerspec *value,
{
int ret;
struct itimerspec svalue;
struct itimerspec soldValue;
struct itimerspec soldValue = { 0 };
if (value == NULL) {
errno = EINVAL;
@@ -284,7 +284,7 @@ int SysClockSettime(clockid_t clockID, const struct timespec *tp)
int SysClockGettime(clockid_t clockID, struct timespec *tp)
{
int ret;
struct timespec stp;
struct timespec stp = { 0 };
if (tp == NULL) {
errno = EINVAL;
@@ -307,7 +307,7 @@ int SysClockGettime(clockid_t clockID, struct timespec *tp)
int SysClockGetres(clockid_t clockID, struct timespec *tp)
{
int ret;
struct timespec stp;
struct timespec stp = { 0 };
if (tp == NULL) {
errno = EINVAL;
@@ -355,7 +355,7 @@ int SysNanoSleep(const struct timespec *rqtp, struct timespec *rmtp)
{
int ret;
struct timespec srqtp;
struct timespec srmtp;
struct timespec srmtp = { 0 };
if (!rqtp || LOS_ArchCopyFromUser(&srqtp, rqtp, sizeof(struct timespec))) {
errno = EFAULT;
@@ -383,7 +383,7 @@ int SysNanoSleep(const struct timespec *rqtp, struct timespec *rmtp)
clock_t SysTimes(struct tms *buf)
{
clock_t ret;
struct tms sbuf;
struct tms sbuf = { 0 };
if (buf == NULL) {
errno = EFAULT;
@@ -435,7 +435,7 @@ int SysClockGettime64(clockid_t clockID, struct timespec64 *tp)
{
int ret;
struct timespec t;
struct timespec64 stp;
struct timespec64 stp = { 0 };
if (tp == NULL) {
errno = EINVAL;
@@ -462,7 +462,7 @@ int SysClockGetres64(clockid_t clockID, struct timespec64 *tp)
{
int ret;
struct timespec t;
struct timespec64 stp;
struct timespec64 stp = { 0 };
if (tp == NULL) {
errno = EINVAL;
@@ -524,7 +524,7 @@ int SysTimerGettime64(timer_t timerID, struct itimerspec64 *value)
{
int ret;
struct itimerspec val;
struct itimerspec64 svalue;
struct itimerspec64 svalue = { 0 };
if (value == NULL) {
errno = EINVAL;
@@ -583,6 +583,7 @@ int SysTimerSettime64(timer_t timerID, int flags, const struct itimerspec64 *val
}
if (oldValue != NULL) {
(void)memset_s(&soldValue, sizeof(struct itimerspec64), 0, sizeof(struct itimerspec64));
soldValue.it_interval.tv_sec = oldVal.it_interval.tv_sec;
soldValue.it_interval.tv_nsec = oldVal.it_interval.tv_nsec;
soldValue.it_value.tv_sec = oldVal.it_value.tv_sec;