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

OpenFEC fails to perform on 32bit platforms #60

Closed
baranovmv opened this issue May 14, 2016 · 6 comments
Closed

OpenFEC fails to perform on 32bit platforms #60

baranovmv opened this issue May 14, 2016 · 6 comments
Assignees
Labels
defect Something isn't working portability
Milestone

Comments

@baranovmv
Copy link
Member

baranovmv commented May 14, 2016

In case of compiling OpenFEC with -m32 flag or compiling and calling on ARM tests fail.
The issue is in file of_symbol.c in symbols arithmetic operations.

==29720== Memcheck, a memory error detector
==29720== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==29720== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==29720== Command: ./eperftool -codec=3 -seed=1 -find_min_overhead -tot_src=39 -tot_rep=23
==29720== 
./eperftooleperf_tool: an extended AL-FEC performance evaluation tool
OpenFEC.org - Version 1.4.2, December 16th, 2014

tot_nb_source_symbols=39  tot_nb_repair_symbols=23  symbol_size=1024  ldpc_N1=5  rs_m=8
codec_id=3
transmission_type=randomly_send_all_source_and_repair_symbols
===> (1) test with 39 recvd symbols (overhead 0) and 23 lost symbols... ==29720== Invalid read of size 4
==29720==    at 0x403B43E: of_add_to_multiple_symbols (of_symbol.c:502)
==29720==    by 0x403D3C1: of_linear_binary_code_col_forward_elimination (of_ml_tool.c:257)
==29720==    by 0x403CF58: of_linear_binary_code_triangularize_dense_system (of_ml_tool.c:145)
==29720==    by 0x403CD99: of_linear_binary_code_solve_dense_system (of_ml_tool.c:111)
==29720==    by 0x403BBBA: of_linear_binary_code_finish_decoding_with_ml (of_ml_decoding.c:227)
==29720==    by 0x404912D: of_ldpc_staircase_finish_decoding (of_ldpc_staircase_api.c:465)
==29720==    by 0x4046DA4: of_finish_decoding (of_openfec_api.c:568)
==29720==    by 0x804BE16: receive_and_decode (receiver.c:209)
==29720==    by 0x804B0C5: start_enc_dec_test (eperftool.c:268)
==29720==    by 0x804AB43: main (eperftool.c:124)
==29720==  Address 0x4307d78 is 0 bytes after a block of size 248 alloc'd
==29720==    at 0x402A17C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==29720==    by 0x40456C0: of_malloc (of_mem.c:40)
==29720==    by 0x40488E5: of_ldpc_staircase_set_fec_parameters (of_ldpc_staircase_api.c:291)
==29720==    by 0x4045F5C: of_set_fec_parameters (of_openfec_api.c:213)
==29720==    by 0x804F8E9: create_and_init_codec_instance (codec_instance_mgmt.c:107)
==29720==    by 0x804BAB4: receive_and_decode (receiver.c:148)
==29720==    by 0x804B0C5: start_enc_dec_test (eperftool.c:268)
==29720==    by 0x804AB43: main (eperftool.c:124)
==29720== 
==29720== Invalid write of size 4
==29720==    at 0x403B44A: of_add_to_multiple_symbols (of_symbol.c:502)
==29720==    by 0x403D3C1: of_linear_binary_code_col_forward_elimination (of_ml_tool.c:257)
==29720==    by 0x403CF58: of_linear_binary_code_triangularize_dense_system (of_ml_tool.c:145)
==29720==    by 0x403CD99: of_linear_binary_code_solve_dense_system (of_ml_tool.c:111)
==29720==    by 0x403BBBA: of_linear_binary_code_finish_decoding_with_ml (of_ml_decoding.c:227)
==29720==    by 0x404912D: of_ldpc_staircase_finish_decoding (of_ldpc_staircase_api.c:465)
==29720==    by 0x4046DA4: of_finish_decoding (of_openfec_api.c:568)
==29720==    by 0x804BE16: receive_and_decode (receiver.c:209)
==29720==    by 0x804B0C5: start_enc_dec_test (eperftool.c:268)
==29720==    by 0x804AB43: main (eperftool.c:124)
==29720==  Address 0x4307d78 is 0 bytes after a block of size 248 alloc'd
==29720==    at 0x402A17C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==29720==    by 0x40456C0: of_malloc (of_mem.c:40)
==29720==    by 0x40488E5: of_ldpc_staircase_set_fec_parameters (of_ldpc_staircase_api.c:291)
==29720==    by 0x4045F5C: of_set_fec_parameters (of_openfec_api.c:213)
==29720==    by 0x804F8E9: create_and_init_codec_instance (codec_instance_mgmt.c:107)
==29720==    by 0x804BAB4: receive_and_decode (receiver.c:148)
==29720==    by 0x804B0C5: start_enc_dec_test (eperftool.c:268)
==29720==    by 0x804AB43: main (eperftool.c:124)
==29720== 
==29720== Invalid read of size 4
==29720==    at 0x403B359: of_add_from_multiple_symbols (of_symbol.c:255)
==29720==    by 0x403D6BC: of_linear_binary_code_backward_substitution (of_ml_tool.c:322)
==29720==    by 0x403CE37: of_linear_binary_code_solve_dense_system (of_ml_tool.c:119)
==29720==    by 0x403BBBA: of_linear_binary_code_finish_decoding_with_ml (of_ml_decoding.c:227)
==29720==    by 0x404912D: of_ldpc_staircase_finish_decoding (of_ldpc_staircase_api.c:465)
==29720==    by 0x4046DA4: of_finish_decoding (of_openfec_api.c:568)
==29720==    by 0x804BE16: receive_and_decode (receiver.c:209)
==29720==    by 0x804B0C5: start_enc_dec_test (eperftool.c:268)
==29720==    by 0x804AB43: main (eperftool.c:124)
==29720==  Address 0x4307d78 is 0 bytes after a block of size 248 alloc'd
==29720==    at 0x402A17C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==29720==    by 0x40456C0: of_malloc (of_mem.c:40)
==29720==    by 0x40488E5: of_ldpc_staircase_set_fec_parameters (of_ldpc_staircase_api.c:291)
==29720==    by 0x4045F5C: of_set_fec_parameters (of_openfec_api.c:213)
==29720==    by 0x804F8E9: create_and_init_codec_instance (codec_instance_mgmt.c:107)
==29720==    by 0x804BAB4: receive_and_decode (receiver.c:148)
==29720==    by 0x804B0C5: start_enc_dec_test (eperftool.c:268)
==29720==    by 0x804AB43: main (eperftool.c:124)
==29720== 
ERROR in "/opt/openfec/applis/eperftool/receiver.c":307:receive_and_decode(): ERROR in "/opt/openfec/applis/eperftool/receiver.c":307:receive_and_decode(): ERROR in "/opt/openfec/applis/eperftool/receiver.c":307:receive_and_decode(): ERROR in "/opt/openfec/applis/eperftool/receiver.c":307:receive_and_decode(): ERROR in "/opt/openfec/applis/eperftool/receiver.c":307:receive_and_decode(): ERROR in "/opt/openfec/applis/eperftool/receiver.c":307:receive_and_decode(): ERROR in "/opt/openfec/applis/eperftool/receiver.c":307:receive_and_decode(): ERROR in "/opt/openfec/applis/eperftool/receiver.c":307:receive_and_decode(): ERROR in "/opt/openfec/applis/eperftool/receiver.c":307:receive_and_decode(): ERROR in "/opt/openfec/applis/eperftool/receiver.c":307:receive_and_decode(): ERROR in "/opt/openfec/applis/eperftool/receiver.c":307:receive_and_decode(): ERROR in "/opt/openfec/applis/eperftool/receiver.c":307:receive_and_decode(): ERROR in "/opt/openfec/applis/eperftool/receiver.c":307:receive_and_decode(): ERROR in "/opt/openfec/applis/eperftool/eperftool.c":274:start_enc_dec_test():    failed
decoding_status=2
==29720== 
==29720== HEAP SUMMARY:
==29720==     in use at exit: 0 bytes in 0 blocks
==29720==   total heap usage: 147 allocs, 147 frees, 185,502 bytes allocated
==29720== 
==29720== All heap blocks were freed -- no leaks are possible
==29720== 
==29720== For counts of detected and suppressed errors, rerun with: -v
==29720== ERROR SUMMARY: 432 errors from 3 contexts (suppressed: 0 from 0)
@baranovmv baranovmv added defect Something isn't working portability labels May 14, 2016
@gavv gavv added this to the 0.1 milestone May 14, 2016
@baranovmv
Copy link
Member Author

One can reproduce this on on x86-64 host by adding the following string in CMakeLists.txt:

set(CMAKE_C_FLAGS "-m32")

@gavv
Copy link
Member

gavv commented May 15, 2016

We need this for #9.

@baranovmv
Copy link
Member Author

According to OpenFEC tests (make test) the issue is in of_add_to_multiple_symbols(...) and of_add_from_multiple_symbols(...)

@gavv gavv changed the title openfec fails to perform on 32bit platforms OpenFEC fails to perform on 32bit platforms May 15, 2016
@baranovmv
Copy link
Member Author

baranovmv commented May 15, 2016

This patch upon src/lib_common/linear_binary_codes_utils/of_symbol.c fix this issue

--- src/lib_common/linear_binary_codes_utils/of_symbol.c        2014-12-16 17:29:00.000000000 +0300
+++ src/lib_common/linear_binary_codes_utils/of_symbol.c        2016-05-15 14:42:45.821633790 +0300
@@ -244,11 +244,14 @@ void      of_add_from_multiple_symbols    (void

 #else //defined (__LP64__) || (__WORDSIZE == 64) } {

+       while(from_size > 0) {
        /*
         * 32-bit machines
         */
        UINT32          *t32 = (UINT32*) to;    // to pointer to 32-bit integers
-       UINT32          *f32 = (UINT32*)  from; // from pointer to 32-bit integers
+               UINT32          *f32 = (UINT32*)  from[0];      // from pointer to 32-bit integers
+               from++ ;
+               from_size-- ;
        /* First perform as many 32-bit XORs as needed... */
        for (i = symbolSize32; i > 0; i--)
        {
@@ -265,6 +268,7 @@ void        of_add_from_multiple_symbols    (void
                        * (UINT8*) ( (UINT8*) t32 + i) ^= * (UINT8*) ( (UINT8*) f32 + i);
                }
        }
+       }
 #endif //defined (__LP64__) || (__WORDSIZE == 64) }

 //#else  /* } ASSEMBLY_SSE_OPT { */
@@ -494,8 +498,11 @@ void       of_add_to_multiple_symbols      (void           *
        /*
         * 32-bit machines
         */
-       UINT32          *t32 = (UINT32*) to;    // to pointer to 32-bit integers
+       while( to_size > 0 ){
+               UINT32          *t32 = (UINT32*) to[0]; // to pointer to 32-bit integers
        UINT32          *f32 = (UINT32*)  from; // from pointer to 32-bit integers
+               to++ ;
+               to_size-- ;
        /* First perform as many 32-bit XORs as needed... */
        for (i = symbolSize32; i > 0; i--)
        {
@@ -512,6 +519,7 @@ void        of_add_to_multiple_symbols      (void           *
                        * (UINT8*) ( (UINT8*) t32 + i) ^= * (UINT8*) ( (UINT8*) f32 + i);
                }
        }
+       }
 #endif //defined (__LP64__) || (__WORDSIZE == 64) }

        //#else  /* } ASSEMBLY_SSE_OPT { */

@gavv
Copy link
Member

gavv commented May 18, 2016

The patch has troubles with whitespaces and formatting. I've uploaded fixed verson: gist.

@gavv
Copy link
Member

gavv commented May 18, 2016

Our travis now also cross-compiles Roc for RPi 1 and RPi 2 and runs tests using QEMU.

To fix builds, I temporarily added applying the patch above to scons --with-3rdparty=openfec. We can remove it when the patch will be accepted by upstream.

@gavv gavv removed this from the 0.1 milestone Mar 27, 2017
@gavv gavv added this to the 0.1 milestone Jul 11, 2017
@gavv gavv removed this from the 0.1 milestone Jan 2, 2019
@gavv gavv closed this as completed May 27, 2019
@gavv gavv added this to the 0.1.0 milestone Jul 10, 2020
@gavv gavv added this to Roc Toolkit Jul 6, 2024
@gavv gavv moved this to Done in Roc Toolkit Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Something isn't working portability
Projects
Status: Done
Development

No branches or pull requests

2 participants