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

Fix unaligned access in get_unigram_frequency() #152

Closed
wants to merge 1 commit into from
Closed

Fix unaligned access in get_unigram_frequency() #152

wants to merge 1 commit into from

Conversation

AdrianBunk
Copy link

In Debian the testsuite of fcitx5-zhuyin failed on 32-bit ARM
runnning on 64-bit hardware:
https://buildd.debian.org/status/fetch.php?pkg=fcitx5-zhuyin&arch=armhf&ver=5.0.8-1&stamp=1657997016&raw=0

Backtrace:

#0  0xf7a1cd64 in pinyin::PhraseItem::get_unigram_frequency (this=0x1d78364)
    at ../src/storage/phrase_index.h:125
#1  pinyin::PhoneticLookup<1, 1>::unigram_gen_next_step (token=16777669, 
    cur_step=0x1d78c78, end=3, start=0, this=0x1d78358)
    at ../src/lookup/phonetic_lookup.h:649
#2  pinyin::PhoneticLookup<1, 1>::search_unigram2 (this=this@entry=0x1d78358, 
    topresults=topresults@entry=0x1d5f850, start=start@entry=0, 
    end=end@entry=3, ranges=ranges@entry=0xffc7fa2c)
    at ../src/lookup/phonetic_lookup.h:567
#3  0xf7a1d406 in pinyin::PhoneticLookup<1, 1>::get_nbest_match (
    this=0x1d78358, prefixes=<optimized out>, matrix=matrix@entry=0x1d785f0, 
    constraints=<optimized out>, results=results@entry=0x1d78600)
    at ../src/lookup/phonetic_lookup.h:809
#4  0xf7a1b8e8 in zhuyin_guess_sentence (instance=0x1d785e8) at zhuyin.cpp:904
#5  0x008bfda4 in fcitx::ZhuyinSection::typeImpl (this=0x1d78568, 
    s=<optimized out>, length=<optimized out>)
    at /usr/include/c++/11/bits/unique_ptr.h:173
#6  0xf7a93abe in fcitx::InputBuffer::type(unsigned int) ()
   from /usr/lib/arm-linux-gnueabihf/libFcitx5Utils.so.2
#7  0x008bd7a4 in fcitx::ZhuyinBuffer::type (this=this@entry=0xffc7fb54, 
    c=<optimized out>, c@entry=32) at ./src/zhuyinbuffer.cpp:90
#8  0x008bbc82 in test_basic () at ./test/testzhuyinbuffer.cpp:41
#9  0x008bccda in main () at ./test/testzhuyinbuffer.cpp:167

The problem was the unaligned access, memcpy() the data instead.

In Debian the testsuite of fcitx5-zhuyin failed on 32-bit ARM
runnning on 64-bit hardware:
https://buildd.debian.org/status/fetch.php?pkg=fcitx5-zhuyin&arch=armhf&ver=5.0.8-1&stamp=1657997016&raw=0

The problem was the unaligned access, memcpy() the data instead.
@epico
Copy link
Member

epico commented Jul 18, 2022

Does this issue also happen with the ibus-libzhuyin project?

@epico
Copy link
Member

epico commented Jul 18, 2022

Maybe I can write more test cases in libpinyin.

@AdrianBunk
Copy link
Author

Does this issue also happen with the ibus-libzhuyin project?

ibus-libzhuyin does not have tests that run at build time.

@epico
Copy link
Member

epico commented Jul 27, 2022

Maybe you can apply this patch only on armhf architecture.

I think the following code maybe better:

        guint32 retval = 0;
        m_chunk.get_content(sizeof(guint8) + sizeof(guint8), &retval,
                            sizeof(guint32));
        return retval;

@epico
Copy link
Member

epico commented Jan 19, 2023

Thanks, I merged #155 .

Close this pull request now.

@epico epico closed this Jan 19, 2023
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

Successfully merging this pull request may close these issues.

None yet

2 participants