Bug 1308204

Summary: uhd: FTBFS in rawhide
Product: [Fedora] Fedora Reporter: Fedora Release Engineering <releng>
Component: uhdAssignee: Jaroslav Škarvada <jskarvad>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 24CC: astitcher, jskarvad, jwakely, luca.giuzzi
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: uhd-3.9.4-2.fc24 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-05 05:01:19 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1305208    
Attachments:
Description Flags
build.log
none
root.log
none
state.log none

Description Fedora Release Engineering 2016-02-13 22:37:39 UTC
Your package uhd failed to build from source in current rawhide.

http://koji.fedoraproject.org/koji/taskinfo?taskID=12875584

For details on mass rebuild see https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

Comment 1 Fedora Release Engineering 2016-02-13 22:37:41 UTC
Created attachment 1126670 [details]
build.log

Comment 2 Fedora Release Engineering 2016-02-13 22:37:43 UTC
Created attachment 1126672 [details]
root.log

Comment 3 Fedora Release Engineering 2016-02-13 22:37:44 UTC
Created attachment 1126673 [details]
state.log

Comment 4 Jan Kurik 2016-02-24 15:17:36 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 24 development cycle.
Changing version to '24'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora24#Rawhide_Rebase

Comment 5 Jonathan Wakely 2016-05-24 12:34:42 UTC
This blocks gqrx from being rebuilt in F24.

The errors are:

/builddir/build/BUILD/uhd-release_003_008_002/host/utils/cdecode.c: In function 'int base64_decode_value(char)':
/builddir/build/BUILD/uhd-release_003_008_002/host/utils/cdecode.c:11:266: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
     static const char decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
                                                                                                                                                                                                                                                                          ^
/builddir/build/BUILD/uhd-release_003_008_002/host/utils/cdecode.c:11:266: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/uhd-release_003_008_002/host/utils/cdecode.c:11:266: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/uhd-release_003_008_002/host/utils/cdecode.c:11:266: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/uhd-release_003_008_002/host/utils/cdecode.c:11:266: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/uhd-release_003_008_002/host/utils/cdecode.c:11:266: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/uhd-release_003_008_002/host/utils/cdecode.c:11:266: error: narrowing conversion of '-2' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/uhd-release_003_008_002/host/utils/cdecode.c:11:266: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/uhd-release_003_008_002/host/utils/cdecode.c:11:266: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/uhd-release_003_008_002/host/utils/cdecode.c:11:266: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/uhd-release_003_008_002/host/utils/cdecode.c:11:266: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/uhd-release_003_008_002/host/utils/cdecode.c:11:266: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/uhd-release_003_008_002/host/utils/cdecode.c:11:266: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/uhd-release_003_008_002/host/utils/cdecode.c:11:266: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/uhd-release_003_008_002/host/utils/cdecode.c:11:266: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/uhd-release_003_008_002/host/utils/cdecode.c:11:266: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]

I was surprised that code ever worked on ARM, and in fact it looks like it doesn't:

https://sourceforge.net/p/libb64/bugs/1/

Comment 6 Jonathan Wakely 2016-05-24 13:08:26 UTC
Also https://sourceforge.net/p/libb64/bugs/2/ deals with the same bug, but misses another one. I've attached an improved patch there.

Comment 7 Jaroslav Škarvada 2016-05-24 13:16:08 UTC
I think it's clear to me how to fix it (IIRC I fixed this gcc speciality in few other packages), but I am too lazy to patch it :) I will probably rebase the uhd package as I have already done in rawhide.

Comment 8 Jonathan Wakely 2016-05-24 13:40:18 UTC
Simply casting the literals to char won't fix it, the code is broken and doesn't work correctly (even on x86, see my comment at https://sourceforge.net/p/libb64/bugs/2/ about the off-by-one error).

Comment 9 Jaroslav Škarvada 2016-05-24 14:28:48 UTC
Thanks for info, it seems upstream workaround it the following way [1]:

- they switched from c++ to c, because it's C code,  so the C++11 requirements doesn't apply
- they used explicit conversion the following way:

if ((signed char)value_in < 0 || value_in > decoding_size) return -1;

It seems to compile and work (maybe it relies on gcc behaviour - I am not good at C standards).

[1] https://github.com/EttusResearch/uhd/blob/master/host/lib/usrp/x300/cdecode.c

Comment 10 Jonathan Wakely 2016-05-24 16:36:49 UTC
"It compiles" doesn't mean it's not still horribly broken.

For a start, as I've already said, that line you quoted has an off-by-one error. If value_in == decoding_size then it accesses off the end of the array.

Comment 11 Jonathan Wakely 2016-05-24 17:13:35 UTC
Also, for signed char, if value_in is -128 then this subtraction:

 value_in -= 43;

at https://github.com/EttusResearch/uhd/blob/master/host/lib/usrp/x300/cdecode.c#L13 will underflow, with undefined behaviour.

And when char is unsigned this cast has implementation-defined behaviour (so it works with GCC, but could produce the wrong result and/or raise a signal with other compilers):

                } while ((signed char)fragment < 0);

The code stinks.

Comment 12 Jaroslav Škarvada 2016-05-25 09:41:25 UTC
Right, it relies on undefined gcc behavior, but there is still off by one error. I will patch it downstream. Are you going to pull request your patch to uhd upstream?

Comment 13 Jonathan Wakely 2016-05-25 09:59:24 UTC
Yes, will do.

Comment 14 Jaroslav Škarvada 2016-05-25 10:01:38 UTC
Thanks.

Comment 15 Jaroslav Škarvada 2016-05-25 12:46:48 UTC
Applying https://github.com/EttusResearch/uhd/pull/60 downstream.

Comment 16 Fedora Update System 2016-05-25 15:34:04 UTC
uhd-3.9.4-2.fc24 gr-osmosdr-0.1.3-19.20141023git42c66fdd.fc24 gnuradio-3.7.9.1-4.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-22f4609f86

Comment 17 Fedora Update System 2016-05-26 05:01:31 UTC
gnuradio-3.7.9.1-4.fc24, gr-osmosdr-0.1.3-19.20141023git42c66fdd.fc24, uhd-3.9.4-2.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-22f4609f86

Comment 18 Jonathan Wakely 2016-07-03 17:21:54 UTC
*** Bug 1352168 has been marked as a duplicate of this bug. ***

Comment 19 Jaroslav Škarvada 2016-07-04 10:16:48 UTC
*** Bug 1352298 has been marked as a duplicate of this bug. ***

Comment 20 Fedora Update System 2016-07-05 05:01:16 UTC
gnuradio-3.7.9.1-4.fc24, gr-osmosdr-0.1.3-19.20141023git42c66fdd.fc24, uhd-3.9.4-2.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.