Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror

Comment Re:Nope (Score 1) 151

Yeah, I think I should have read the code not just the CVE. It looks to me like a direct port of the C code with every other line being unsafe. I would put serious doubt on "efficient reasons". There are always multiple ways to write efficent code and one of those ways is usually safe or in the case of a data structure like this there will be a way to write it which involves much less unsafe code.

I've read the code now. So the safety statement is "unsafe { node_inner.death_list.remove(self) };" is okay because a node is either in a single list or in no list at all.

But "for death in death_list {" breaks this because it's moved part of the list onto the local stack. When you iterate though a list in Rust, it consumes the list destroying it. You avoid that by doing "for death in &death_list {". The fix just makes the safety statement true by deleting the nodes in place. This requires you to lock each node as you delete it but that isn't the fix in it's self.

Comment Re:Nope (Score 1) 151

Rust doesn't allow you to release locks before you are done with the list. When you lock a resource in Rust, it remains locked until the resource is out of scope. In Rust, it's { let a = resource.lock() }. The unlock happens due to the }. There isn't an .unlock() call like C/C++. The issue is that the Linked List is a C implementation in the Linux Kernel, which is why Rust needs to use unsafe to access it.

Comment Re:Nope (Score 1) 151

The problem is that the Rust compiler can't check the C code the Rust code is calling. If the C Linked List was written in Rust, then the compiler would have caught the race condition. The typical Rust program doesn't use unsafe. You need unsafe in Rust for 3 things: Writing data structures, Hardware access and calling C code. For data structures such as Linked List (through that's in the Rust standard library), you cargo import a pre-written and well tested version. I mean there is only like 16 data structures that programmers regularly use. No need to roll your own. Whilst the data structure itself technically could be bugged the Rust compiler verifies that the code using it is correct. Rust would have caught this error if std::collections::LinkedList was used. For hardware access, you write unsafe code and then you create a safe wrapper around it. Then the rest of your code calls your safe wrapper. You can enforce at compile time that the calls to the hardware are made in the right order, etc. See type state pattern. But obviously you need to code in how your network card actually functions before the Rust compiler can check it.

Comment Re: Finally... (Score 1) 180

This is kinda of silly since in the wide open general case fully optimized Rust code is 1% faster than fully optimized C/C++ code. Rust enables additional compiler optimizations that are not possible in C/C++. Now you might say well no one has really implemented these additional optimizations but it's irrelevant because eventually people will.

Comment Re:No (Score 2) 21

AI's technical definition is "Whatever is currently being studied by AI researchers at the moment" To give a quick list AI has referred to: Scheduling algorithms, Prolog, Genetic Algorithms, Neural Networks and now it refers to LLMs. There is also the term hard AI for machines that actually think, but research into hard AI is considered to be stalled.

Comment Re:It's a private company (Score 1) 99

Hunter Biden's laptop was found in a state that Hunter Biden has never been too and is the only state in the US where a repair shop guy can take ownership of a laptop and reveal the content?

Not only is it a lie, it's such a blatant lie you would have to be a complete moron to fall for it.

Slashdot Top Deals

The party adjourned to a hot tub, yes. Fully clothed, I might add. -- IBM employee, testifying in California State Supreme Court

Working...