0

我在让 rrdtool(版本 1.4.8)在我的系统(x86_64 CentOS 4.1、内核 2.6.18.128 和 ext3 文件系统类型)上创建数据库时遇到问题。

我尝试运行一个简单的命令来创建本教程所示的数据库,但我收到一个 SIGBUS 错误,它似乎与 memcpy() 有关。我在下面展示了来自 gdb 的回溯。

(gdb) run create test.rrd --start 920804400 DS:speed:COUNTER:600:U:U RRA:AVERAGE:0.5:1:24 RRA:AVERAGE:0.5:6:10
Starting program: rrdtool-1.4.8/src/.libs/rrdtool create test.rrd --start 920804400 DS:speed:COUNTER:600:U:U RRA:AVERAGE:0.5:1:24 RRA:AVERAGE:0.5:6:10
(no debugging symbols found)

Program received signal SIGBUS, Bus error.
0x00002acb298da7d3 in memcpy () from /lib64/tls/libc.so.6
(gdb) bt
#0  0x00002b46e74ae7d3 in memcpy () from /lib64/tls/libc.so.6
#1  0x00002b46e731d612 in rrd_write (rrd_file=0x1c46e230, buf=0x1c46e0a0, count=128) at rrd_open.c:716
#2  0x00002b46e731515e in rrd_create_fn (file_name=0x7fffc38b9a3f "test.rrd", rrd=0x7fffc38b8b60) at rrd_create.c:727
#3  0x00002b46e7314a28 in rrd_create_r (filename=0x7fffc38b9a3f "test.rrd", pdp_step=300, last_up=920804400, argc=3, argv=0x7fffc38b9070) at rrd_create.c:580
#4  0x00002b46e731330e in rrd_create (argc=7, argv=0x7fffc38b9050) at rrd_create.c:113
#5  0x00000000004028db in HandleInputLine (argc=8, argv=0x7fffc38b9048, out=0x2b46e766a680) at rrd_tool.c:646
#6  0x00000000004023a2 in main (argc=8, argv=0x7fffc38b9048) at rrd_tool.c:521
(gdb) up
#1  0x00002b46e731d612 in rrd_write (rrd_file=0x1c46e230, buf=0x1c46e0a0, count=128) at rrd_open.c:716
716     memcpy(rrd_simple_file->file_start + rrd_file->pos, buf, count);
(gdb) p rrd_file->pos
$21 = 0
(gdb) p (char *)buf
$25 = 0x1c46e0a0 "RRD"
(gdb) p rrd_simple_file->file_start
$22 = 0x2b46ea64b000 "RRD"
(gdb) p count
$23 = 128

这里有什么问题,我该如何解决?

4

1 回答 1

1

这个问题可能与您的旧 Centos 发行版的一些mmap错误有关。
如果升级到较新版本不是一个选项,您可以尝试rrdtool使用以下选项编译您的:

./configure --disable-mmap

通过这样做,函数memcpy中第 716 行的错误rrd_write()(如下所示)不应该被执行:

/* Write count bytes from buffer buf to the current position
 * rrd_file->pos of rrd_simple_file->fd.
 * Returns the number of bytes written or <0 on error.  */

ssize_t rrd_write(
    rrd_file_t *rrd_file,
    const void *buf,
    size_t count)
{
    rrd_simple_file_t *rrd_simple_file = (rrd_simple_file_t *)rrd_file->pvt;
#ifdef HAVE_MMAP
    size_t old_size = rrd_file->file_len;
    if (count == 0)
        return 0;
    if (buf == NULL)
        return -1;      /* EINVAL */

    if((rrd_file->pos + count) > old_size)
    {
        rrd_set_error("attempting to write beyond end of file");
        return -1;
    }
    memcpy(rrd_simple_file->file_start + rrd_file->pos, buf, count);
    rrd_file->pos += count;
    return count;       /* mimmic write() semantics */
#else
    ssize_t   _sz = write(rrd_simple_file->fd, buf, count);

    if (_sz > 0)
        rrd_file->pos += _sz;
    return _sz;
#endif
}
于 2013-09-23T19:54:14.227 回答