Linux bcopy() requires word aligned memory, use memcpy()
Much to my surprise bcopy() under Linux appears to copy the data in word sized chunks. It does the right thing but if you buffer is not a multiple of the word size you will be reading past the end of your buffer. Or at least that is what valgrind is reporting. We should be using mempcy() anyway on Linux so replace bcopy() with memcpy() to resolve the issue. ==305== Thread 211: ==305== Invalid read of size 8 ==305== at 0x3BCD28357D: _wordcopy_fwd_dest_aligned (in /lib64/libc-2.11.1.so) ==305== by 0x3BCD282B05: bcopy (in /lib64/libc-2.11.1.so) ==305== by 0x58D7FEF: dmu_write (dmu.c:730) ==305== by 0x591C942: spa_history_write (spa_history.c:165) ==305== by 0x591D255: spa_history_log_sync (spa_history.c:277) ==305== by 0x591D545: log_internal (spa_history.c:450) ==305== by 0x591D5EC: spa_history_log_internal (spa_history.c:475) ==305== by 0x5902319: dsl_prop_set_sync (dsl_prop.c:707) ==305== by 0x5906A7D: dsl_sync_task_group_sync (dsl_synctask.c:199) ==305== by 0x58FF4EC: dsl_pool_sync (dsl_pool.c:376) ==305== by 0x591744C: spa_sync (spa.c:5365) ==305== by 0x5922C85: txg_sync_thread (txg.c:414)
This commit is contained in:
parent
a6411d4033
commit
f32ec2346b
|
@ -727,7 +727,7 @@ dmu_write(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
|
||||||
else
|
else
|
||||||
dmu_buf_will_dirty(db, tx);
|
dmu_buf_will_dirty(db, tx);
|
||||||
|
|
||||||
bcopy(buf, (char *)db->db_data + bufoff, tocpy);
|
(void) memcpy((char *)db->db_data + bufoff, buf, tocpy);
|
||||||
|
|
||||||
if (tocpy == db->db_size)
|
if (tocpy == db->db_size)
|
||||||
dmu_buf_fill_done(db, tx);
|
dmu_buf_fill_done(db, tx);
|
||||||
|
|
Loading…
Reference in New Issue