• 0 Posts
  • 66 Comments
Joined 11 months ago
cake
Cake day: July 27th, 2023

help-circle

  • This is a use-after-free, which should be impossible in safe Rust due to the borrow checker. The only way for this to happen would be incorrect unsafe code (still possible, but dramatically reduced code surface to worry about) or a compiler bug. To allocate heap space in safe Rust, you have to use types provided by the language like Box, Rc, Vec, etc. To free that space (in Rust terminology, dropping it by using drop() or letting it go out of scope) you must be the owner of it and there may be current borrows (i.e. no references may exist). Once the variable is droped, the variable is dead so accessing it is a compiler error, and the compiler/std handles freeing the memory.

    There’s some extra semantics to some of that but that’s pretty much it. These kind of memory bugs are basically Rust’s raison d’etre - it’s been carefully designed to make most memory bugs impossible without using unsafe. If you’d like more information I’d be happy to provide!





  • He was in his apartment. There was a call to the police about an argument in the building. The officer went to an apartment that is said the be the wrong one, banged on the door and shouted to open up. Fortston answered the door with a piston in his hand, pointing at the floor. The officer shot him.

    According to the media, Forston was on the phone with his girlfriend for a while by the time the police were called. It seems to me that, as far as the officer was aware, the only “crime” that occured was “an argument”, and it sounds like the officer also had the wrong apartment. Unless I can view the bodycam footage it’s hard to be certain but this definitely sounds like he was killed because he was black and had a gun.




  • As spacecraft reenter the atmosphere from orbital speeds, they’re going so fast that the atmosphere is compressed enough (and so gets hot enough) to free the electrons from the atoms in the air. This forms plasma. The special thing here is that we got live video during this portion of reentry; the free electrons in plasma heavily interfere with radio communications, so in previous missions there has been a full communications blackout at that time. Starship did not experience that blackout, which is unique. I’m not qualified to say exactly why, but the team was stressing that Starship is big enough that it “punches a hole through the atmosphere”. Another factor could be the 4(?) starlink terminals on the leeward side providing redundant communications signals.



  • I was very intrigued by a follow-up to the recent numberphile video about divergent series. It was a return to the idea that the sum of the integers greater than zero can be assigned the value -1/12. There were some places this could be used, but as far as I know it was viewed as shaky math by a lot of experts.

    As far as I recall the story goes something like this: now, using a new technique Terrence Tao found, a team was seemingly able to “fix” previous infinities in quantum field theory - there’s a certain way to make at least some divergent series work out to being a real number, and the presenter proposed that this can be explained as the universe “protecting us” from the infinities inherent in the math.

    It made me think about other places infinities show up in modern physics (namely, singularities in general relativity) and whether a technique something like this could “solve” them without a whole new framework like string theory is.




  • The issue is that, in the function passed to reduce, you’re adding each object directly to the accumulator rather than to its intended parent. These are the problem lines:

    if (index == array.length - 1) {
    	accumulator[val] = value;
    } else if (!accumulator.hasOwnProperty(val)) {
    	accumulator[val] = {}; // update the accumulator object
    }
    

    There’s no pretty way (that I can think of at least) to do what you want using methods like reduce in vanilla JS, so I’d suggest using a for loop instead - especially if you’re new to programming. Something along these lines (not written to be actual code, just to give you an idea):

    let curr = settings;
    const split = url.split("/");
    for (let i = 0; i < split.length: i++) {
        const val = split[i];
        if (i != split.length-1) {
            //add a check to see if curr[val] exists
            let next = {};
            curr[val] = next;
            curr = next;
        }
        //add else branch
    }
    

    It’s missing some things, but the important part is there - every time we move one level deeper in the URL, we update curr so that we keep our place instead of always adding to the top level.