Better HN
topnewbestaskshowjobs
Log inSign up

codedokode

9,867 karma · joined Aug 20, 2015 (11y ago) · 5,528 submissions

PHP developer from Russia.
Submissions

comment 3y ago · link · parent

Your phone number and messages can easily be leaked if there is a vulnerability in your smartphone OS or Signal app. However if you use a messenger not requiring a phone number, then attacker gets only the messages.

Also as I understand you have to give your number to your contacts to be able to chat with them. For comparison, Telegram allows adding contacts without sharing a phone number. So in Signal all contacts know your real identity and your location.

comment 3y ago · link · parent

> activated in a very odd location once only before being destroyed.

Phone numbers are recycled so eventually it will become someone else's phone number unless you continue paying for it.

comment 3y ago · link · parent

In my opinion "secure messenger" should protect from any actor. If we start making exceptions then it cannot be called secure anymore.

Signal requires extra information that is not necessary for exchanging messages. That is at least suspicious. If you are fine with giving away your number you can just use WhatsApp or Telegram.

comment 3y ago · link · parent

Signal requires a phone number which is linked to identity and precise location.

comment 3y ago · link · parent

> In your "unsafe" example in Rust, you still don't get undefined behavior.

You get an unexpected behaviour instead. For example, imagine if you had a device for counting amount of bytes transferred over the network. If the counter overflows, you will get the wrong number, and issue an invalid bill to the customer. While that is a "defined" behaviour that is not what one expects.

I expect the counter either to work correctly according to normal math rules or indicate that it cannot perform the task due to hardware limitations.

One might blame the developer but history shows that developers fail to take account of overflow. For example, experienced developers writing Linux kernel made several mistakes, which lead to security vulnerabilities.

In most cases developers need standard math, not operations modulo 2^32 or 2^64. When you count bytes, you need an exact amount, not an amount modulo 2^32. Why do language designers provide modulo operations instead of normal math I don't understand.

Rust has chosen a weird path when the program works differently in debug and release mode. This is clearly wrong. I expect the same program to work the same way no matter whether optimizations are enabled or not.

comment 3y ago · link · parent

I mean every memory access can cause an exception and handling an exception is a kind of branch.

comment 3y ago · link · parent

> There may be a water purifier somewhere running in a 1995 x86 box that still needs to be maintained.

Then they can use 1995 year compiler with unsafe arithmetic.

comment 3y ago · link · parent

> Also, safety is not always a top requirement.

Safety is the requirement for desktop, mobile and server processors but x86 and ARM penalize using safe math operations (you have to insert branch instructions).

> There are a lot of CPU architectures and their variants, some older than 40 years, and C is supported on most of them.

Between safety on modern CPUs and supporting 40-years CPU I would choose the first.

comment 3y ago · link · parent

Sadly the macros they proposed are ugly, long to type and hard to read. People will not use them.

comment 3y ago · link · parent

They are longer to type than `+`.

It is easy to write unsafe code and difficult to write safe code. As a result, while most mathematical operations must be safe, developers use unsafe operations because they are easier to type and more readable.

Operators like `+` should be equivalent to checked_add().unwrap(), not to unchecked_add(). Why choose unsafe and rarely used operation as a default? It is a mistake. Swift uses sane defaults.

UPD: for example, let's say we need to allocate memory for N elements of size S and a header of size H. Here is the unsafe code:

    u32 s = N * S + H
And here is safe code:

    u32 s = checked_add(checked_mul(N, S).unwrap(), H).unwrap()
And here is safe code in Swift:

    let s: Uint32 = N * S + H
And unsafe code in Swift:

    let s = N &* S &+ H

comment 3y ago · link · parent

I think it was a mistake when CPU and language designers decided to make overflow in arithmetic operations not an error. This is wrong. Overflow can produce invalid data, which can break something elsewhere. Overflow has been a reason for security vulnerabilities.

For example, you don't want to have an overflow when calculating a total cost of ordered goods or size of an allocated memory block.

One could argue that it is a developer's responsibility to make sure overflow doesn't happen, but the history shows that developers usually fail to protect the program from such kind of errors. We have memory protection, why cannot we have overflow protection?

In my opinion, an overflow should cause an exception unless the program explicitly asks to ignore it. Of course this means that every addition now becomes a (very unlikely) conditional branch, but I guess this can be optimized by static prediction. Every memory access is already a conditional branch, and it doesn't cause problems.

But CPUs and programming languages seems to make writing overflow-safe code more difficult than unsafe. In assembly, you have to insert additional branch instructions, and in business-oriented languages like Java you have to write long sentences like Math.addExact(). If you write a complicated formula this way, it becomes unreadable.

Sadly, modern languages like Rust haven't fixed the mistake and also penalize writing safe code.

