-
Notifications
You must be signed in to change notification settings - Fork 267
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 #1268 - Segmentation Fault with Constant Lines #1269
Conversation
* This issue occurs with the --add-jsontime for lines that are a constant value. In this case, the variable `im->gdes[vidx].step` is always 0, which results in a division by zero segmentation fault.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1269 +/- ##
=======================================
Coverage 51.10% 51.11%
=======================================
Files 45 45
Lines 18251 18259 +8
=======================================
+ Hits 9328 9333 +5
- Misses 8923 8926 +3 ☔ View full report in Codecov by Sentry. |
@oetiker, I'm still getting random segfault's when enabling the --add-jsontime. So, I expect to have a few more updates to this pull as I track them down. |
It seems that it's with the use of proc_open() in PHP. If I open the command through a pipe, I get the segfault, if I open it using a shell exec, then there are no problems. Still researching. |
Okay, for whatever reason, when starting RRDtool in this manner, the variable ./rrdtool -
graphv blah.... So, there are a few ways to fix this:
What do you think? |
Two debug outputs with the variation in output. I've added a compare for each loop through the element. Note the bad dates in the output at the end of the proc_open_debug_output.gz, it has somehow got lost in space due to some bad data as the timestamps are not aligning with the step as in the shell_exec_debug.output.gz which appears to be correct. So, this issue must be deeper in how the stdin is being handled vs. the pure shell exec. The rrdtool binary still crashes when using --add-jsontime without the updated patch in strait RRDtool 1.9.0 or the latest develop. |
Modified code block from testing. I'll update the pull request with the sanitized version which will fix output generation, but not the issue when using the stdin pipe. long unsigned int chosen_step = 0;
/* fill data structure */
for (dst_row = 0; (int) dst_row < (int) row_cnt; dst_row++) {
for (i = 0; i < (int) (*col_cnt); i++) {
long vidx = im->gdes[ref_list[i]].vidx;
time_t now = *start + dst_row * *step;
long unsigned int chosen_idx;
if (chosen_step == 0) {
if (im->gdes[vidx].step > 0) {
chosen_step = im->gdes[vidx].step;
}
}
// if (im->gdes[vidx].step == 0 || im->gdes[vidx].step > chosen_step) {
printf("==========================================================\n");
printf("now is %lu\n", (unsigned long) now);
printf("step is %lu\n", im->gdes[vidx].step);
printf("start is %lu\n", im->gdes[vidx].start);
printf("ds_cnt is %li\n", im->gdes[vidx].ds_cnt);
printf("ds is %li\n", im->gdes[vidx].ds);
printf("chosen_step is %lu\n", chosen_step);
// }
if (im->gdes[vidx].step > 0 && im->gdes[vidx].step == chosen_step) {
chosen_idx = ceil((double) (now - im->gdes[vidx].start) / im->gdes[vidx].step) * im->gdes[vidx].ds_cnt + im->gdes[vidx].ds;
printf("chosen_idx is %lu\n", chosen_idx);
(*dstptr++) = im->gdes[vidx].data[chosen_idx];
// ceil((double) (now - im->gdes[vidx].start) / im->gdes[vidx].step) * im->gdes[vidx].ds_cnt + im->gdes[vidx].ds];
}
} |
* The LINEX functions allow for a numeric value, but the export believe that these are exportable columns.
If you are okay with my Larry |
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.
2x typo: contant -> constant
Just like me :) |
@c72578, I don't see that in the DIFF though. Can you be more specific? |
Got it. I was looking at the code ;) |
im->gdes[vidx].step
is always 0, which results in a division by zero segmentation fault.