Skip to content
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

When viewing graphs, a byref error can be seen in the error logs #3104

Closed
reubenfarrelly opened this issue Nov 27, 2019 · 17 comments
Closed
Labels
bug Undesired behaviour gui UI related issue

Comments

@reubenfarrelly
Copy link

I'm following git 1.2.x branch, and a commit somewhere around d5f9867 has broken things all over again.

After updating to anything past this commit I now get this logged, and a server side error:

[Wed Nov 27 17:06:07.199325 2019] [php7:error] [pid 3756:tid 140394685986560] [client 2403:5800:7100:911::50:58253] PHP Fatal error: Uncaught Error: Cannot pass parameter 5 by reference in /var/www/cacti.reub.net/htdocs/graph_json.php:158\nStack trace:\n#0 {main}\n thrown in /var/www/cacti.reub.net/htdocs/graph_json.php on line 158, referer: https://cacti.reub.net/graph_view.php?action=preview
[Wed Nov 27 17:06:07.207148 2019] [php7:error] [pid 3756:tid 140394711164672] [client 2403:5800:7100:911::50:58253] PHP Fatal error: Uncaught Error: Cannot pass parameter 5 by reference in /var/www/cacti.reub.net/htdocs/graph_json.php:158\nStack trace:\n#0 {main}\n thrown in /var/www/cacti.reub.net/htdocs/graph_json.php on line 158, referer: https://cacti.reub.net/graph_view.php?action=preview

It is browser independent and shows up in Tree View (is anyone even testing Tree View? This is the second fatal problem in a month to break this view...) Preview and List Views still work OK though.

Reverting d5f9867 results in the error going away, but the page doesn't render graphs.

Problem current as of 1a6ba58 .

@netniV
Copy link
Member

netniV commented Nov 27, 2019

Are you sure that you have the latest from the 1.2.x branch? I only ask as I am sure there was a pull request that fixed this issue.

The commit looks right just wondering if the files are properly updated.

@reubenfarrelly
Copy link
Author

The previous and similar issue I had was #3053 but things worked again after that was committed.

thunderstorm /var/www/cacti.reub.net/htdocs # git status
On branch 1.2.x
Your branch is up to date with 'origin/1.2.x'.

and

thunderstorm /var/www/cacti.reub.net/htdocs # git pull
Already up to date.
thunderstorm /var/www/cacti.reub.net/htdocs #

That was taken now so I'm assuming that confirms I am up to date?

An md5sum of the graph_json.php file locally and pulled from the server matches too.

@netniV
Copy link
Member

netniV commented Nov 27, 2019

OK, cool. Must have been missed but I thought it was included, we will take a look.

@netniV
Copy link
Member

netniV commented Nov 27, 2019

I've looked at the function definition and that hasn't changed in 4 years. Can you verify the version of PHP you are using?

@netniV
Copy link
Member

netniV commented Nov 27, 2019

Wait, no it's me, I had my repo checked out to release/1.2.2 for some reason. I've now reset to the 1.2.x branch and can see the problem is because of the NULL value being passed on parameter 5. PHP doesn't allow you to pass in null, you must just not specify it.

The workaround is to either remove the null value or pass a variable initialised to an array. Can you try removing the null value and see if that cures your problem? This was likely introduced as part of cfb0733 and then corrected to the proper element in d5f9867

@netniV
Copy link
Member

netniV commented Nov 27, 2019

Again, forget that, you can't skip a parameter so you'd have to pass either array(), try this:

