Google Cloud suspended customer's account three times, for three different reasons
The founder of a service that manages SSL certificates says Google Cloud has suspended his account three times, without good reason, and recommended not using the G-Cloud for serious workloads.…
It's beached Wales! Prince William has a ball on Rio's Copacabana as he goes barefoot for a sunset game of volleyball - after playing football at the iconic Maracanã stadium ahead of his Earthshot events in Brazil
Wicked star Jonathan Bailey becomes first ever openly gay man to be named People's Sexiest Man Alive
Alfie Boe, 52, confirms romance with used car auction house manager, 29, with date night snap - two years after secret fling with Hannah Waddingham
Trent Alexander-Arnold shares heartbreaking message to Diogo Jota, as he lays a wreath in memory of his former team-mate on his Liverpool return
Moment masked council workers tear down Union Jack flags in the darkness of night
Essex school to get new classroom for children with learning difficulties
Australians To Get At Least Three Hours a Day of Free Solar Power - Even If They Don't Have Solar Panels
Read more of this story at Slashdot.
Embattled Rachel Reeves emerges from hiding today to lay ground for promise-breaking Budget betrayal - and, as ever, it won't be her fault
Half Yours claims stunning victory in the Melbourne Cup as jockey Jamie Melham makes sporting history - but horror fall scares fans on racing's biggest day
Undefined Tasks
Years ago, Brian had a problem: their C# application would crash sometimes. What was difficult to understand was why it was crashing, because it wouldn't crash in response to a user action, or really, any easily observable action.
The basic flow was that the users used a desktop application. Many operations that the users wanted to perform were time consuming, so the application spun up background tasks to do them, thus allowing the user to do other things within the application. And sometimes, the application would just crash, both when the user hadn't done anything, and when all background jobs should have been completed.
The way the background task was launched was this:
seeder.RunSeeder();It didn't take too much head scratching to realize what was running every time the application crashed: the garbage collector.
RunSeeder returned a Task object, but since Brian's application treated the task as "fire and forget", they didn't worry about the value itself. But C# did- the garbage collector had to clean up that memory.
And this was running under .Net 4.0. This particular version of the .Net framework was a special, quantum realm, at least when it came to tasks. You see, if a Task raises an exception, nothing happens. At least, not right away. No one is notified of the exception unless they inspect the Task object directly. There's a cat in the box, and no one knows the state of the cat unless they open the box.
The application wasn't checking the Task result. The cat remained in a superposition of "exception" and "no exception". But the garbage collector looked at the task. And, in .Net 4.0, Microsoft made a choice about what to do there: when they opened the box and saw an exception (instead of a cat), they chose to crash.
Microsoft's logic here wasn't entirely bad; an uncaught exception means something has gone wrong and hasn't been handled. There's no way to be certain the application is in a safe state to continue. Treating it akin to undefined behavior and letting the application crash was a pretty sane choice.
The fix for Brian's team was simple: observe the exception, and choose not to do anything with it. They truly didn't care- these tasks were fire-and-forget, and failure was acceptable.
seeder.RunSeeder().ContinueWith(t => { var e = t.IsFaulted ? t.Exception : null; }); // Observe exceptions to prevent quantum crashesThis code merely opens the box and sees if there's an exception in there. It does nothing with it.
Now, I'd say as a matter of programming practice, Microsoft was right here. Ignoring exceptions blindly is a definite code smell, even for a fire-and-forget task. Writing the tasks in such a way as they catch and handle any exceptions that bubble up is better, as is checking the results.
But I, and Microsoft, were clearly on the outside in this argument. Starting with .Net 4.5 and moving forward, uncaught exceptions in background tasks were no longer considered show-stoppers. Whether there was a cat or an exception in the box, when the garbage collector observed it, it got thrown away either way.
In the end, this reminds me of my own failing using background tasks in .Net.
China's president Xi Jinping jokes about backdoors in Xiaomi smartphones
Chinese president Xi Jinping has joked that smartphones from Xiaomi might include backdoors.…