in reply to Re^3: Influencing the Gconvert macro
in thread Influencing the Gconvert macro
I've seen such warnings in smoke logs a number of times, and tried to investigate at least a couple of times without success; I'd love (someone) to get to the bottom of it, at least to understand if it's a real problem (that needs to be fixed by increasing a buffer size).
I've never seen anyone report an actual problem relating to the warning though.
Hugo
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Influencing the Gconvert macro
by syphilis (Archbishop) on Oct 01, 2020 at 07:38 UTC | |
I can verify that the "%.*g" formatting still works ok when the buffer size needs to be bigger than 127. For example, with this patched perl, perl -le 'printf "%.751g\n", 2 ** - 1074;' prints out all 751 mantissa digits correctly and displays the exact decimal rendition of the value 2 ** -1074.
Actually, I can add a little to that. I hacked the source to print out the size of the buffer, and I've just discovered that, so long as I ask for no more than 91 digits, the buffer size is 127 - which should be sufficient. But as soon as I ask for more than 91 digits, the buffer size is not displayed - indicating that the processing has switched to a different block. Incredibly, when I ask for more than 91 digits, I've also just now realized that the "%.*g" formatting works fine on Ubuntu-18.04 perls. That is, the bug exists only when I request 18 to 91 (inclusive) digits. If I request a number outside of that range, it works fine on a standard (unpatched) perl-5.32.0 on Ubuntu-18.04: So it looks to me that the concern surrounding the 127-byte buffer is unfounded, because the processing switches to a different block as soon as we ask for more than 91 digits. But I'm not prepared to claim that I've actually proved anything ;-) Cheers, Rob | [reply] [Watch: Dir/Any] [d/l] [select] |
by hv (Prior) on Oct 01, 2020 at 13:24 UTC | |
Ok, the main calculation in the perl source is I think this statement from sv.c:
.. after which if we are subject to locale it goes and checks the actual length of the utf8 representation of the radix point and adjusts that "+ 1" for the default. The above adds up to 35, which is pretty close to the difference between 91 and 127. The origin of the gcc warning looks like it might be gimple-ssa-sprintf.c or a close relative, in which case the "#define target_mb_len_max() 6" may well explain the difference between 127 and 133. So this looks pretty safe to me - and you'd certainly need a debugging perl to get close to exercising the limits. That just leaves the question of whether we can give the compiler enough hints for it to come to the same conclusion, or whether we'd only be able to shut it up with a sledgehammer preprocessor directive. Hugo | [reply] [Watch: Dir/Any] [d/l] |
by syphilis (Archbishop) on Oct 02, 2020 at 03:55 UTC | |
I'm puzzled as to how/why this check is even being run. I've just built perl-5.33.2 with the usual configure args , making no attempt to influence the setting of Gconvert. But I've applied this patch to sv.c: That works fine but I'm not happy about the double-rounding that takes place when nvtype is We really want fv to be an NV, not a long double. And then we would need the sprintf() formatting to accommodate the nvtype - "g" versus "Lg". UPDATE: Duh ... there is no double-rounding ... but I think I still need to attend to the issue of "g" or "Lg" formatting. And it still produces that awful noise (see below my sig). The command that produces that noise is: So I've tried (unsuccessfully) to reproduce those warnings by compiling the following C program: I compiled it by running the same command (minus the perl-specific "-D..." switches) and it compiles noiselessly. So I guess that the noise must be introduced by something in those perl-specific switches. Do you know how to reproduce the warnings when compiling that C script ? Incidentally, AFAICS, that patch effectively removes Gconvert from the perl source entirely - except for Win32API-File, where the Gconvert call in cpan\Win32API-File\const2perl.h could be replaced with sprintf(), anyway. For Windows, Gconvert is already hard coded to sprintf(). Cheers, Rob
| [reply] [Watch: Dir/Any] [d/l] [select] |
by syphilis (Archbishop) on Oct 04, 2020 at 05:09 UTC | |
by syphilis (Archbishop) on Oct 04, 2020 at 10:39 UTC | |
|