diff --git a/graph_json.php b/graph_json.php
index 25930ff6..6c5b7f5d 100644
--- a/graph_json.php
+++ b/graph_json.php
@@ -155,7 +155,8 @@ if (!isset_request_var('image_format')) {
 $graph_data_array['image_format'] = $gtype;
 
 if ($config['poller_id'] == 1 || read_config_option('storage_location')) {
-       $output = rrdtool_function_graph(get_request_var('local_graph_id'), $rra_id, $graph_data_array, '', null, $_SESSION['sess_user_id']);
+       $xport_meta = array();
+       $output = rrdtool_function_graph(get_request_var('local_graph_id'), $rra_id, $graph_data_array, '', $xport_meta, $_SESSION['sess_user_id']);
 
        ob_end_clean();
 } else {

@netniV
Copy link
Member

netniV commented Nov 27, 2019

So, I analysed this type of function call and the parameters used and produced the following table. I see about 10 calls that are invalid right now as they try to pass null for the xport_meta parameter.

NOTE: This table is wide so you'll have to scroll sideways to see it all on GitHub.

File Line function $local_graph_id $rra_id $graph_data_array $rrdtool_pipe = false &$xport_meta = array() $user = 0
./plugins/gexport/functions.php 980 rrdtool_function_graph $local_graph_id 0 $graph_data_array $rrdtool_pipe $metadata $user
./plugins/gexport/functions.php 991 rrdtool_function_graph $local_graph_id 0 $graph_data_array $rrdtool_pipe $metadata $user
./plugins/gexport/functions.php 1020 rrdtool_function_graph $local_graph_id $rra['id'] $graph_data_array $rrdtool_pipe $metadata $user
./plugins/npc/top_graph_header.php 147 rrdtool_function_graph $_GET["local_graph_id"] $_GET["rra_id"] $graph_data_array)      
./plugins/thold/thold_functions.php 5306 rrdtool_function_graph $val['local_graph_id'] '' $graph_data_array ''    
./graph_json.php 159 rrdtool_function_graph get_request_var('local_graph_id') $rra_id $graph_data_array '' $xport_meta $_SESSION['sess_user_id']
./graph_json.php 221 rrdtool_function_graph get_request_var('local_graph_id') $rra_id $graph_data_array '' null $_SESSION['sess_user_id']
./graph_image.php 132 rrdtool_function_graph get_request_var('local_graph_id') $rra_id $graph_data_array '' null $_SESSION['sess_user_id']
./graph_image.php 145 rrdtool_function_graph get_request_var('local_graph_id') $rra_id $graph_data_array '' null $_SESSION['sess_user_id']
./graph.php 535 rrdtool_function_graph get_request_var('local_graph_id') get_request_var('rra_id') $graph_data_array '' null $_SESSION['sess_user_id']
./graph.php 539 rrdtool_function_graph get_request_var('local_graph_id') get_request_var('rra_id') $graph_data_array '' null $_SESSION['sess_user_id']
./lib/reports.php 365 rrdtool_function_graph $local_graph_id '' $graph_data_array '' $xport_meta $user
./lib/reports.php 375 rrdtool_function_graph $local_graph_id '' $graph_data_array '' $xport_meta $user)
./lib/reports.php 385 rrdtool_function_graph $local_graph_id '' $graph_data_array '' $xport_meta $user)
./lib/reports.php 395 rrdtool_function_graph $local_graph_id '' $graph_data_array '' $xport_meta $user
./lib/reports.php 405 rrdtool_function_graph $local_graph_id '' $graph_data_array '' $xport_meta $user)
./lib/reports.php 415 rrdtool_function_graph $local_graph_id '' $graph_data_array '' $xport_meta $user)
./lib/reports.php 425 rrdtool_function_graph $local_graph_id '' $graph_data_array '' $xport_meta $user
./lib/reports.php 435 rrdtool_function_graph $local_graph_id '' $graph_data_array '' $xport_meta $user)
./lib/reports.php 445 rrdtool_function_graph $local_graph_id '' $graph_data_array '' $xport_meta $user)
./lib/rrd.php 1225 rrdtool_function_graph $local_graph_id $rra_id $graph_data_array $rrdtool_pipe = false &$xport_meta = array() $user = 0
./lib/rrd.php 2325 rrdtool_function_graph $local_graph_id $rra_id $xport_data_array null $xport_meta $user
./remote_agent.php 238 rrdtool_function_graph $local_graph_id $rra_id $graph_data_array null $xport_options $user
./graphs.php 1600 rrdtool_function_graph get_request_var('id') 1 $graph_data_array '' null $_SESSION['sess_user_id']
./graphs.php 1603 rrdtool_function_graph get_request_var('id') 1 $graph_data_array '' null $_SESSION['sess_user_id']):__esc('Not Checked')
./aggregate_graphs.php 751 rrdtool_function_graph get_request_var('id') 1 $graph_data_array '' null $_SESSION['sess_user_id']
./aggregate_graphs.php 752 rrdtool_function_graph get_request_var('id') 1 $graph_data_array '' null $_SESSION['sess_user_id']):__esc('Not Checked')
./graph_realtime.php 179 rrdtool_function_graph get_request_var('local_graph_id') '' $graph_data_array '' null $_SESSION['sess_user_id']

