1,994 karma · joined October 5, 2012
When was this bug introduced? Does anyone maintain a list of when all the known Linux kernel bugs were introduced? I'd love to know how many bugs are added to the kernel each year, and if the rate is changing.
I'm not trying to troll. I think the Linux kernel is an amazing piece of software engineering. I just think this would be an interesting metric.
Their expression (simplified) was: *target = pixels[j] << 24, where pixels contains items of type unsigned char.
I hadn't realized that the pixels[j] was being promoted to an int rather than unsigned int. Eeep.
> I really dislike the promotion logic in C.
Agreed. I'll add that to my list of C dislikes.
I still think that even with manually promoting to the appropriate unsigned type isn't sufficient. Because target has type long*, so coercing the result of (unsigned int)pixels[j] << 24 to long still causes overflow and therefore UB... unless there's yet more I've missed.
Edit: Damn it, again, that's what the discussion says (https://github.com/glfw/glfw/pull/1986#issuecomment-95800024...).
The code would never fail on a two's compliment machine. What ubsan is saying is that the rules of C don't guarantee this code to work - it only works because the overflow writes into the sign bit, which is where the next thing expected it to be anyway.
If the above is true, I don't think their "fix" helps: https://github.com/glfw/glfw/pull/1986/files. I would have thought that the important part is to change the longs to unsigned longs. Edit: Ah, right, that's what the discussion says: https://github.com/glfw/glfw/pull/1986
unsigned char foo = 0x80; long bar = foo << 24;
It overflows and bar is set to -2147483648. If foo was initialized with 0x7f, there'd be no overflow and bar would be set to 2130706432.
In the original problem, the value of foo isn't known at compile time.
> I tend to see lots of structs, bit-packing, and bitwise operations that don't make as much sense in APL.
That's why I mentioned "performance matters". Those things are common in algorithms where performance matters. If APL isn't interested, then it isn't good for most algorithmic work. Those operations aren't some quirk of current CPU architecture. It is less work in our universe to do bit shifts than multiplies. And bit packing reduces storage and IO, which also saves work at a fundamental level. The same operations are used in FPGA/ASIC designs where the architecture is much more free. Maybe quantum or analogue computers would change that picture a little but that's not what APL is for.
I'd say the main use for a symbolic thought notation is when working on performance critical stuff. If performance isn't critical then I use a simple algorithm and a simple implementation. Higher level system design stuff is usually better done as diagrams than symbolic notation. I guess when working on a large codebase I'm using the structure of the symbolic programming language to help me think about how distant parts of the code interact. But that doesn't sound like something APL would be good at either.
I agree except that the first thing the paper does is define "1" to be a function that "produces a vector of the first N integers". Highly confusing. It turns out that symbol isn't a "1" and rather is a weird squiggle that unfortunately looks like one.
Or draw boxes and arrows on a whiteboard or pieces of paper. But I agree, they usually don't write APL or anything like it.
I did some optimization work on a bilinear bitmap upscaler recently [1]. There were times in the middle of that work where I felt like I was sitting watching someone else do it for me. Not physically watching, but more like a part of my brain was doing it automatically. The amount of state in scope at once is too big to fit into my working memory (maybe I'm weak at this), so the work has to be symbolic manipulation. It feels like there are patterns in the symbol manipulation that my brain can do with minimal effort. Somehow the result is that I can write (hopefully) correct code that is beyond my ability to comprehend without the notation. The fact that I don't understand how I understand it contributes to the feeling that someone else wrote it for me.
The problem I have looking at APL is that it doesn't look like it would help with this kind of work. The examples in the paper are all mathematical and abstract. I'd like to see some real-world practical examples, where performance matters, IO is fiddly and memory layout is part of the API. And instead of the problem domain being "differentiating a polynomial", I'd rather it was decoding the Huffman data out of a JPEG, or implementing a video game's collision detection system. My feeling is that C like notations are better for that type of thing. Maybe that isn't what APL is supposed to be good at. However, the paper starts by saying APL is needed because maths notation is not universal.
"The plan which is, recommended by the United States provides for certain discrete frequencies, with appropriate guard bands, for those industrial scientific and medical devices which cannot be shielded effectively. This assures a minimum disruption of vital communication services. The allocation of frequencies for this purpose is justified because of the tremendous investments in equipment and the public demand for the various services performed, together with the harmful interference to radio communications which would result if such devices were scattered indiscriminately throughout the spectrum. The frequencies proposed are:
13660 kHz
27320 kHz
40980 kHz
2450 MHz"
http://handle.itu.int/11.1004/020.1000/4.62.51.en.108, page 628.
"effective penetration and heating favors wavelengths in the cm range (1–30 GHz). Higher frequencies cannot penetrate sufficiently, and much lower frequencies require very high fields, and can have poor coupling unless making use of direct contact or inductive heating. In the years following WWII, emphasis was thus placed on frequencies in the low GHz region, where both the historic development of microwave power sources and serendipity converged."
https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=9393469
In 1952, a paper called Tubes for dielectric heating at 915 megacycles said this, "Dielectric heating can be much faster at microwave frequencies. Because leakage radiation is large enough to interfere with communications, heating is best done at assigned frequencies. The bands at 915 and 2,450 megacycles are most useful."
Admittedly Intel having its own fabs looks good while everyone else is struggling for capacity, but I assume that will be fixed eventually. When it is, I expect Intel's decline to hasten.
Intel are already experimenting with using other people's fabs. I think this is their best path.
>for loop can only be used to iterate over elements of an array, if you want to just execute a block N times, you need while…
The Zig docs suggest something like this:
var i: usize = 0;
while (i < 10) {
i += 1;
}
Is there a plan to provide a mechanism to stop "i" from remaining in scope after the end of the loop? I couldn't find anything relevant with a quick web search.I use integer iterating for-loops a lot in C. I just checked a 5000 line project of mine that deals with bitmaps. There are 100 occurrences of something like:
for (int i = 0; i < 10; i++) {
I think these would all become while-loops in Zig. Exposing 100 variables to a larger scope than they need to be sounds like a source of bugs to me.I think I disagree, although I prefer C to C++ these days. I posit that memory safe programming languages are more complex than C and sometimes cause code that would be simple in C to be written in a more complex way to allow the memory safety to be maintained. I posit that complexity is one of the causes of security vulnerabilities.
Regarding, "Quarks are the fundamental building blocks", do we actually think that? If so, why? I'm genuinely curious. Is it just because we haven't seen anything more fundamental? That would violate your "We now think that" qualifier - ie if that is the reason, the qualifier should be "We have NO reason to think that...".
That's an interesting observation. I'd say engineering does have abstractions, but they're much better. For example, treating an RSJ as a simple uniform piece of material is an abstraction. In reality it is a crazily complex mesh of crystals. But the abstraction is simple and well studied, so it can be used reliably.
Programming abstractions are less reliable. Even commonly used ones like "the filesystem" and "the heap" are vastly more complex. It is almost impossible to remember all the possible hazards when you use them.