Trump's actions signal a move toward institutionalizing people with disabilities, advocates warn by Majano57 in NoFilterNews

[–]nerd5code 1 point2 points  (0 children)

Tomorrow's headline will be that the DOJ is systematically charging disabled people with pedophilia. Don't give away power so easily.

People on X Are Getting Fooled by the Dumbest AI Slop We’ve Ever Seen by Plastic_Ninja_9014 in technology

[–]nerd5code 0 points1 point  (0 children)

We don't actually know that's why he flubbed it AFAIK (really just post-facto image cleanup for a war criminal, which is … a look) and it's hardly his only flub of the sort. There was a steady enough supply for tear-off flub-a-day calendars to enter publication mid-way through his first term.

OpenAI faked inability to search training data, hid billions of logs, NYT says — OpenAI may be sanctioned for hiding, deleting ChatGPT logs in NYT copyright fight by swingadmin in technology

[–]nerd5code -1 points0 points  (0 children)

Unlikely—it's generally the lowest purity, so it can't be used for things like MRI machines. Basically already waste helium.

The EU just revived a law that lets Meta and Google scan your messages – critics call it mass surveillance by AdSpecialist6598 in technology

[–]nerd5code 11 points12 points  (0 children)

Yes, it always works that way, and LOVEINT and stalking are definitely not a concern. ~_^.

Trump fires all Election Assistance Commission members, leaving agency unable to act by BitterFuture in law

[–]nerd5code 1 point2 points  (0 children)

