News for hackers. Stuff that matters.
Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by vore on Tuesday October 17, 2023 @04:23PM (#37921044)
You say that as if that's a bad thing – I absolutely need to kept safe from myself, because I need all the help I need to make sure I'm doing things right!
Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by sargstuff on Tuesday October 17, 2023 @05:09PM (#37921592)
use a malloc that has the extra saftey features, run under an interpreted C, and several other ways to handle it (sandbox program, emulator, etc). Changing the underlying C language should NOT be one of them.
Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by AlotOfReading on Tuesday October 17, 2023 @08:27PM (#37923410)
The only way to make C "safe" without modifying the language is to run it in a VM, and even that doesn't fully encompass what people mean by safety.

It's an old language. Some of the fundamental mistakes were just things that were common at the time and only look so bad in hindsight (e.g. strings, locales, nullable pointers, half the k&r standard library). That doesn't mean we can't and shouldn't do better where we can though.

Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by pjmlp on Wednesday October 18, 2023 @02:59AM (#37925595)
Example, C++/CLI, if certain code patterns are used the code is no longer considered safe from MSIL verifier point of view.

C and C++ targeting WASM, despite all the security message of how great it is, memory locations inside of the same linear memory segment can still be corrupted, thus providing a way to influence the overall execution logic inside of the sandbox.

Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by sargstuff on Wednesday October 18, 2023 @04:09PM (#37934124)
Oh, so time of 4k memory, have a 4k program and want to strictly reserve/add 3.14159 K to 4k program for automated saftey issues?

At time C was written, swapping in/out of memory measured in literal minutes & when fraction of second of execution time, including swapping in/out of memory, was more than several times the average yearly salary of the day (excluding sneaker net intervention)

Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by zh3 on Tuesday October 17, 2023 @05:29PM (#37921858)
I'd agree with that, to the extent that understanding how badly your tools can hurt you is an important thing to learn.

Consider how a surgeon would respond if told not to use a scalpel because of the risk of accidental injury when using a sharp tool.

We learn from our mistakes - to which I'd add, sometimes we can afford to make mistakes (home programs) and other times we can't (safety-critical code).

Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by ilyt on Tuesday October 17, 2023 @07:11PM (#37922791)
Surgeon would absolutely use a tool that tells them when they're about to make something that's 99% of the time a mistake.
Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by ecshafer on Tuesday October 17, 2023 @07:18PM (#37922856)
I think a more accurate analogy would be some kind of scalpel that would not let the surgeon cut deeper than they needed. So if they needed a 1 cm incision, it would somehow stop the blade form going in 1.1 cm. In that case, some experienced surgeon may say "But I know how to make a 1cm incision!", but I think that the reality is that preventing a mistake from happening is valuable.

You see the same arguments against static analysis, unit tests, strong type systems, etc. The evidence seems to favor systems which prevent errors over artisinal expertise.

Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by Kamq on Tuesday October 17, 2023 @07:42PM (#37923024)
I think an even more accurate analogy would be if a surgeon had some kind of scalpel with a 1 cm limit, but if a surgery suddenly changes in the middle, and suddenly requires a deeper incision, the surgeon has to spend a non-zero amount of time re-configuring the scalpel.

This casts flexibility vs safety as a tradeoff, which it is.

Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by SilasX on Tuesday October 17, 2023 @11:51PM (#37924678)
Oh, one more refinement:

Surgeons are constantly killing people[1], and every time, it turns out it was because the surgeon disabled a known, recommended safety rail, and whenever anyone points out that they should stop disabling the safety rails, they insist that they know how to operate without them, it's those other people that don't. Plus it's sooooo inconvenient for an operation[2] to take five more minutes, they're too good to have to deal with that.

[1] introducing security vulnerabilities

[2] code changeset submission

Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by dekhn on Wednesday October 18, 2023 @03:56PM (#37933940)
The one thing I remember from watching my wife's surgery is that they counted the surgical sponges going in, and counted them coming back out. Because sometimes surgeons would forget and leave a sponge inside and then the person woudl get a really bad infection.

Honestly, checklists and procedure matter more than most people want to admit.

Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by sargstuff on Wednesday October 18, 2023 @04:05PM (#37934067)
Was LD_LOAD and related LC stuff (algebra & unix) the 19th c rabbit hole for [1] & [2] ?

1] introducing security vulnerabilities

[2] code changeset submission

Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by steveklabnik on Tuesday October 17, 2023 @08:23PM (#37923380)
https://www.sawstop.com

This is my favorite one

Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by pjmlp on Wednesday October 18, 2023 @02:56AM (#37925569)
That surgeon has undergone several years training, had to go through an exam to be allowed to practice, and is submited to yearly evaluations if they are still allowed to touch that scapel.

I would agree the same for developers, if similar practices would be enforced everywhere instead of having people calling themselves enginners just because they like how the word sounds.

Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by kortilla on Wednesday October 18, 2023 @03:47AM (#37925920)
Yet surgeons killed people all of the time and had to be forced to use checklists because it turns out credentialism doesn’t prevent mistakes.
Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by pjmlp on Wednesday October 18, 2023 @05:00AM (#37926337)
Which is also something that we need to add as well, on top of credentialism.

More quality and process validation, less cowboy programming.

Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by kortilla on Wednesday October 18, 2023 @08:39AM (#37927760)
And skip the credentialism, because that’s generally bullshit.
Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by pjmlp on Wednesday October 18, 2023 @08:55AM (#37927911)
Not at all, that is a guarantee that people actually know how to hold the scapel and can enter the operating room safely.

A brick layer doesn't turn into a Construction Engineer, only because they think they know everything about building houses, and have somehow built their own during long weekends.

Likewise a coder out of a bootcamp, isn't someone versed in what actually entails to be a Software Engineer, regarless how cool the title might sound like.

Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by kortilla on Wednesday October 18, 2023 @09:02AM (#37928032)
No, it’s not a guarantee, it’s just a noisy filter with a very high false negative rate and a high enough false positive rate (as visible in malpractice insurance).
Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by pjmlp on Wednesday October 18, 2023 @03:33PM (#37933624)
I certainly is, those numbers would be much higher without that filter.
Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by kortilla on Thursday October 19, 2023 @10:25AM (#37943347)
I don’t think you know what “guarantee” means. If it was a guarantee, malpractice insurance wouldn’t exist.