Bug 664080

Summary: math lib functions no longer work
Product: [Fedora] Fedora Reporter: Pádraig Brady <p>
Component: bcAssignee: Ondrej Vasik <ovasik>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: low    
Version: 14CC: ovasik
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: bc-1.06.95-2.fc14 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-12-24 19:26:54 EST Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:

Description Pádraig Brady 2010-12-17 18:29:21 EST
$ echo "s(1);e(1)" | /f14/usr/bin/bc -l
$ echo "s(1);e(1)" | /f11/usr/bin/bc -l
.84147098480789650665
2.71828182845904523536
Comment 1 Ondrej Vasik 2010-12-18 02:51:06 EST
Thanks for report - strange, can't reproduce here...

$ rpm -q bc
bc-1.06.95-1.fc12.i686

$ echo "s(1);e(1)" | bc -l
.84147098480789650665
2.71828182845904523536

And that's the same version which is in f14. Some specific arch?
Comment 2 Pádraig Brady 2010-12-21 06:31:17 EST
I had a quick look at this again...

It doesn't look to be an issue specific to the math lib (-l option)
as in the following example, n is not defined and should give a
different error and e is defined and should not give error.

$ echo "v=n(1);v=e(1)" | LANG=C /usr/bin/bc -l
(standard_in) 1: Assignment of a void expression
(standard_in) 2: Assignment of a void expression

That along with the fact that I also have it working
on another i686 F14 box with same sw versions, suggested
to me something low level. So I rebuilt the binary
(which still had the issue), and ran it under an F11 chroot
and it was OK!

That suggests to me a glibc issue?

$ rpm -q gcc kernel glibc
gcc-4.5.1-4.fc14.i686
kernel-2.6.35.9-64.fc14.i686
glibc-2.12.90-21.i686
$ uname -a
Linux 2.6.35.9-64.fc14.i686 #1 SMP Fri Dec 3 12:35:42 UTC 2010 i686 i686 i386 GNU/Linux
$ grep -E "(model|flags)" /proc/cpuinfo 
model           : 13
model name      : Intel(R) Pentium(R) M processor 1.70GHz
flags           : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 ss tm pbe nx up bts est tm2

I'll try replacing memcpy and strcmp etc. this evening...
Comment 3 Ondrej Vasik 2010-12-21 08:14:18 EST
glibc - maybe ... could you please try to recompile bc srpm on your FC-14 machine and check it again? Maybe bc just needs to be rebuilt in F14...
Comment 4 Pádraig Brady 2010-12-21 11:01:07 EST
Sorry for being unclear. When I said "So I rebuilt the binary" above,
that was the rpm. Then I rebuilt a version without readline for
testing in the F11 chroot (with older readline)
Comment 5 Pádraig Brady 2010-12-21 18:55:21 EST
Found the issue in bc with a bit of thought and valgrind...
I'll send the fix upstream, but there's not been a release
for 4 years, so I'd apply it locally anyway. cheers.

--- storage.c.orig      2010-12-21 19:43:14.663540110 +0000
+++ storage.c   2010-12-21 19:42:01.392540111 +0000
@@ -99,6 +99,7 @@
    {
       f = &functions[indx];
       f->f_defined = FALSE;
+      f->f_void = FALSE;
       f->f_body = (char *) bc_malloc (BC_START_SIZE);
       f->f_body_size = BC_START_SIZE;
       f->f_code_size = 0;
Comment 6 Ondrej Vasik 2010-12-22 00:24:14 EST
Thanks for the patch, sure, upstream seems to be dead (1.06.95 for years), I'll do an update soon.
Comment 7 Fedora Update System 2010-12-22 04:49:54 EST
bc-1.06.95-2.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/bc-1.06.95-2.fc14
Comment 8 Fedora Update System 2010-12-22 14:54:02 EST
bc-1.06.95-2.fc14 has been pushed to the Fedora 14 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update bc'.  You can provide feedback for this update here: https://admin.fedoraproject.org/updates/bc-1.06.95-2.fc14
Comment 9 Fedora Update System 2010-12-24 19:26:49 EST
bc-1.06.95-2.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.