mtd-utils 1:2.1.6-1build1 FTBFS
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
mtd-utils (Debian) |
Fix Released
|
Unknown
|
|||
mtd-utils (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
mtd-utils 1:2.1.6-1build1 fails to build from source due to one missing test case:
```
[ RUN ] test_mtd_read
libmtd: error!: cannot read 28 bytes from mtd0 (eraseblock 224, offset 43)
error 9 (Bad file descriptor)
[ ERROR ] --- 0xffffffffffffffff != 0
[ LINE ] --- tests/unittests
[ FAILED ] test_mtd_read
```
The test function:
```
static void test_mtd_read(void **state)
{
int mock_fd = 4;
int eb = 0xE0;
int offs = 43;
int len = 28;
off_t seek;
char buf[28];
struct mtd_dev_info mtd;
memset(&mtd, 0, sizeof(mtd));
mtd.bb_allowed = 1;
mtd.eb_cnt = 1024;
mtd.eb_size = 128;
seek = (off_t)eb * mtd.eb_size + offs;
expect_lseek(seek, SEEK_SET, seek);
expect_read(len, len);
int r = mtd_read(&mtd, mock_fd, eb, offs, &buf, len);
assert_
(void) state;
}
```
The failure is in `mtd_read`:
```
ret = read(fd, buf + rd, len - rd);
```
The failure is reproducible (locally).
description: | updated |
description: | updated |
Changed in mtd-utils (Debian): | |
status: | Unknown → New |
Changed in mtd-utils (Debian): | |
status: | New → Fix Released |
Its trying to call the real read() instead of the __wrap_read() even though --wrap=read was passed to the linker. Seems like the linker is ignoring --wrap=read if LTO is enabled.
The attached debdiff is a quick fix for Noble. No need to add to lto-disabled-list, as only the test is building linking with --wrap=read. But I have not forwarded the bug upstream as I am not sure if this should be a gcc bug or a bug in mtd-utils. If gcc ignores --wrap=read with LTO enabled then imho, it should be a gcc bug.
A build with this change can be seen at https:/ /launchpad. net/~sudipmuk/ +archive/ ubuntu/ mtd-utils/ +build/ 28026320