In the beginning of Avengers: Infinity War, as we all know, Thanos and the Children attack and kill half of the surviving Asgardians. In search for the Space Stone, Thanos tortures Thor and then gains it from Loki. Loki makes a false attempt to join Thanos then instantly tries to stab him. He is stopped and killed easily.
Why did Loki try to kill Thanos here? He's seen Thanos defeat Hulk and kill half of the Asgardians, so he should logically know that a small blade doesn't have a great chance of success against Thanos. Also, even if he did succeed in killing Thanos here, the Children would kill Loki instantly.
If this was a spur of the moment decision, it might make sense, but it doesn't seem as if Loki is acting all on instinct - he's worked with Thanos before; he could've tried to pull off the "fake ally" thing.
I quite like the fan theory that Loki was deliberately trying to get Thanos to kill him in order to save Thor according to Thanos's 50/50 rule, but I am wondering if there is a canon answer for his actions.