错误malloc.c:2406:sysmalloc:使用RTIMU库时断言

时间:2019-05-08 19:47:24

标签: c++ raspberry-pi raspberry-pi3 raspbian

我对软件非常陌生,遇到了从未见过的错误。

untitled: malloc.c:2406: sysmalloc: Assertion `(old_top == initial_top (av) 
&& old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse 
(old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.

我不知道是什么原因导致此错误,因此我尝试查找文件在Raspberry Pi上的存储位置,但没有结果。

我在互联网上进行了检查,只发现有人说我尝试使用-fsanitize=address,但没有成功。这次尝试给了我一个新的错误==1167==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.

我选择重建文件以删除该更改,并返回到第一个错误。

很抱歉,该软件有多混乱,我不喜欢删除代码,所以我将其注释掉,直到整个项目正常工作为止,

#include <iostream>
#include <wiringPi.h>
#include <stdio.h>
#include <softPwm.h>
#include <math.h>
#include <stdint.h>
#include <unistd.h>
#include <pid.h>
#include <pid.cpp>
#include <RTIMULib/RTIMULib/RTIMULib.h>

using namespace std;

class PID;
class RTIMUSettings;

PID leftMotorPID = PID{50.0, 100.0, 0.0, 1.0, 1.0, 1.0};
PID rightMotorPID = PID{50.0, 100.0, 0.0, 1.0, 1.0, 1.0};

RTIMUSettings *settings = new RTIMUSettings("mpu9150");
RTIMU *imu = RTIMU::createIMU(settings);

double speedLeft = 14;
double speedRight = 14;

int main()
{
    int sampleCount = 0;
    int sampleRate = 0;
    uint64_t rateTimer;
    uint64_t displayTimer;
    uint64_t now;
    wiringPiSetupGpio();
    pinMode(21, PWM_OUTPUT);
    pinMode(22, PWM_OUTPUT);
    softPwmCreate (21, 14, 100);
    softPwmCreate (22, 14, 100);
    if (imu == NULL) {
        printf("No IMU found\n");
        exit(1);
    }

    imu->IMUInit();

     rateTimer = displayTimer = RTMath::currentUSecsSinceEpoch();

    //  now just process data

    while (1) {
        //  poll at the rate recommended by the IMU

        usleep(imu->IMUGetPollInterval() * 1000);

        while (imu->IMURead()) {
            RTIMU_DATA imuData = imu->getIMUData();
            sampleCount++;

            now = RTMath::currentUSecsSinceEpoch();

            //  display 10 times per second

            if ((now - displayTimer) > 10000) {
                printf("Sample rate %d: %s\r", sampleRate, RTMath::displayDegrees("", imuData.fusionPose));
                displayTimer = now;
            }

            //  update rate every second

            if ((now - rateTimer) > 1000000) {
                sampleRate = sampleCount;
                sampleCount = 0;
                rateTimer = now;
            }
        }
    }

    while (1 == 1){
//      cout << "speedLeft";
//      cin >> speedLeft;
//      cout << "speedRight";
//      cin >> speedRight;
        softPwmWrite(21, speedLeft);
        softPwmWrite(22, speedRight);

        delay(100);
    }
    return 0;
}

该代码仅应从我的检测帽读取值,并允许我更改GPIO引脚的输出。它过去已经可以构建,但现在已经不行了。

编辑:我收到了一些评论,将我链接到另一篇文章。当我尝试使用valgrind时,它说有==1195== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 3)

我可能误读了这篇文章,但从我的看到,我认为我不是。我尝试使用fsanitize=address,但这只给了我先前引用的新错误。

0 个答案:

没有答案