@netniV
Copy link
Member

netniV commented Nov 27, 2019

Attaching an excel file that has the above table.
rrd.xlsx

I used the following command to generate this:

find . -name \*.php -exec grep -Hn "rrdtool_function_graph" {} \; | \
sed -r 's/(.*:[0-9]+:).*rrdtool_function_graph\((.*)\).*/\1rrdtool_function_graph,\2/'

netniV added a commit that referenced this issue Nov 27, 2019
@netniV
Copy link
Member

netniV commented Nov 27, 2019

@ddb4github since you supplied a fix that was partially to do with this, can you just double check that you can't see an issue with my fix?

@reubenfarrelly
Copy link
Author

The error is gone for me now so it looks to be fine. I am seeing a partial blank page on Tree view (top navigation loads fine but the body is blank - both Chrome and Edge) but that's possibly unrelated to this fix as it has been flaky for a while. I'll do further testing and try isolate the problem and open a separate issue if required.

@netniV
Copy link
Member

netniV commented Nov 28, 2019

OK, cool. Let us know on the other one if you do find a bug.

@netniV netniV closed this as completed Nov 28, 2019
@netniV netniV changed the title PHP Fatal error: Uncaught Error: Cannot pass parameter 5 by reference in graph_json.php:158 When viewing graphs, a byref error can be seen in the error logs Dec 7, 2019
@christh0mas
Copy link

Hello. I just upgraded Cacti to 1.2.8 and I am now unable to see my graphs via tree view. I'm getting the same error shown above:

CMDPHP Validation Error, Variable:thumbnails, Value:on Backtrace: (/graph_view.php[221]:top_graph_header(), /lib/functions.php[3272]:include_once(), /include/top_graph_header.php[54]:grow_dhtml_trees(), /lib/html_tree.php[95]:html_validate_tree_vars(), /lib/html_tree.php[843]:validate_store_request_vars(), /lib/html_utility.php[704]:die_html_input_error(), /lib/html_validate.php[64]:cacti_debug_backtrace())

I can't tell from this post what the solution is though. Any assistance would be greatly appreciated.
Thanks.

@ghost
Copy link

ghost commented Jan 27, 2020

Hi, same error as @christh0mas after upgrade to 1.2.8. Any assistance would be greatly appreciated.
thnx

@netniV
Copy link
Member

netniV commented Jan 27, 2020

This was resolved, you'll need 1.2.9 for that which hasn't been released yet. You can download the sources from here as long as you understand how to install them.

@ghost
Copy link

ghost commented Feb 28, 2020

Hi netniV, I've updated to 1.2.9, but the error still persists. Is there something that I need to update or reset? I've checked the files graph.php/graphs.php and html_tree.php, and they are updated. Thanks
2020-02-28 16_37_49-Window

@netniV
Copy link
Member

netniV commented Feb 29, 2020

We are going to release 1.2.10 this weekend. I would suggest upgrading to that and we can run some checksums to make sure you have unmodified versions of things.

@netniV netniV added 3rd Party Bug 3rd party bug bug Undesired behaviour gui UI related issue and removed 3rd Party Bug 3rd party bug labels Feb 29, 2020
@ghost
Copy link

ghost commented Mar 3, 2020

ok, I had to relogin.. now it works. Thank you for your help.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour gui UI related issue
Projects
None yet
Development

No branches or pull requests

3 participants