-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix decimal constant bug occuring when several programs in a COBOL file #113
Fix decimal constant bug occuring when several programs in a COBOL file #113
Conversation
Codecov Report
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. @@ Coverage Diff @@
## gcos4gnucobol-3.x #113 +/- ##
=====================================================
+ Coverage 65.74% 65.75% +0.01%
=====================================================
Files 32 32
Lines 59092 59090 -2
Branches 15575 15572 -3
=====================================================
+ Hits 38849 38857 +8
+ Misses 14262 14254 -8
+ Partials 5981 5979 -2
... and 3 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
115e899
to
7575d39
Compare
That's a quite severe issue, please recheck if this happens with 3.1 and trunk, then create a bug issue with the details. Thank you.
I'll check the PR quite soon, likely tomorrow.
|
Confirmed on 3.1 and trunk as well. |
On SF please, that's the right place for any bug report or feature request :-)
Thanks!
|
Hi @GitMensch, |
The bug report is here: https://sourceforge.net/p/gnucobol/bugs/920/ |
You mean here : https://sourceforge.net/p/gnucobol/bugs/917/ |
Without further checks I do wonder where this has gone bad, it seems this was fixed already? |
I think this is a different issue. The one you mention is about decimal constants not being initialized at all. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only minor changes to do for now, mostly to the testsuite.
Please be so kind to adjust it, then upload the generated code of that program with and without the codegen change, to ease rechecking the result after switching from "storage" to local.
That has been done. Here is the generated code in both case (relevant changes in |
Thank you for your work. I've adjusted the bug report with the findings - it isn't about It seems reasonable to move the "INITIAL" from As far as I see your change will then still work fine - then please push that change to the testsuite here. The second issue in both the old and new codegen: all constants from all runtime-elements (programs and user-defined functions) are initialized and clean in all runtime-elements, even if they aren't used at all (which is highlighted by your first test code where the constant was not used in prog2 and still got cleaned at its exit. Another related issue is, that we don't need multiple definitions in the first place. Adjusting that would also fix the bug at hand, but I currently see only two options and am not sure if those are good (both would leave the constant to be static and global):
We could use the change as-is, which would fix the SIGSEGV with the downside of a bit increased cpu time and memory usage (common programs likely have 5 to 20 decimal constants). What is your take on this? |
I updated the testsuite as requested (fix still works fine). As for your suggestions:
I agree that this might not be the best option.
Seems like a reasonable approach. It's probably best to tackle issue 923 first though. An optimal approach would be to add that counter only for those constants that appear in more than one program - but that might be overengineering... |
I'd declare this PR as "ready for svn" (even when svn committing is still postponed) as soon as the Changelog entry is added. Can you work on #923? In this case I'd suggest to postpone the change on
there. |
I'll try. I'll add questions directly on the SVN issue if needed. |
Note: as suggested, I put back the following, since it is handled by 923.
|
@ddeclerck Please bring this and #115 to svn, as two commits in whatever order. Then reference the commits at the referenced issues on SF (not sure if you can close them there yourself, if yes, please do so). |
now upstream - thanks! |
This patch fixes a nasty bug dealing with decimal constants when there are several programs in a COBOL file.
Consider the following COBOL file:
Attempting to run this program will result in a segfault:
We found out the bug was occurring because returning from a subprogram clears all decimal constants, i.e the generated code for
prog2
contains:Hence when
prog
tries to use the constant 42 (throughdc_1
), we are greeted with a segfault sincedc_1
is now NULL.The proposed fix is to move all the decimal constants to the "local" header files instead of the "global" header.
The testsuite has been run and does not complain.