Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failures on big endian #36

Closed
nijel opened this issue Nov 8, 2017 · 6 comments
Closed

Test failures on big endian #36

nijel opened this issue Nov 8, 2017 · 6 comments

Comments

@nijel
Copy link
Contributor

nijel commented Nov 8, 2017

Both fail with:

sdcv: /<<PKGBUILDDIR>>/src/stardict_lib.cpp:542: const gchar* {anonymous}::OffsetIndex::read_first_on_page_key(glong): Assertion `(nitems == 1)' failed.

Problematic code:

sdcv/src/stardict_lib.cpp

Lines 535 to 545 in 925a4bc

inline const gchar *OffsetIndex::read_first_on_page_key(glong page_idx)
{
fseek(idxfile, wordoffset[page_idx], SEEK_SET);
guint32 page_size = wordoffset[page_idx + 1] - wordoffset[page_idx];
const size_t nitems = fread(wordentry_buf,
std::min(sizeof(wordentry_buf), static_cast<size_t>(page_size)),
1, idxfile);
THROW_IF_ERROR(nitems == 1);
//TODO: check returned values, deal with word entry that strlen>255.
return wordentry_buf;
}

@nijel nijel changed the title Test failures on s390x and mips Test failures on s390x, powerpc and mips Nov 8, 2017
@Dushistov
Copy link
Owner

Thanks for info @nijel , can you run t_json test on one of this architecture with this patch?:

diff --git a/src/stardict_lib.cpp b/src/stardict_lib.cpp
index 63e23f5..7f222fd 100644
--- a/src/stardict_lib.cpp
+++ b/src/stardict_lib.cpp
@@ -539,6 +539,7 @@ inline const gchar *OffsetIndex::read_first_on_page_key(glong page_idx)
     const size_t nitems = fread(wordentry_buf,
                                 std::min(sizeof(wordentry_buf), static_cast<size_t>(page_size)),
                                 1, idxfile);
+    fprintf(stderr, "%p %lld %llu %zu %p %zu\n", idxfile, (long long)page_idx, (long long unsigned)page_size, nitems, wordentry_buf, sizeof(wordentry_buf));
     THROW_IF_ERROR(nitems == 1);
     //TODO: check returned values, deal with word entry that strlen>255.
     return wordentry_buf;

@nijel
Copy link
Contributor Author

nijel commented Nov 8, 2017

Probably yes, I will look into this next week.

@nijel nijel changed the title Test failures on s390x, powerpc and mips Test failures on big endian Nov 9, 2017
@nijel
Copy link
Contributor Author

nijel commented Nov 14, 2017

From the gdb session:

(gdb) print page_idx
$3 = 0
(gdb) print idxfile 
$4 = (FILE *) 0x200a5140
(gdb) print page_size
$5 = 385875968
(gdb) print nitems
$6 = 0
(gdb) print wordentry_buf
$7 = "\321\207\320\265\320\273\320\276\320\262\320\265\320\272\000\000\000\000\000\000\000\000\031", '\000' <repeats 240 times>
(gdb) print sizeof(wordentry_buf)
$9 = 264

IMHO it seems that page_size is wrong...

@nijel
Copy link
Contributor Author

nijel commented Nov 14, 2017

The problem is in cache loading, following workaround works:

diff --git a/src/stardict_lib.cpp b/src/stardict_lib.cpp
index 63e23f5..1c91fe3 100644
--- a/src/stardict_lib.cpp
+++ b/src/stardict_lib.cpp
@@ -561,6 +561,7 @@ inline const gchar *OffsetIndex::get_first_on_page_key(glong page_idx)
 bool OffsetIndex::load_cache(const std::string &url)
 {
     const std::list<std::string> vars = get_cache_variant(url);
+    return false;
 
     for (const std::string &item : vars) {
         struct ::stat idxstat, cachestat;

@nijel
Copy link
Contributor Author

nijel commented Nov 14, 2017

Okay the problem is that the cache loading code doesn't detect as invalid caches created on other architecture and testsuite ships tests/rus-eng-stardict-2.4.2/1.xdxf.idx.oft created on little endian machine. This leads to loading wrong offsets.

@nijel
Copy link
Contributor Author

nijel commented Nov 14, 2017

Should be fixed by #38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants