# Bug in volk on armv6

**URL:** <https://www.ruby-forum.com/t/bug-in-volk-on-armv6/245679>\
**Category:** GNU Radio\
**Created:** [July 1, 2013, 10:09am UTC](https://www.ruby-forum.com/t/bug-in-volk-on-armv6/245679 "2013-07-01T10:09:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [July 1, 2013, 10:09am UTC](https://www.ruby-forum.com/t/bug-in-volk-on-armv6/245679/1 "2013-07-01T10:09:13Z")

</div>

Hi!

I would like to report a bug in volk on armv6.

There is infinite “while” cycle in volk/tmpl/volk\_cpu.tmpl.c function  
“has\_neon” (line 111).

Code “while(!found\_neon && auxvec\_f) {” will loop infinitely if there  
is no neon in platform. found\_neon will never be true and file  
descriptor auxvec\_f will always be true.

–  
Alexey B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![snaury](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@snaury](https://www.ruby-forum.com/u/snaury)\
**Post date:** [July 3, 2013, 4:57pm UTC](https://www.ruby-forum.com/t/bug-in-volk-on-armv6/245679/2 "2013-07-03T16:57:43Z")

</div>

On Mon, Jul 1, 2013 at 4:08 AM, Alexey B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> –  
> Alexey B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Ok, I see your point. Looks like we should be testing the return value  
from fread, instead of auxvec\_f. Can you confirm if this patch works?

diff --git a/volk/tmpl/volk\_cpu.tmpl.c b/volk/tmpl/volk\_cpu.tmpl.c  
index 81fc679..b1a0a4a 100644  
— a/volk/tmpl/volk\_cpu.tmpl.c  
+++ b/volk/tmpl/volk\_cpu.tmpl.c  
@@ -116,10 +116,11 @@ static int has\_neon(void){  
auxvec\_f = fopen(“/proc/self/auxv”, “rb”);  
if(!auxvec\_f) return 0;

- size\_t r = 1;  
//so auxv is basically 32b of ID and 32b of value  
//so it goes like this

- while(!found\_neon && auxvec\_f) {
- 

```
 fread(auxvec, sizeof(unsigned long), 2, auxvec_f);

```

- while(!found\_neon && r) {
- 

```
 r = fread(auxvec, sizeof(unsigned long), 2, auxvec_f);
 if((auxvec[0] == AT_HWCAP) && (auxvec[1] & HWCAP_NEON))
   found_neon = 1;

```

}

Or might be better to test ‘if(r \< 2)’ after the fread line and break  
in case an error occurs and we only get 1 character out and not try to  
read from it again. Probably not a bit deal since we’re only reading  
in two chars at a time.

Tom

---

<div class="post-metadata">

**Author:** ![snaury](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@snaury](https://www.ruby-forum.com/u/snaury)\
**Post date:** [July 4, 2013, 10:15am UTC](https://www.ruby-forum.com/t/bug-in-volk-on-armv6/245679/3 "2013-07-04T10:15:09Z")

</div>

Confirming that this fix works.

But now volk test fails in another place.

(gdb) run  
Starting program: /root/gnuradio-3.6.5.1/build/volk/lib/test\_all  
[Thread debugging using libthread\_db enabled]  
Using host libthread\_db library  
“/lib/arm-linux-gnueabihf/libthread\_db.so.1”. Running 92 test cases…  
Using Volk machine: generic\_orc  
RUN\_VOLK\_TESTS: volk\_16ic\_s32f\_deinterleave\_real\_32f\_a  
no architectures to test  
RUN\_VOLK\_TESTS: volk\_16ic\_deinterleave\_real\_8i\_a  
generic completed in 0s  
orc completed in 0.01s  
Best arch: generic  
RUN\_VOLK\_TESTS: volk\_16ic\_deinterleave\_16i\_x2\_a  
generic completed in 0s  
orc completed in 0s  
Best arch: generic  
RUN\_VOLK\_TESTS: volk\_16ic\_s32f\_deinterleave\_32f\_x2\_a  
generic completed in 0.01s

Program received signal SIGSEGV, Segmentation fault.  
0xb6f96428 in ?? () from /usr/lib/arm-linux-gnueabihf/libvolk.so.0.0.0  
(gdb) bt  
#0 0xb6f96428 in ?? ()  
#from /usr/lib/arm-linux-gnueabihf/libvolk.so.0.0.0  
Cannot access memory at address 0x0  
#1 0xb6db3da0 in pthread\_mutex\_unlock ()  
#from /lib/arm-linux-gnueabihf/libc.so.6 2 0x00000020 in ?? ()  
#3 0x00000020 in ?? ()  
Backtrace stopped: previous frame identical to this frame (corrupt  
stack?)

P.S. I’m trying to compile gnuradio on raspbian on Raspberry Pi board.  
All other tests passed ok, so some broken volk function shouldn’t be a  
problem for me since I only want to use network sink on it.

On Wed, 3 Jul 2013 10:55:06 -0400  
Tom R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > descriptor auxvec\_f will always be true.  
> > +++ b/volk/tmpl/volk\_cpu.tmpl.c
> 
> - 
> 
> ```
> r = fread(auxvec, sizeof(unsigned long), 2, auxvec_f);
> if((auxvec[0] == AT_HWCAP) && (auxvec[1] & HWCAP_NEON))
> found_neon = 1;
> 
> ```
> 
> }
> 
> Or might be better to test ‘if(r \< 2)’ after the fread line and break  
> in case an error occurs and we only get 1 character out and not try to  
> read from it again. Probably not a bit deal since we’re only reading  
> in two chars at a time.
> 
> Tom

–  
Alexey B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![snaury](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@snaury](https://www.ruby-forum.com/u/snaury)\
**Post date:** [July 16, 2013, 4:42pm UTC](https://www.ruby-forum.com/t/bug-in-volk-on-armv6/245679/4 "2013-07-16T16:42:04Z")

</div>

On Thu, Jul 4, 2013 at 4:13 AM, Alexey B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> RUN\_VOLK\_TESTS: volk\_16ic\_s32f\_deinterleave\_real\_32f\_a  
> generic completed in 0.01s  
> Backtrace stopped: previous frame identical to this frame (corrupt  
> stack?)
> 
> P.S. I’m trying to compile gnuradio on raspbian on Raspberry Pi board.  
> All other tests passed ok, so some broken volk function shouldn’t be a  
> problem for me since I only want to use network sink on it.

Hi Alexey,

Yeah, you shouldn’t care too much about Volk on the Raspberry Pi since  
there’s nothing optimized for that platform. You just need to make  
sure all call to Volk work using the ‘generic’ proto-kernels (in other  
words, you need Volk because we use functions from the library in GNU  
Radio, but you won’t access any of the SIMD-optimized versions of the  
code).

To learn more about the QA failure above, it’d be better to build with  
debug symbols on (-DCMAKE\_BUILD\_TYPE=“Debug”) to get more information  
out of that back trace.

Tom