The only language I know with overflow protection is Swift: an overflow causes an exception there. Well done, Apple, you are lightyears ahead of open source software.

comment 3y ago · link · parent

I don't understand why one needs to emulate a virtual machine to run a container. Why do you need a kernel? Why emulate physical devices, interrupts and everything else? Why cannot one run a container as a protected mode application?

comment 3y ago · link · parent

I guess that arithmetic operations are not very slow in Python, but if you use objects, then Python performs complicated lookups for every field or method access.

comment 3y ago · link · parent

As I understand, in low-level languages the concept of ownership exists anyway, no matter whether the language allows to declare it explicitly or not. Rust just makes you write it out explicitly.

comment 3y ago · link · parent

> The biggest of said problems is that the garbage collector has the annoying habit to “pause the world”.

I think that main problem of garbage-collected programs is that they usually allocate several times more RAM than they use. This causes excessive swapping which produces more noticeable lags than just garbage collection. I vaguely remember reading somewhere that the difference can be 6x, but I am not sure if this is the correct number. This means that garbage-collected software is great for large expensive servers stuffed with RAM sticks but not so great for a personal computer having just 4 or 2 Gb.

comment 4y ago · link · parent

It is unfair indeed. A fair solution would be to improve conditions for everyone so that they can live in comfortable conditions before trial.

comment 4y ago · link · parent

> Intel's market segmentation on ECC memory is, however, garbage.

Any segmentation is garbage because instead of making the best product possible a company instentionally makes it worse.

comment 4y ago · link · parent

While unrelated to this, I would like browsers to suspend background tabs and maybe even compress their data and unload information that can be restored later (for example, unload images from memory, drop JS bytecode and JIT caches). Majority of websites have no need to do anything when I am not watching them.

Of course there are cases when you need some background activity, for example if you are listening to music or running a program. As I understand, it is extremely difficult do distuinguish between tabs doing useful work and not doing. I would be fine with a manual switch to allow site run in background.

comment 4y ago · link · parent

This project is interesting, but I looked at tests folder and there is not many tests despite software is so complex. Also I wonder, isn't it better to write tests in languages like Python?

Also, I don't see what's the use of Cosmopolitan Libc. In what situation does one need a CLI-only binary that can run on any system?

comment 4y ago · link · parent

Isn't it dangerous? What if Earth will freeze inside because of this and become like Mars or Moon?

comment 4y ago · link · parent

One of the reasons why it became like this is because there is no protocol that would allow a host to request blocking traffic from other host on upstream provider (so that malicious traffic is blocked close to originating network). If there was such protocol, site owners could protect from attacks themselves, but without it you have to use Cloudflare unless you are Google scale with channels wider than attacker's.

comment 4y ago · link · parent

Cloudflare might end a golden era of scraping, when it was trivial to scrape data from any site. Now Cloudflare helps site owners to make sure than only humans can read their contents manually. As more site owners switch to similar services, web will become less and less machine readable. No automated data processing, no archiving.

comment 4y ago · link · parent

In this case AMD could also claim that they translate instructions in their CPU before execution.

comment 4y ago · link · parent

Don't you think that the punishments are too severe? Severe punishments should be for violent crimes, not for stealing several thousands dollars from authors.

comment 4y ago · link · parent

Doesn't Rosetta infringe on Intel's copyrighted instruction set and architecture of a CPU? Why Apple can use this instruction set and others cannot?

UPD: and ARM seems to be infringing as well:

> There’s a standard ARM alternate floating-point behaviour extension (FEAT_AFP) from ARMv8.7, but the M1 design predates the v8.7 standard, so Rosetta 2 uses a non-standard implementation.

> (What a coincidence – the “alternative” happens to exactly match x86.

Good luck persuading a judge that this was "a coincidence".

comment 4y ago · link · parent

> You're also conflating a savings/checking account with investing

As I understand, investing is a risk because you can lose everything and nobody will compensate you. Investments are not covered by FDIC insurance or similar systems in other countries.

But as for gold, your gold will stay with you unless the government decides to confiscate it.

comment 4y ago · link · parent

He is not losing though because potentially Russia can mobilize 20-40 millions of soldiers or even more if he convinces other countries like Belarus or Iran to help him.

comment 4y ago · link · parent

I meant cryptocurrency like Bitcoin which is incredibly difficult to mint.

comment 4y ago · link · parent

As I understand, the interest rates for deposits in developed countries are too low to compensate inflation.

comment 4y ago · link · parent

> When the bank goes bust there's insurance on your deposits

Usually it covers only limited amount, not full deposit. In US it seems to be generous $250 000 but in other countries it is much lower (e.g. just about $20 000 here).

> gold is practically hard to work with and barely functions as an inflation hedge

And deposit interest rates are often below inflation in developed countries.

1
103104105
185