Hi,

Suddenly, uc_recurring cron runs, results in apache segfaults - every time.

I've debugged with some watchdog() calls - and have found out that for some odd reason it dies EVERY time on uc_order_load.
uc_recurring.module:
watchdog('uc_recurring', "renewing if applicable:".$fee->order_id);
$order = uc_order_load($fee->order_id);
watchdog('uc_recurring', "Loaded order:".$fee->order_id);

I put a watchdog entry in uc_order_load (at the top)- and in 1 cron run it gives me these messages:
uc_recurring 2010-03-15 13:29 renewing if applicable:33 Anonymous
uc_recurring 2010-03-15 13:29 Starting uc_recurring_cron Anonymous

and then several hundred of these:
ubercart 2010-03-15 13:29 loading order:33- Anonymous
ubercart 2010-03-15 13:29 loading order:33- Anonymous
ubercart 2010-03-15 13:29 loading order:33- Anonymous
ubercart 2010-03-15 13:29 loading order:33- Anonymous
...

And nothing from the watchdog right after the uc_order_load call.

How can the uc_order_load function call be called that many times from 1 line? Any ideas?

I'm running Debian etch - php-5.2.0.

Comments

klavs’s picture

uc_order_load is used tonnes of other places - where there's no problem.

Somehow uc_recurring triggers some odd bug - although I can't figure out how.

univate’s picture

I had an error recently where I was getting segfaults, due to an recursive function call. You may want to check that you don't have anything else happening in your uc_order_load function, like a hook that is also attempting to load the same object.

klavs’s picture

uc_order_load is the normal ubercart function - and it's called from tonnes of different places, where there's no problem - so it's really weird.

I can see it has a hook - and currently uc_fee and uc_address (besides uc_recurring) hooks into it.

I'll try to disable those and see what happens.

klavs’s picture

I found a workaround for the issue:

if (($total = uc_order_get_total($order)) !== $order->order_total) {
db_query("UPDATE {uc_orders} SET order_total = %f WHERE order_id = %d", $total, $order->order_id);
$order->order_total = $total;
}

After uncommenting this in uc_order_load - it works.

It's a crap thing to do anyways - updating the order on load - so the total may become something the customer did NOT see when they got their order confirmation email, or on their review page.

I haven't found any bugs by not having this in yet.

univate’s picture

Title: uc_recurring_cron loads order until segfault » uc_order_load causing segfault
Project: UC Recurring Payments and Subscriptions » Ubercart
Category: task » bug

If that is the problem then this is more likely to be an issue in ubercart itself.

I don't think it would be the db update causing the problem, its probably the function call "uc_order_get_total()", if you look in that function there is a hook that calls:

hook_order('total', $order);

I would be looking to see what happens from there, first try removing that hook and if it remove the segfault then see what modules are being called from that hook.

longwave’s picture

Status: Active » Closed (cannot reproduce)

The problem code in #4 is also noted at #1021940: order load is updating order total and is causing problems on certain conditions

Otherwise, I cannot reproduce this, but it sounds like an infinite loop is being caused somehow.