我在使用rrdtool(版本1.4.8)在我的系统上创建数据库时遇到问题(x86_64 CentOS 4.1,内核2.6.18.128和ext3文件系统类型)。
我尝试运行一个简单的命令来创建一个数据库,如this教程所示,但是我收到一个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
这里有什么问题,我该如何解决?
答案 0 :(得分: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
}