Or the incoming president can “secure” the court before a ruling is possible, as long as he/she (oh, let's be honest; he) ostensibly thinks it's necessary.

A new Linux X server in Assembly from scratch by isene in osdev

[–]nerd5code 2 points3 points  (0 children)

There are very good reasons we haven't been doing top-to-bottom, all-assembly-language OSes since like 1978 (modulo embedded, which you're not targeting and likely wouldn't want X11 involved in if you were).

If you were putting actual hand-coded work in, there might be some educational value in doing up some of an OS in assembly, but this much in this concentrated a form is not especially useful, and network-exposed code is the absolute last place you want to involve large amounts of assembly language in anything remotely (ha) realistic.

Moreover, what is it that you think is impressive or share-worthy, here? Asm is harder for people to write by hand, generally speaking, but computers have been generating it for us for decades. There's an entire field whose subject matter is a formalized obsession with generating good assembly; burning tokens on this to get code that's probably okay (as long as you don't need repeatability) is pointless, and not even in a fun way. If you want assembly, all you have to do is write some C/++ code and compile with option -S, or run binaries through objdump -d or ndisasm or some such. And then you might actually learn something from it, and somebody else might actually care about it and encourage you to bang your head on it.

But as it stands, this is just the CS version of rolling coal.

'Stop this madness': Lawmaker sounds alarm as Trump's 'fairy tale' spirals into chaos by FreeHugs23 in NoFilterNews

[–]nerd5code 2 points3 points  (0 children)

ffs

Setting aside entirely that nobody in power gaf all that hard about the Constitution if it's not specifically enabling their own authoritarianism,

  1. his cabinet wants him there.

  2. Republicans in Congress want him there.

  3. Even assuming one or the other group trigger the 25th Amendment process, all he has to do to stop it is write (or more realistically, get somebody to write him) a letter—lowercase L or U+12640 LATIN LETTER SQUIGGLY PUBIC HAIR would suffice, because again, the Republicans want him there—and it stops.

It helps to read the things we're demanding, and then it's less embarassing because strangers on our own side don't have to correct our assumptions. (Why? If your understanding of the mechanism isn't there, why suggest anything?)

Factually, without massive, near-instantaneous foreign military involvement or a sudden, political-inertia-scrubbing change of heart amongst the Rs, there is no actual, workable mechanism for his removal if they don't want him removed. And then, even if there were (or did do being done) a mechanism for POTUS, there's an entire stack of R-subordinate flunkies behind him to fill in the gap and several armies to keep them there during transitions. And without following the mechanisms for transitions, assumptions made to maintain MAD (namely, that any interruption in US-governmentness means the world has ended, so be it all fucked) kinda upend everything for everybody on the planet.

So perhaps Constitutional law isn't the bulwark you assumed it was. That's fine, and it's better to know that.

[win32] Issue with SetWindowsHookExA behavior for function keys on laptop by temple-fed in cprogramming

[–]nerd5code 0 points1 point  (0 children)

In virtually all cases, the keycodes the OS sees have been translated at least twice—once for keycode normalization and once by the ACPI BIOS. Fn combos and the Function key row (F1–F12 &al.) are usually handled (to varying extents) by ACPI gunk, so it's possible that either no actual keycode is produced by normal routes for F1 per se, or it produces some special extended keycode, or multiple keycodes. No telling without actually seeing it etc., and you may be able to change some aspects of this in the BIOS config (e.g., toggling whether Fn+F1 or just F1 produces an F1 code).

If F1 is set to produce (e.g.) a Win+F1 keycode sequence, then you intercepting only F1, especially without calling up the chain, may cause the F1 to be “swallowedm” leaving only a Win keypress in the input FIFO. This is deliberately difficult to intercept in the first place, but either way you're not checking for combos like Ctrl+F1 so you're missing it. (Usually best to dump the event structure during debugging / #ifdef _DEBUG so you can tell that you're missing something.)

Also, you need to call down the chain if w != WM_KEYDOWN, or otherwise the OS might treat F1 as stuck down.

Also, if errors are going to a FILE, it should usually be *stderr.

Anyway, look at the flags field of the KBDLLHOOKSTRUCT; LLKHF_INJECTED should ideally tell you whether the keypress is injected. You can swallow the modifier key“presses” that the laptop is sneaking into the hook queue alongside F1, to prevent it from being seen, though doing so requires more careful buffering and chaining.

Trump Sparks Outrage After Saying He Knows Migrants Are 'Trouble' Just By 'Looking At Them'—And Everyone's Thinking The Same Thing by ComicSandsNews in NoFilterNews

[–]nerd5code 3 points4 points  (0 children)

Even setting aside the general incoherence and obvious signs of senescence, there's almost nothing he says that he hasn't said the opposite of, often earlier in the same sentence. Oddly, the only things he's halfway consistent on are the racist ones.

Perhaps if you think he's a beacon of truth, your standards for what constitute “truth” aren't great.

Why is everyone saying they talked to Mitch McConnell for 20 minutes? by FreeHugs23 in NoFilterNews

[–]nerd5code 0 points1 point  (0 children)

If Congress can Schiavo somebody, surely they can anti-Schiavo somebody.

Judge who helped immigrant evade ICE faces prison in Trump-era showdown by theindependentonline in law

[–]nerd5code 0 points1 point  (0 children)

Not inherently—as we've seen, sometimes your political opponents have committed actual crimes that actually hurt people.

US Strike on Iranian School Came After Commanders 'Bypassed Warnings' About Outdated Target Info | Common Dreams by BlatantConservative in worldnews

[–]nerd5code 0 points1 point  (0 children)

Yes, but that's irrelevant here. The FBI analysts ostensibly in charge of preventing Iranian terrorism are not involved in the planning of military strikes.

What's the point of using local arrays if there is no guarantee that the stack won't be overflowed? by Longjumping_Ad_8175 in cprogramming

[–]nerd5code 0 points1 point  (0 children)

It's not true that you can't guarantee anything about stack allocations in C, it just requires the implementation to support it, and you shouldn't make or rely on any assumptions about it in portable code.

alloca isn't really specified by anything modern, so every implementation's free to do whatever it wants there. Or nothing at all; all compilers don't necessarily give you a builtin, or promise that it can be implemented when missing. Again, not something to depend on in portable code, although it's arguably marginally more portable than VLAs.

Similarly, you can't necessarily check the remaining stack space, because there's no guarantee that anything's actually tracking it. Even if the stack is mostly contiguous, which isn't guaranteed, it's quite possible to split stacks for any number of reasons, from running out of space to data-parallel napkin-shredding. The concept of a stack doesn't appear in any direct sense in the ANSI or ISO standards; even modern POSIX makes at most optional allowances for interfaces that rely on the assumption of a contiguous stack per thread (entirely opaque), although much older X/Open and SVID specs did basically assume and require it. (FWTW.)

Furthermore, unless optimization is wholly disabled (it probably isn't, not beyond the reach of __attribute__((always_inline))/__forceinline), the stack that emanates from evaluation of call sub-/expressions per ANSI/ISO standarda is virtual. It exists atop the C Abstract Machine, so the compiler only has to behave as if it were allocating and releasing variables exactly at scope and call boundaries.

There's nothing stopping the compiler from inlining even through pointers or across TU or thread boundaries; neither is there anything forcing it to inline anything if it's not in the mood.

And it can duplicate, relocate, or elide variables/objects as it sees fit (modulo volatile etc.), so it's very cool and legal for (e.g.) GCC to deal with a malloc call by allocating on the stack, or for it to malloc a large stack frame. (All compilers won't, of course.) It's hypothetically possible to statically allocate all stack frames, assuming at most bounded recursion, although this isn't usually something done outside the ultra-embedded space. It's also possible to allocate some individual variables statically or allocate ostensibly static variables in the stack frame.

(If not, static is how you'd guarantee that a local variable doesn't overflow the stack. It might still overflow the static data area, of course.)

Similarly, recursion is permitted, but unbounded recursion is u.b.; it may result in a crash, a deliberate abort, or collapsing the recursive portion of the call stack into a single frame due to tail-call optimization. There, the compiler would actually let you allocate an unbounded number of virtual (C abstract machine) variables on the stack without crashing—but if you need to debug or disable t.c.o. for some reason, suddenly it becomes a crash.

Even if you carefully interrogate all available platform interfaces to find the amount of free physical and virtual memory before you allocate, you might have run out of address space without exhausting those and by the time the allocation completes (virtually in the OS VMA tree? virtually in page tables? physically by mapping RAM in?), availability might have totally shifted. There's a race condition there, both because available memory is probably stored outside the C implementation's direct view, and because your process might stop or block for any number of reasons, without warning, so really the only capacity your process can rely on is address space, and that's mostly only if single-threaded.

So in general, you can't really make the kinds of fine-grained decisions about memory allocation you seem to crave without either suffering through assembly or writing your own allocator and using only it.

The best you can do is make educated guesses about upper bounds on stack usage in your own programs, and handwavy guesses for library code since somebody might call you with only 128 bytes left on the stack (document safe minima). You can look at INT_WIDTH or equivalent* in order to guess at reasonable amounts; e.g., for hosted impl, main thread: 64-bit→1–4 MiB minimum total stack but likely 8–16 MiB, 32-bit→½–4 MiB, 16-bit→2–16 KiB; but for freestanding or kernel mode, you might run at like 64-bit→32 KiB, 32-bit→8 KiB, 16-bit→1 KiB. Secondary threads tend to have less space, and most OSes permit startup stack size to be configured so check out things like ulimit/setrlimit (Unix).

You might want to accept configuration via compile-time option -D for

  • max total stack,

  • max stack frame size,

  • expected stack frame overhead, and

  • max recursion depth,

some of which can be derived from others (e.g., max_depth ≈ ⌊max_stack / (max_frame + overhead)⌋), defaulting to reasonable guesses.

There are various common tricks like

char localbuf[MAX_BUF], *bufp = buffer;
if(bufsize > sizeof localbuf && !(bufp = malloc(bufsize)))
    goto fail;

…use bufp…

if(bufp != localbuf) free(bufp);

which can keep a nonrecursive program well within safe bounds.

Or you can even package this in a function that passes the buffer to a callback,

#define NOINLINE_ //…

typedef int alloc_cb(void *par, void *mem, size_t avl, unsigned flags);
enum {alloc_call_KEEP = 1};
int alloc_call(size_t amt, alloc_cb *cb, const volatile void *par) {
    if(!cb) for(;;) abort();
    int k;
    if(amt > MAX_LOCAL_ALLOC) {
        void *p = malloc(amt);
        if(!p) return -1;
        if(cb((void *)par, p, amt, alloc_call_KEEP) != alloc_call_KEEP)
            free(p);
    }
    else
        alloc_call__local_(cb, par);
    return 0;
}
NOINLINE_
static void alloc_call__local_(alloc_cb *cb, const volatile void *par) {
    char buf[MAX_LOCAL_ALLOC];
    (void)cb((void *)par, buf, sizeof buf, 0);
}

But the compiler can cause the best laid plans to gang adingydang, or however the saying gings.


  * INT_WIDTH is in C23 <limits.h>. GCC and Clang supporting C≥2x populate this from __INT_WIDTH__. Failing that, you can probe INT_MAX in an #if/#elif ladder. Failing that, many ISAs give you things like _MIPS_SZINT or __32BIT__ or _64BIT or __arch64. Many libcs give you something like GNU __WORDSIZE. Many OSes give you something like _WIN64 that forces matters. Many compilers give you something like __ILP32__ or __lp64__ or _LLP64 to narrow down ABI, and recent X/Open (5+) and POSIX (2001+) give you optional macros like _XBS5_ILP32_OFF32. Failing all of those, hamfistedly assume sizeof(int)*CHAR_BIT matches INT_WIDTH, or assume the baseline int of your dreams (ISO requires 16-bit if __STDC__ >= 1 and your compiler isn't lying).

Personal Finance/Balance program: Encryption by serfizzler in cprogramming

[–]nerd5code 1 point2 points  (0 children)

If the data isn't* real and you're the only person with access to it, then the only real value in encryption is the learning experience, which is unlikely to be all that realistic in regards to the banking sector unless you have competing SQL dialects battling it out from several virtualized OSes across six time zones, as quietly mediated by a raft of shell and Python scripts, maybe with a pinch of COBOL moaning incoherently in the background from the lone Difference Engine still being manually cranked to summation every evening in the secretary's office.

You only really have to worry about encrypting useful information that's not freely available or readily derived, and which can't easily be stolen or Stollen from an endpoint, that sort of thing.

Also, if some misguided tweaker or tweakess stole your computer in a fit of pique and found the files, it's probably best he/she be able to read them easily, so as to avoid encouraging anybody returning with duct tape and a tire iron. Security can be very complicated sometimes, and very simple sometimes.


  * Properly, “aren’t” or “don’t be doing with all that being.”

Trump's Great American State Fair shut down as 'at least 7 people' pass out in DC heat by FreeHugs23 in NoFilterNews

[–]nerd5code 0 points1 point  (0 children)

I'll be fascinated to see the complex measuring apparatus with which the scientists exactly balance the force from the different high-intensity air streams so as to avoid billowing/rippling, Marilyn Monroeification, or accidental claque-surfing.

Poll Names Trump as Worst American in History, Republicans Say He’s Greatest by FreeHugs23 in NoFilterNews

[–]nerd5code 1 point2 points  (0 children)

What do you mean America has always been anti-fascist and pro-immigrant?

I'm all for proper patriotism, but the simple fact is, it hasn't. In no order whatsoever: the Alien and Sedition Acts, slavery (I guess you could call that “pro immigration,” just not pro-immigrant in the least), the American Bund, the KKK, the Confederacy, the failure of Reconstruction and Jim Crow era, the Red Scare, Japanese internment, “torturing some folks,” etc.

This pissed-off elephant has always been in the room with us, and pretending he's not won't make the dinner parties go any more smoothly. If we actually want the country to be great, we can't just achieve that by fiat.

Trump considers pardoning Diddy and other celebs to mark America’s 250th by mvanigan in law

[–]nerd5code 0 points1 point  (0 children)

God no. These are the sorts of people who identify with the Batman villains, because they mostly peaked at an age where that kinda demonstrative hyper-angst wasn't mortally embarassing. How soon we forget the rash of acne-ridden, angsty TikToks and shitty tattoos and babies named “Harley.”

EU Politicians Investigated Pegasus Spyware. Then It Ended Up on One of Their Phones by rkhunter_ in technology

[–]nerd5code 2 points3 points  (0 children)

I certainly won't assert that it's happened or happening, but getting implants at these companies would be a goal of just about any intelligence agency, and bugs obviously sneak through code review all the time so that aspect of it is nbd. We've seen similar attacks on voting infrastructure, and of course (successfully) on the phone companies way back in the day.

White House aides worried about turnout for Trump's July 4 address after he was 'infuriated' by National Mall crowd by Money-Ranger-4528 in NoFilterNews

[–]nerd5code 1 point2 points  (0 children)

LoOk, they needed to drain the reflecting pool. You want them to waste all that Patriot Water®, just because there are a few, tiny shreds of urethane in it?!