Preferences

apple1417
Joined 37 karma
https://apple1417.dev

  1. The MSVC linker has a feature where it will merge byte-for-byte identical functions. It's most noticeable for default constructors, you might get hundreds of functions which all boil down to "zero the first 32 bytes of this type".

    A quick google suggests it's called "identical comdat folding" https://devblogs.microsoft.com/oldnewthing/20161024-00/?p=94...

  2. My most common source of unintentional BOMs is powershell. By default, 'echo 1 > test' writes the raw bytes 'FF FE 31 00 0D 00 0A 00'. Not too likely for that to end up in a shell script though.
  3. In normal use it's essentially the same yes. The one interesting edge case that might catch some people out is there's actually nothing special about std::exception, you can throw anything, "throw 123;" is valid and would skip any std::exception handlers - but you can also just catch anything with a "catch (...)".
  4. I recently started working on a repo which historically had 100+ parallel branches. I've been jumping between a few tools recently trying to find something which handles browsing these sanely - I always liked browsing graphs, but the sheer amount of branches ruins most of them.

    Currently the best workflow I've worked out is just a plain

        git log --oneline --graph -- <dir>
    
    Followed by showing the specific commits. But this doesn't work so well with MRs that touched many files across different dirs. Anyone have suggestions for tools that might handle this better?
  5. An interesting example was Borderlands 2. The game originally had a native port by Aspyr, which worked quite well. 5 years pass and they release a new update and DLC - but they neglected to update the ports. 5 more years pass, then at some point in the past year or two they just plain removed the native Linux packages. They didn't announce it or anything so not 100% sure when. So these days when you install it you always get the (updated) Windows build under proton.

    I'm a little sad we lost the native version, but on the other hand running it under proton just works, as I'd been doing for years, and the game would never have been updated otherwise.

  6. If you have an older game which still uses dx9, dxvk can give a decent little performance boost - even if you're running on Windows. It's kind of magical that adding a translation layer is able to improve performance.

    In more modern games using dx11/12, I've always noticed a small loss like you'd expect. I haven't properly benchmarked any but I suspect a game with native Vulkan support would do pretty similarly, and might come out on top due to CPU load.

  7. They exist, but one of the problems is they're not particularly good cubes. While it might help you learn the basics, not being able to handle it like a speedcube means they're probably not going to help you get faster.

    https://m.youtube.com/watch?v=l-TWH5W-1fw

    https://exmarscube.com/product/ex-mars-ai-robot-cube/

    That being said, while looking up those links, I found out that, since I got out of the hobby, smart cubes have become a thing, and are made by real speedcube manufacturers.

    https://www.gancube.com/products/gan-356-i-carry-smart-magic...

    This is an easier problem to solve. I'm not sure if you have to solve it first or if it can identify pieces on power up, but after that it's just tracking rotations, which can be done from the (fixed position) centres alone. But if an actual speedcube manufacturer can already fit those electronics in without comprising performance, I can't imagine it's that much harder to fit some addressable LEDs on some slip-ring-esque connections. Must just not be much of a market.

  8. I'll preface this by saying my experience is with embedded, not kernel, but I can't imagine MMIO is significantly different.

    There would still be ways to make it work with a more restricted intrinsic, if you didn't want to open up the ability for full pointer forging. At a high level, you're basically just saying "This struct exists at this constant physical address, and doesn't need initialisation". I could imagine a "#define UART zmmio_ptr(UART_Type, 0x1234)" - which perhaps requires a compile time constant address. Alternatively, it's not uncommon for embedded compilers to have a way to force a variable to a physical address, maybe you'd write something like "UART_Type UART __at(0x1234);". I believe this is technically already possible using sections, it's just a massive pain creating one section per struct for dozens and dozens.

    Unfortunately the way existing code does it is pretty much always "#define UART ((UART_Type*)0x1234)". I feel like trying to identify this pattern is probably too risky a heuristic, so source code edits seem required to me.

  9. On a recent 12h Air New Zealand flight I went on they offered free wifi for everyone. They say you can:

    - Browse the web.

    - Send and receive emails and messages.

    - Check and post to social media

    In practice I think they just whitelist a few messenger apps. Everything else was unusable - I couldn't even load this site. Only had my phone so couldn't check if I was actually receiving any bytes from other sites, but it at least wasn't immediately blocked.

  10. 2800 day streak here, primarily in Finnish. I haven't been a fan of the app for a long time, but the problem I've always had switching is the question: What else? There might be a thousand different Spanish courses, but for less popular languages there just aren't many choices, the fact that they still host one is great. Yes I haven't really learnt much, it's more maintaining what I do know, but I'd've lost it without.

    Incidentally I do think Finnish is one of the cases where it could work well. The way I see it the difficulty in learning Finnish is primarily learning an entirely new vocabulary, the grammar and sentence structure isn't that hard, and Duolingo could work well to teach you thousands of new words. The problem is they have a very limited amount of exercises, to the point my phone's auto complete can solve half of them.

    ---

    Please don't just link me stuff you've found on Google, I've tried them all. My favourite was Yle Kielikoulu, but that's been shut down.

  11. I once got a "log into phishing training" email which spoofed the company address. No one even saw the email, it instantly hit the spam filter.

    Our infra guy then had to argue with them for quite a while to just email from their own domain, and that no, we're weren't going to add their cert to our DNS, and let a third party spoof us (or however that works, idk). Absolutely shocking lack of self awareness.

  12. Not OP, outside of games I keep a dual boot pretty much exclusively for Visual Studio - imo it's one of the best debuggers I've ever used. I know gdb is just as powerful if not more, but it is so much less ergonomic, even with the different frontends I've tried. Edit and continue for C/C++ is such a killer feature too. I stick away from msbuild or using it as an editors it's purely my debugher.

    Granted it helps that a lot of the time I need "advanced" debugging relates to msvc/windows specific issues, which while I could run it in wine, it's just easier if I'm on windows anyway.

  13. On one of the projects I worked on, I brought a PIC16 down to ~20nA - where our fancy meter only went down to 10nA precision. It was completely unnecessary, but I'm still quite proud of it.

    For more standard cases, the 43uA from the article is roughly the same order of magnitude you'll get from pretty much any micro in sleep mode, after doing your first pass low power optimisation. The stuff I normally work with gets about 10. The thing is just, most of the time, that's low enough already - for this project 2500mAh/43uA = 6 years of sleeping. The bigger factor is the current it consumes while awake - and that's where the Arduino's a bit of a letdown, the stuff I normally use is only in the order of 100uA while awake.

  14. I've worked on several low power projects, while yes we needed an interrupt to wake the processor, they all still used polling for all the actual button handling. At worst the interrupt just set a flag. It's actually kind of amazing how polling turns the main loop into a denounce filter, entirely for free.
  15. Having run into similar problems several times, I've also never really been satisfied with the solutions. You have to have different types to cause compile errors, but then you have throw those types away whenever you perform any actual operations on them.

        struct TypeA { int inner; };
        struct TypeB { int inner; };
    
        struct TypeA a1, a2;
        // whoops
        TypeB result = {.inner = a1.inner + a2.inner};
    
    Don't get me wrong, where I've used this sort of pattern it's definitely caught issues, and it definitely massively lowers the surface area for this type of bug. But I still feel like it's quite fragile.

    The use case I felt worked best was seperating out UTC datetime vs localised datetime structs - mainly since it's something you already had to use function calls to add/subtract from, you couldn't play with raw values.

  16. I've seen something related, which returned a bool instead of failing compilation, be used to switch between a path the optimiser could inline and some assembly. You could probably use this to make sure it was always inlined.
  17. It depends on what orbit you want. Due to the latitude you'll end up pretty inclined by default - which is bad for equatorial orbits sure, but a good start for polar ones. At a public session I went to several years back they spoke of specifically trying to attract polar launches for that reason.
  18. That was actually recently added as a built-in feature

    https://code.visualstudio.com/updates/v1_97#_git-blame-infor...

    Like the sibling comment, I didn't want to run all of GitLens just for it, but now that it's a built-in I've also been finding it quite useful.

  19. Reading the PEP for adding it, it seems primarily concerned with mirroring how the C builtins generally don't allow it, for performance.

    https://peps.python.org/pep-0570/#rationale

    That being said, you can find quite a lot of uses in the modules written in Python - though I'm not going to pretend I can tell you the reasoning for all them.

      grep "/\s*[,)]" /usr/lib/python3.13/ --recursive --include "*.py" --exclude-dir site-packages
    
    In my own code, the main use I've found is that they don't "reserve" a slot in kwargs - this is totally valid code:

      def func(x, /, **kwargs):
        print(x, kwargs)
      func(1, x=2)
    
    You could've worked around it by taking a dict before, but it's just a lot friendlier being able to take args as normal.
  20. > For regular programmers, if your machine won't boot up, you are having a bad day. For embedded developers, that's just a typical Tuesday, and your only debugging option may be staring at the code and thinking hard.

    Of course where it becomes even more fun is when it's a customer's unit in Peru and you can't replicate it locally :). But oh how I love it. I have definitely spent many a day staring at code piecing things together with what limited info we have.

    But to get back on topic, I can definitely confer on the quality of most embedded compilers. It's a great day when I can just use normal old gcc. I've never run into anything explicitly wrong, but I see so many bits of weird codegen or missed optimisations that I keep the disassembly view open permanently, as a sanity check. The assembly never lies to you - until you find a silicon bug at least.

  21. I have worked on a device with this exact same "send a tiny sensor reading every 30 minutes" use case, and this has not been my experience at all. We can run an STM32 and a few sensors at single digit microamps, add an LCD display and a few other niceties and it's one or two dozen. Simply turning on a modem takes hundreds of microamps, if not milliamps. In my experience it's always been better for power consumption to completely shut down the modem and start from scratch each time [1] - which means you're paying to start a new session every time anyway. Now I'll agree it's still inefficient to start up a full TLS session, a protocol like in the post will have it's uses, but I wouldn't blame it on NAT.

    [1] Doing this of course kills any chance at server-to-device comms, you can only ever apply changes when the device next checks in. This does cause us complaints from time to time, especially for those with longer intervals.

  22. You can actually usually get a pretty good starting point from just a single build, and only refine it once you find a build it breaks on. It's essentially just finding a unique substring. In my experience this almost always involves some wildcard sections, so the signature in the parent got lucky not to need them. I like to think about it as more of matching the shape of the original instructions than matching them verbatim.

    To manually construct a signature, you basically just take what the existing instructions encode to, and wildcard out the bits which are likely to change between builds. Then you'll see if it's still a unique match, and if not add a few more instructions on. This will be things like absolute addresses, larger pointer offsets, the length of relative jumps, and sometimes even what registers the instructions operate on. Here's an example of mine that needed all of those:

      "48 8B ?? ????????",        // mov rcx, [rdi+000001D0]
      "48 85 C9",                 // test rcx, rcx
      "74 ??",                    // je Talos2-Win64-Shipping.exe+25EE729
      "E8 ????????",              // call Talos2-Win64-Shipping.exe+25E45F0
      "48 63 ?? ????????",        // movsxd rax, dword ptr [rbx+000005D0]
      "8D 70 FF"                  // lea esi, [rax-01]
    
    
    Now since making a signature is essentially just finding a unique substring, with a handful of extra rules for wildcards, you can also automate it. Here's a ghidra script (not my own) which I've found quite handy.

    https://github.com/nosoop/ghidra_scripts/blob/master/makesig...

This user hasn’t submitted anything.

Keyboard Shortcuts

Story Lists

j
Next story
k
Previous story
Shift+j
Last story
Shift+k
First story
o Enter
Go to story URL
c
Go to comments
u
Go to author

Navigation

Shift+t
Go to top stories
Shift+n
Go to new stories
Shift+b
Go to best stories
Shift+a
Go to Ask HN
Shift+s
Go to Show HN

Miscellaneous

?
Show this modal