HackerTrans
TopNewTrendsCommentsPastAskShowJobs

quelsolaar

no profile record

Submissions

Undefined behaviour spotted in safe Rust code

twitter.com
2 points·by quelsolaar·7 माह पहले·1 comments

comments

quelsolaar
·2 माह पहले·discuss
I was luck to know Josh Nimoy who is responsible for a lot of this in the movie, who has since sadly passed away. Josh took great pride in the fact that he was able to put Emacs and a bunch of Unix commands in a major Hollywood blockbuster.ed
quelsolaar
·2 माह पहले·discuss
The things you want from C isn't C. Id advice you to use another language.
quelsolaar
·2 माह पहले·discuss
A lot of the Central UB can not be defined, because they rely on detection. In order to have a well defined behaviour (by the standard or the compiler) the implementation needs to first detect that the behaviour is triggered, this is often very tricky or expensive. Its easy to define that a program should halt, if it writes outside an array, but detecting if it does can be both slow and hard to implement. There are implementations that do, but they are rarely used outside of debugging.

A better way to think about UB is as a contract between developer and implementation, so that the implementations can more easily reason about the code. How would you optimize:

(x * 2) / 2

An optimizer can optimize this out for a signed integer, because it doesn't have to consider overflow, but with a unsigned integer it can not. UB is a big reason why C is the most power efficient high level language.
quelsolaar
·2 माह पहले·discuss
The 5 stages of learning about UB in C:

-Denial: "I know what signed overflow does on my machine."

-Anger: "This compiler is trash! why doesn't it just do what I say!?"

-Bargaining: "I'm submitting this proposal to wg14 to fix C..."

-Depression: "Can you rely on C code for anything?"

-Acceptance: "Just dont write UB."
quelsolaar
·3 माह पहले·discuss
Mark down is great because it doesn't define a bunch of things. Headline? Its a headline, no font, no sizing, no colors... Just a headline. It means that it can be displayed on any device, printed on any paper, work with any accessibility tool and optimized for what ever requirements the reader has, not what ever the writer thought looked good. The web is full of great content being made hard to access because of poor/inflexible layout choices. Just give me the text and let me choose how to make it readable. The added fact that you can read raw markdown without even parsing it makes it even better. Not having total control over what its going to look like for the reader is a feature not a bug.
quelsolaar
·3 माह पहले·discuss
Do not make the mistake of anthropomorphising Larry Ellison.
quelsolaar
·7 माह पहले·discuss
This, "If you have enough, why does it matter if someone else has more" argument doesn't really hold. Yes we can make more TVs and phones so that everyone can get one, but then get to things like centrally located housing, where there is a limited supply. It matters a lot if you want someplace to live, and there are thousands of very rich people trying to out bid one and other for the same space in your city. This is why housing is no longer affordable.
quelsolaar
·7 माह पहले·discuss
Thanks for the shout out. I had no idea my 2h video, without a camera 8 years ago would have such legs! I should make a new one and include why zero initialization is bad.
quelsolaar
·9 माह पहले·discuss
Yeah the idea i that school is somehow a bastion of meritocracy is misguided.

Academia is better at setting clear requirements and measuring those goals, but whether these requirements have anything to do with being successful or useful in the real world is an entirely different matter.

School isn't reality, its mostly not even trying to simulate reality. School breads a lot of "Why was I not rewarded? I did everything they said i should do" disappointment in the real world.
quelsolaar
·10 माह पहले·discuss
This is awesome. I run a team that uses software I produce and i have a rule that i can’t deliver breaking changes, and i cant force migrations. I can do the migration myself, or i have to emulate the old behavior next to the new. It makes you think really hard about releasing new APIs. I wish this was standard practice.
quelsolaar
·12 माह पहले·discuss
Writing in binary or cranking your own electricity is easy. Anyone can do it.

There is a difference between things that are difficult and things that just take a lot of work.
quelsolaar
·12 माह पहले·discuss
Your customers will pay more for things that are hard to do. Ask ASML.
quelsolaar
·12 माह पहले·discuss
I exclusively write in C89. I'm a member of the ISO C standard board.
quelsolaar
·12 माह पहले·discuss
When ever i see "never implement your own...", i know i want to implement it myself. People say that about hard things, and I only want to do hard things. Nobody wants people who can do easy things, people want people who can do hard things. The only way to learn how to do hard things, is to do hard things, so do the hardest things.

So go ahead, write your own date library, your own Unicode font rendering, compiler, OS, game engine or what ever else people tell you to never do because its hard.
quelsolaar
·पिछला वर्ष·discuss
Gaza has changed.
quelsolaar
·4 वर्ष पहले·discuss
Im the CTO of a company that got funded, about the first time i became a parent. In the year since i have been promoted to CEO. Living in Sweden i have access to generous paternity leave, but taking it out would kill my company.

Some how im making it work and am pretty close to an equal parent. You learn tricks, like you best friend is a headset. Keyboard time is extremely valuable, so i try to use it for code, and use voice for a lot of communication. I love my job so if i can spend 8h working and 8h with my son life is good and i dont need more, if i can do both like taking a meeting when in the park things are stellar.

Dont get me wrong its hard, but loving what you do is the key to doing anything that is hard.
quelsolaar
·5 वर्ष पहले·discuss
No I do not. I run ISO conformant C without options.
quelsolaar
·5 वर्ष पहले·discuss
Thanks! I didn't know that!
quelsolaar
·5 वर्ष पहले·discuss
Interesting perspective. I dont have the same experience. To me a wraping 32 bit index on a 64bit machine is much more likely to seg fault if it reads 4 billion values forward, rather than a few bytes backwards and therefore i find unsigned index wrapps to be easier to debug. In all fairness wrapping indicies are an extremely rare bug for me, so i cant say i have much experience debugging it.
quelsolaar
·5 वर्ष पहले·discuss
I agree with this almost entierly and i use almost exclsivly unsigned ints in C.

However, its not true that unsigned is faster because the compiler can optimize. Consider:

x = (x * 2) / 2;

If x is unsigned, and overflows, x will not be the same after this operation so the compiler can not optimize away this line. If x is signed and overflow is undefined, the compiler can assume it wont overflow and optimize away the line. UB affords the compiler a lot of optimizations.