bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Assignments into FUNCTAB resulting either strange output or hanging


From: Jason C. Kwan
Subject: Assignments into FUNCTAB resulting either strange output or hanging
Date: Wed, 8 Sep 2021 03:47:48 +0000 (UTC)

Dear GNU,
I've noticed a rather strange bug about FUNCTAB. Hope the attached outputs 
suffice to reproduce the bug on your end. Thanks
Jason
On my version 
gawk -VGNU Awk 5.1.0, API: 3.0 (GNU MPFR 4.1.0, GNU MP 6.2.1)Copyright (C) 
1989, 1991-2020 Free Software Foundation.
running on this machine
Summary=======           System Version: 20G95           Hardware Model: 
MacBookPro15,2                 Board ID: Mac-827FB448E656EC26    Installed 
Memory Size: 16GB (17179869184)                Page Size: 4096         Root 
Volume Type: SSD:1,HDD:0,FUSION:0,FDE:1,RAID:0,TINYSSD:0,IN:1,EX:0,INEX:0,APFS  
       Root Volume Size: 931GB (1000240963584)                 SSD Name: APPLE 
SSD AP1024M             SSD Revision: 1161.100     Discrete GPU Present: 0      
         Total Time: 147:40:15          Dashboard Start: 2021-09-01 19:41:37    
        Dashboard End: 2021-09-07 23:21:44
Trying to do certain kinds of math operations on it feels like hanging (the 
final one involving multiplying b with negative infinity :
gawk -e 'BEGIN{ a="0xFE"; print b= FUNCTAB[+a]; print a; c=sprintf("%400g",b);  
print sprintf(" b : \f [%s]\n c : \f[%x]\n",b^(log(0)*b),b-c)  }'
when the output field is wide enough, i get back plenty of numbers
$ date  | gawk -e '{ a="0xFE"; print b= FUNCTAB[+a]; print a; 
printf("%5.310e\n",b)    
}'6.9479e-3100xFE??877557937723776738480915850953617326454614839557284805662916966568868877681050291539531252788984962450113740560184771666730980762794177452495253156543738376885465183160063273903627419386098876475375492703298816675604655744333154725916842600693687989465574994335971031957663156586178727763726702e-310

These cases result in strange output
   $ LC_ALL=C  gawk  -e 'BEGIN { a="0xFE"; print b= FUNCTAB[+a]; print a; 
c=sprintf("%400g",b);  print sprintf(" b : \f [  %s  ]\n c : \f[%.304f]\n",b,c) 
 }'6.93644e-3100xFEpp?p                                                         
                                                                                
                                                                                
                                                                                
                                                                         
6.93644e-310  ] c :     
[0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]
$ LC_ALL=C  gawk  -e 'BEGIN { a="0xFE"; print b= FUNCTAB[+a]; print a; 
c=sprintf("%400g",b);  print sprintf(" b : \f [  %s  ]\n c : \f[%.310f]\n",b,c) 
 }'6.9307e-3100xFE????                                                          
                                                                                
                                                                                
                                                                                
                                                                         
6.9307e-310  ] c :     
[0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]
$ LC_ALL=C  gawk  -e 'BEGIN { a="0xFE"; print b= FUNCTAB[+a]; print a; 
c=sprintf("%400g",b);  print sprintf(" b : \f [  %s  ]\n c : \f[%.310f]\n",b,b) 
 }'6.9326e-3100xFE@@?@                                                          
                                                                                
                                                                                
                                                                                
                                                                         
6.9326e-310  ] c :     
[0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]
$ LC_ALL=C  gawk  -e 'BEGIN { a="0xFE"; print b= FUNCTAB[+a]; print a; 
c=sprintf("%400g",b);  print sprintf(" b : \f [  %s  ]\n c : 
\f[%.310f]\n",b,+b)  }'6.93421e-3100xFE??:    
[0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]
Additionally, depending on posix mode,standard mode, traditional mode, or GMP 
loaded, different things show up
$ LC_ALL=C  gawk -M -e 'BEGIN { print atan2(0,-1)/2; OFMT="%.80f"; print  
(2^-600)^(1/log(FUNCTAB[+0])); print atan2(0,-1)/2 }'1.5708gawk: cmd. line:1: 
fatal error: internal errorAbort trap: 6$ LC_ALL=C  gawk --posix  -e 'BEGIN { 
print atan2(0,-1)/2; OFMT="%.80f"; print  (2^-600)^(1/log(FUNCTAB[+0])); print 
atan2(0,-1)/2 
}'1.570811.57079632679489655799898173427209258079528808593750000000000000000000000000000000$
 LC_ALL=C  gawk -b  -e 'BEGIN { print atan2(0,-1)/2; OFMT="%.80f"; print  
(2^-600)^(1/log(FUNCTAB[+0])); print atan2(0,-1)/2 
}'1.57081.793601923301627154572202016424853354692459106445312500000000000000000000000000003.14159265358979311599796346854418516159057617187500000000000000000000000000000000$
 LC_ALL=C  gawk --traditional  -e 'BEGIN { print atan2(0,-1)/2; OFMT="%.80f"; 
print  (2^-600)^(1/log(FUNCTAB[+0])); print atan2(0,-1)/2 
}'1.570811.57079632679489655799898173427209258079528808593750000000000000000000000000000000
Basically, FUNCTAB is rather inconsistent :
$ LC_ALL=C  gawk -M  -e 'BEGIN { print FUNCTAB[-1] }'-1$ LC_ALL=C  gawk  -e 
'BEGIN { print FUNCTAB[-1] }'-1$ LC_ALL=C  gawk  -e 'BEGIN { print FUNCTAB[-""] 
}'6.94558e-310$ LC_ALL=C  gawk  -e 'BEGIN { print FUNCTAB[""] }'
$ LC_ALL=C  gawk  -e 'BEGIN { print FUNCTAB[+""] }'6.94205e-310$ LC_ALL=C  gawk 
 -e 'BEGIN { print FUNCTAB[+"a"] }'6.94771e-310$ LC_ALL=C  gawk  -e 'BEGIN { 
print FUNCTAB["a"] }'a$ LC_ALL=C  gawk  -e 'BEGIN { print 
FUNCTAB[FUNCTAB["srand"]] }'srand$ LC_ALL=C  gawk  -e 'BEGIN { print 
FUNCTAB[+FUNCTAB["srand"]] }'6.94842e-310
i didn't attach the full length here, but if you activate GMP and do +5, it's 
nearly 630k dump :
 $ LC_ALL=C  gawk -M  -e 'BEGIN { print FUNCTAB[+5] }' | gwc 
-lcmgawk(9091,0x1148cee00) malloc: *** error for object 0x7f8e2170a660: pointer 
being freed was not allocatedgawk(9091,0x1148cee00) malloc: *** set a 
breakpoint in malloc_error_break to debug      0  628995  628995$ 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]