GNOME Bugzilla – Bug 773688
division by log(1) produces segfault
Last modified: 2017-02-13 06:54:40 UTC
This command (and typing the same formula in the GUI) produces a segfault: gnome-calculator -s "42/log(1)" Interestingly, typing "log₁(42)" gives the expected division by zero error. I am using gnome-calculator version 3.16.0 and I don't have a more recent version available to test. I did not find an existing report for this bug, but if it is already fixed in more recent versions, fell free to close this issue immediately.
Not here: $:andre\> gnome-calculator -s "42/log(1)" Error: (null) $:andre\> rpm -q gnome-calculator gnome-calculator-3.20.2-2.fc24.x86_64
I can confirm that there's not segfault on 3.20.2 or later versions. However, I don't like the fact that the GUI is telling me "Division by zero is undefined" and the command-line tool "Error: (null)". The command line error message should be improved, so I will keep this issue open to do that. @Georges Duperon: could you please try a later version of gnome-calculator?
I tested with 3.10.3 on a Unbuntu 14.04 VM, and it prints `Error: Division by zero is undefined` I tested with 3.18.3 on NixOs 16.03, and it still gives a segfault I tested with 3.18.3 on a Ubuntu 16.04 Docker machine, and it prints `Error: (null)` (I couldn't test the GUI) I tested with 3.22.0 on a Ubuntu 16.10 Docker machine, and it prints `Error: (null)` (I couldn't test the GUI) It therefore seems to me that the issue is related to the compliation flags or dependencies used by the NixOs version, or otherwise that the issue was fixed early via Ubuntu-specific patches. Here are the two build recipies for the NixOs version: https://github.com/NixOS/nixpkgs/blob/release-16.03/pkgs/desktops/gnome-3/3.18/core/gnome-calculator/default.nix https://github.com/NixOS/nixpkgs/blob/release-16.03/pkgs/desktops/gnome-3/3.18/core/gnome-calculator/src.nix The only compilation flag I see is this one (path elided with ....): -I..../include/gio-unix-2.0 The build recipe does not seem to apply any distribution-specific patches.
Georges, thanks for the bug report. There are 2 different issues here. 1. Segfault, I debugged it and it still exists. But is hidden due to compiler optimizations, as we don't use the field being passed anywhere. 2. Error message showing "(null)" instead of real error. I'll upload the patch for issue-2 shortly. Issue-1 is a relatively larger change and will need some more time for testing.
Created attachment 342784 [details] [review] Fix the '(null)' error message on command-line invocations
Comment on attachment 342784 [details] [review] Fix the '(null)' error message on command-line invocations Thanks, the patch improves the situation indeed, pushing.
The second patch is almost ready. I'll upload it soon. The patch fixes the possible SEGV along with the missing highlight on some error cases. To test the highlight part on GUI, try "42/log(1)". Without the fix, it will print out error but won't select any part of expression. With the fix, it'll print out error and select "log(1)", which generated the divide by zero error. Same can be verified with "sin⁻¹2". With the fix, it'll select "2" and print error for the domain of "sin⁻¹" function.
Created attachment 342848 [details] [review] Fix null 'token' in FunctionArgumentsNode
Review of attachment 342848 [details] [review]: Nice patch, thanks. It indeed fixes error handling in the GUI and highlights the problematic token, which is an improvement indeed. I'm thinking of accepting it as is, but bonus points would go if you could also improve the command-line error handling a bit, as we still get "Error: (null)" in the command-line interface for the 42/log(1) usecase, even if the GUI perfectly handles the division by zero and highlights the problematic token.
Thanks Robert. In my local repository the error reporting works. [pioneeraxon@gnome src]$ ./gcalccmd > 42/log(1) Error Division by zero is undefined There are 2 local changes in my repository that are not yet merged in the repository. One of them is the patch I uploaded above, and the other is the one I uploaded in bug 775789. (link : https://bugzilla.gnome.org/attachment.cgi?id=342865&action=diff) I forgot the reason why I had split the changes in 2 parts. But I think the other patch fixes all the generic issues of passing the error string vs. error token throughout the code. I think once you cherry-pick both changes, it'll start working.
Indeed, pushing this change after the other one solved the issue too. Thanks for the reminder. This problem has been fixed in the unstable development version. The fix will be available in the next major software release. You may need to upgrade your Linux distribution to obtain that newer version.