WTF Bites



  • @Tsaukpaetra said in WTF Bites:

    @TimeBandit said in WTF Bites:

    @anonymous234
    Tsaukpaetra I would tap that

    Sho' 'nuff.

    maxresdefault.jpg





  • @dkf said in WTF Bites:

    @Carnage said in WTF Bites:

    scary unsafe characters

    You probably don't want to allow non-printable characters in, that's true.

    At one gig where we integrated with a mainframe system via fixed width flat files, I amused myself by sending the bell character in the test env. The system actually beeped. Eventually they fixed it.


  • 🚽 Regular

    What a fascinating bug!! My wife has complained that open office will never print on Tuesdays!?! Then she demonstrated it. Sure enough, won't print on Tuesday. Other applications print. I think this is the same bug. Here is my guess:

    Print to a postscript file. Observe the line:
    %%CreationDate: (Tue Mar 3 19:47:42 2009)

    Change "Tue" to anything else:
    %%CreationDate: (XTue Mar 3 19:47:42 2009)

    Save the file and it prints. Tools like evince work because they simply omit the "CreationDate" tag to begin with.

    Now something odd happens when my cups script (I am using the Brother MFC420CN) copies the file to a temp file. Some of the code is rearranged, not sure how or why, but it uses a command called "file" to identify the file as "PostScript". This check would work on the original file you printed, but by the time it runs the check on the temp file, it misidentifies. Normally it would return:

    PostScript document text conforming at level 3.0

    But there is another check that happens before the PostScript check. If it finds "Tue" at the fourth byte of the file, it identifies it as:

    Jan 22 14:32:44 MET 1991\011Erlang JAM file - version 4.2

    So it's not a problem w/ openoffice.org, cups, or the brother printer drivers. It is a bug in the file utility, and documented at https://bugs.launchpad.net/ubuntu/+source/file/+bug/248619.

    Now, I cannot recommend a fix, but here is my workaround hack:
    make a change in file /usr/local/Brother/lpd/filterMFC420CN

    change:
    cat > $INPUT_TEMP

    to:
    cat | sed -e 's/^%%CreationDate: (Tue/%%CreationDate: (tue/' > $INPUT_TEMP

    This will identify a pattern that matches "%%CreationDate: (Tue" at the start of a line, and change "Tue" to "tue".


  • BINNED

    @Zecc I've run into an issue with similar cause but different result:
    I've got some plain text data files in my project which start with the string FORMAT. When I try to open them in the Qt Creator IDE, it opens the hex editor view instead of the normal text editor view, which is quite certainly not what I want.
    The issue also seems to be file, as can be seen with

    topspin$ echo "FORMAT" > test.txt
    topspin$ file test.txt 
    test.txt: IFF data
    

    I'm not sure that counts as a bug in file, though. At least in my case I'd say it's arguably a bug in using file to begin with.



  • @topspin The downside of using magic bytes to identify things where you don't have full control of where the content comes from.



  • @Benjamin-Hall said in WTF Bites:

    @topspin The downside of using magic bytes to identify things where you don't have full control of where the content comes from.

    On the flip side: If you get to pick magic bytes for a binary file format, include something that doesn't normally occur in UTF-8 text. Like, put in a 0-byte, since it's unlikely to occur in normal text. Two if you're worried about people who store stuff in UTF-16 (but, frankly, they get what they deserve).

    TIL: firefox refuses to paste text with NUL characters. :-(


  • Considered Harmful

    File extensions to the rescue 🧘 :half-trolling:



  • @Benjamin-Hall said in WTF Bites:

    The downside of using magic bytes to identify things

    Particularly when you have several thousand combinations of magic bytes to identify.

    Collisions are... possible.



  • @anonymous234 said in WTF Bites:

    @Benjamin-Hall said in WTF Bites:

    The downside of using magic bytes to identify things

    Particularly when you have several thousand combinations of magic bytes to identify.

    Collisions are... possible.

    Probable, even.


  • Java Dev

    @Benjamin-Hall said in WTF Bites:

    @anonymous234 said in WTF Bites:

    @Benjamin-Hall said in WTF Bites:

    The downside of using magic bytes to identify things

    Particularly when you have several thousand combinations of magic bytes to identify.

    Collisions are... possible.

    Probable, even.

    There are even file types (like zip) which were designed to allow a file to have a second type at the same time.


  • BINNED

    @PleegWat said in WTF Bites:

    @Benjamin-Hall said in WTF Bites:

    @anonymous234 said in WTF Bites:

    @Benjamin-Hall said in WTF Bites:

    The downside of using magic bytes to identify things

    Particularly when you have several thousand combinations of magic bytes to identify.

    Collisions are... possible.

    Probable, even.

    There are even file types (like zip) which were designed to allow a file to have a second type at the same time.

    A Windows PE .exe starts with a DOS .exe stub, so it's arguably always two formats at the same time.

    Or one is a subset of the other, depends on your perspective.



  • @Applied-Mediocrity said in WTF Bites:

    File extensions to the rescue

    You just have to deal with the clowns that "convert" a bmp into a png by changing the file extension.



  • @levicki said in WTF Bites:

    Pseudo-code which would detect "FORMAT" correctly:

    PRs (maybe) accepted.



  • @anonymous234 said in WTF Bites:

    @Benjamin-Hall said in WTF Bites:

    The downside of using magic bytes to identify things

    Particularly when you have several thousand combinations of magic bytes to identify.

    Collisions are... possible.

    You still have waaaaay more than file extensions. With extensions, collisions are rather common fact.

    Note that the parser in libmagic/file reads the first 8 kilobytes and can look at arbitrary features therein. It does not really have to be first four or eight or something bytes.




  • Notification Spam Recipient



  • @Tsaukpaetra But that was in another thread. That's cheating.


  • 🚽 Regular

    Welcome to the Microsoft Developer Blogs, Radhika.

    569b5daf-d853-4c33-924c-4cee10b44d3d-image.png


  • Notification Spam Recipient

    @Zecc said in WTF Bites:

    Welcome to the Microsoft Developer Blogs

    Apparently I need to log in to see comments, but...

    b20bba9c-6adc-49e2-a9c1-54b8e6e2f34b-image.png


  • Notification Spam Recipient

    Status: I was instructed that I needed to gain access to the company GitHub repo. So, I created and associated a GitHub account and sent the username over to be added to the company.

    Response was "Wait, so you just created a second FREE Github account???"

    Um... yeah? We're not all going to be using a single account and sharing the goddamn password $boss !!!


  • Banned

    @levicki said in WTF Bites:

    EDIT: It turns out that whatever is in slot M2_2 has priority over the slot M2_1, very logical from the slot numbering perspective -- thanks ASUS!

    It's one of those things that has literally zero consequences for anything ever. Electronics designers do what makes most sense from their perspective and label accordingly. Firmware writers do what makes most sense from their perspective, and without looking into code nobody knows what makes sense more in the particular case. And if the two labeling systems don't match, most often it doesn't matter because the choice is completely arbitrary and matters fuck all. As long as they're enumerated the same way for the same hardware config.

    As for why it gets renumbered when you insert two drives - maybe it's due to PCIe lanes reallocation. Edit: and while this MIGHT indeed screw things up, there MIGHT be a perfectly valid reason to do so. Without looking into code, we have no way to know.



  • @anonymous234 said in WTF Bites:

    Collisions are... possible.

    While with file extensions, they are a fact of life. Point in case... in our project we have some files with extension .cma.

    It has three meanings already. Guess what, this is neither of them, but some in-house abomination (specifically some kind of IDL, because https://xkcd.com/927/).

    … the fact they are text sources without anything usable as a magic number notwithstanding.


  • Banned

    @levicki said in WTF Bites:

    @Gąska said in WTF Bites:

    It's one of those things that has literally zero consequences for anything ever.

    And here we go again, ladies and gentlemen -- it's @Gąska's signature disagreeing with me without merit.

    The merit was included in the rest of the post. Single-pass parsers are a rather bad choice for forum posts.

    If physical M.2 slots are labeled M2_1 and M2_2, and if PCI function ID of the slot M2_1 is 12 and PCI function ID of slot M2_2 is 24, one would hope that the devices on a PCI bus are enumerated in ascending order (from PCI function 0 upwards) by the firmware.

    But for what? What difference does it make except aesthetics?

    As for whether it can have any effect apart from triggering my OCD? Of course it can!

    If you use WinPE and have a diskpart script to re-image your PC which references drive 0 as a system drive, and then nukes and paves over with your install image, then if your system drive is not drive 0 like you expected you are going to wipe the wrong drive and end up in a world of hurt.

    Yes, that's exactly what I said in my post! The renumbering can be an issue. But the circuit design/abstract device numbering mismatch itself isn't.

    TL;DR -- there are valid reasons for device order to be deterministic

    Yes!

    and to match physical labels.

    That, on the other hand...

    That you don't know of any such reasons and yet decide to defend bad firmware code

    You don't know if the code is bad. You don't know why they've done it this way. Maybe they remap PCIe lines in such a way that when only one M2 drive is connected, the other slot is treated as totally non-existent, and later they found out in system testing that missing drive slot #0 causes incompatibility with some popular hardware configuration?

    Remember Chesterton's fence.


  • Banned

    @levicki said in WTF Bites:

    @Gąska said in WTF Bites:

    But for what? What difference does it make except aesthetics?

    It makes the device order presented to the system and to the user non-deterministic.

    No it doesn't. The renumbering does. The mismatch doesn't. Everything would be deterministic if there was mismatch without renumbering.

    @Gąska said in WTF Bites:

    But the circuit design/abstract device numbering mismatch itself isn't.

    But it is!

    If you are using RAID1 in those M.2 slots and drive 0 fails, which physical drive will you remove?

    Consult your motherboard manual. I know real men never read manuals, but many disasters could be avoided if only the slightly tech savvy people didn't pretend they're such strong and independent women.

    If you are wiring a three phase electrical motor and R, S, T phase labels in the wall socket do not match the phase angle what is going to happen with your motor when you turn it on?

    Is there any abstraction layer between the motor input and the electrical current, like there is in case of logical numbering of drives?

    Please don't be an idiot and don't defend bad stuff.

    @Gąska said in WTF Bites:

    You don't know if the code is bad.

    The BIOS code that can't detect changes you make in boot order, making it impossible to save such change? The BIOS code that when you swap first and second boot device doesn't swap them in boot override menu as well? That code?

    No, the one next to it. Yes, Sturgeon's law is strong in software and 90% of all code is crap that does stupid things for no reason, but occasionally even a very bad program gets some unintuitive behavior added that DOES have a good reason to exist. (Usually because some other piece of crap beyond of your control, like a 3rd party device, is broken and does the wrong thing and you have to work around it. See MS-DOS not detecting a sufficiently fast diskette swap.)

    What you're doing is basically guilt by association.

    @Gąska said in WTF Bites:

    You don't know why they've done it this way.

    Because they are lazy, sloppy fucks?

    Maybe. Or maybe it was either this or not passing QA because of compatibility issues with common hardware vendors. You don't know and have no way to know which one it is.

    @Gąska said in WTF Bites:

    and later they found out in system testing that missing drive slot #0

    Drive 0 is not missing -- it is shifted from slot 1 to slot 2 when you insert something into slot 2, and that's a big problem.

    No, you didn't understand. I'm talking about a hypothetical scenario where you were personally responsible for writing that firmware and it behaves exactly like you want it to behave, and a configuration where only one disk is inserted and it's in slot 2 (so your preferred Disk 1). So you either report to the OS an unavailable Disk 0 and an available Disk 1, or only the available Disk 1 and no Disk 0 at all, available or otherwise. Because all other firmware is just as crap as this BIOS that doesn't remember boot order,

    It's counter-intuitive

    Subjective, but yes.

    it goes against labeling, physical, and electrical layout

    Only a problem if you try to do the wrong thing and infer information in a way you aren't supposed to because no one promised it that way, but yes.

    it can cause real problems including data loss

    Relabeling - yes. Mismatch alone - no (unless you're retarded and infer information in a way you aren't supposed to instead of RTFM).

    and it doesn't follow the priciple of the least astonishment.

    Subjective, but yes.



  • @levicki said in WTF Bites:

    there are valid reasons for device order to be deterministic and to match physical labels.

    in Linux, certain classes of hardware are explicitly not enumerated deterministically to prevent people from hardcoding device paths that could change boot to boot into scripts and things.

    classic example would be /dev/sd*. Those will be enumerated non deterministically so what what /dev/sda one boot might be /dev/sdb or /dev/sdc next boot (assuming you have three discs, it won't add gaps at boot time). so you're supposed to use /dev/disk/by-label/* or /dev/disk/by-id/* in your scripts and fstab entries. that way if you shuffle the plugs of your discs around, or move motherboard, or anything everything still works because you did things right instead of relying on disc0 being /dev/sda, disc1 being/dev/sdb, etc.

    Windows should do that too.... because screw developers that assume computers never change hardware configurations ever.



  • @Vixen said in WTF Bites:

    classic example would be /dev/sd*. Those will be enumerated non deterministically so what what /dev/sda one boot might be /dev/sdb or /dev/sdc next boot (assuming you have three discs, it won't add gaps at boot time)

    Non-acknowledge. It always worked reliably with device paths and is expected to work reliably with them until the heat death of the universe.

    Yes, you are supposed to use by-label or by-id so it still works if you shuffle the cables or attach another device somewhere it is enumerated before the existing ones, which is quite easy since USB mass storage counts as SCSI disk, but it does work with paths as long as you don't touch anything.



  • @Bulb said in WTF Bites:

    Non-acknowledge.

    confusion. because it works that way for my NAS today. every time i reboot my MDRAID array gets the discs in a different order, and both SSDs (m.2 SATA ones, one for system one for the MDRAID cache) as well.... And to MDRAID's credit it never has an issue that the discs shuffle around between /dev/sda through /dev/sdl

    so it's either the version of Linux I use, or my specific hardware that does it.......

    and since it happens with 100% reliability to me. imma go with..... problems on your end. probably because you don't have 12 discs plugged in at once and because it's Linux you need to reboot so infrequently you've just been lucky so far that it's happened to randomly come out with the same order for you every time.

    my odds of being correct in that buttumption are low, but it matches my world view and the evidence i have observed and fails to match the evidence i have ignored, therefore it is truth and anyone who disagrees with me is the enemy and must be shot with NERF to DEATH! (or annoyance, whichever comes first)



  • @Vixen Back when I used Linux, I'd notice things changing occasionally. I was uninformed back then and wondered why accessing things via /dev/sd* didn't always work reliably. And that was on a laptop with a USB stick plugged in.


  • Considered Harmful

    @PleegWat said in WTF Bites:

    There are even file types (like zip) which were designed to allow a file to have a second type at the same time.

    There are file extensions that do that: instagram_jan_2020_curated_by_levicki.jpg.exe :trollface:


  • Considered Harmful

    @PleegWat said in WTF Bites:

    @Benjamin-Hall said in WTF Bites:

    @anonymous234 said in WTF Bites:

    @Benjamin-Hall said in WTF Bites:

    The downside of using magic bytes to identify things

    Particularly when you have several thousand combinations of magic bytes to identify.

    Collisions are... possible.

    Probable, even.

    There are even file types (like zip) which were designed to allow a file to have a second type at the same time.

    Worth watching:
    https://www.youtube.com/watch?v=hdCs6bPM4is



  • @Vixen said in WTF Bites:

    imma go with..... problems on your end.

    The problem on his end being that his setup works reliably?



  • @hungrier said in WTF Bites:

    @Vixen said in WTF Bites:

    imma go with..... problems on your end.

    The problem on his end being that his setup works reliably?

    my system works perfectly reliably because i don't depend on order of enumeration. :-P



  • @Vixen It's good to have a system that's resilient against devices randomly changing order, but it's also good to have a system that doesn't randomly change the order of devices.



  • @hungrier said in WTF Bites:

    @Vixen It's good to have a system that's resilient against devices randomly changing order, but it's also good to have a system that doesn't randomly change the order of devices.

    if you have the former you don't need the later.



  • @Vixen The same could be said of all religions about not needing the former if you have the latter. Why go out of your way to generate additional potential problems?

    Anyway, as usual, Windows made the right decision all along, to present drive letters that don't change even if the BIOS does something crazy like assign slot 2 to the first one



  • @levicki @Gąska



  • @levicki said in WTF Bites:

    What I don't understand is whether he is trolling, or he is just that stupid?

    Erm. First of all: YMBNH.

    Secondly: We're wondering about that as well. Though the target subject of said wonder is rather wantonly distributed throughout the board (and changes by the nanosecond). And the likelihood for the first part is pretty much approaching one.

    The "understanding" part, that is :trollface:


  • Discourse touched me in a no-no place

    @Bulb said in WTF Bites:

    With extensions, collisions are rather common fact.

    How many different applications think they're the sole owner of .DAT these days?


  • Discourse touched me in a no-no place

    @Gąska said in WTF Bites:

    Firmware writers do what makes most sense from their perspective, and without looking into code nobody knows what makes sense more in the particular case.

    Encountered a case the other day where we had to debug the firmware by going and looking at the archived copy of the Verilog for the hardware. That was “fun”. (It was for a test chip, and no, there wasn't a datasheet. The next rev of the test chip will have one of those, but this particular rev didn't as it was really just a glorified technology platform proof.)



  • @dkf said in WTF Bites:

    looking at the archived copy of the Verilog for the hardware. That was “fun”.

    👋


  • Notification Spam Recipient

    @levicki said in WTF Bites:

    @Gąska said in WTF Bites:

    But for what? What difference does it make except aesthetics?

    It makes the device order presented to the system and to the user non-deterministic.

    @Gąska said in WTF Bites:

    But the circuit design/abstract device numbering mismatch itself isn't.

    But it is!

    If you are using RAID1 in those M.2 slots and drive 0 fails, which physical drive from which M.2 slot will you remove?

    If you have 4 memory slots and engineers say "for optimal performance insert 2 memory modules into slots 2 and 4", and then either board labels or BIOS DRAM initialization code or both do not match, what then?

    If you are wiring a three phase electrical motor and R, S, T phase labels in the wall socket do not match the phase angle what is going to happen with your motor when you turn it on?

    Please don't be an idiot and don't defend broken stuff just to disgree with me.

    @Gąska said in WTF Bites:

    You don't know if the code is bad.

    The BIOS code that can't detect changes you make in boot order, making it impossible to save such change? The BIOS code that when you swap first and second boot device doesn't swap them in boot override menu as well? That code?

    @Gąska said in WTF Bites:

    You don't know why they've done it this way.

    Because they are lazy, sloppy, fucks? Most often the simplest explanation is the most accurate one.

    @Gąska said in WTF Bites:

    Maybe they remap PCIe lines in such a way that when only one M2 drive is connected, the other slot is treated as totally non-existent

    There is no need for any PCIe remapping because this board with this CPU I am using has 44 PCIe lanes available, it is advertised as Dual M.2 slot board, and those M.2 slots have dedicated PCIe lanes (two of its x4 PCIe slots do overlap with last two SATA ports and with USB 3.1 Gen2 ports respectively, but that's about it).

    @Gąska said in WTF Bites:

    and later they found out in system testing that missing drive slot #0

    Drive 0 is not missing -- it is shifted from slot 1 to slot 2 when you insert something into slot 2, and that's a big problem. It's counter-intuitive, it goes against labeling, physical, and electrical layout, it can cause real problems including data loss, and it doesn't follow the priciple of the least astonishment.

    FWIW literally all of this already happens with SATA ports.
    Try plugging in ports 3 and 5. Notice they're numbered zero and one everywhere. Now add one to port 1. What do you think happens?

    You cannot and must not assume enumeration order of devices! This is extremely also applicable to USB, by the way!


  • Notification Spam Recipient

    @Bulb said in WTF Bites:

    since USB mass storage counts as SCSI disk,

    Sure, but if said SCSI disk isn't ready at time of enumeration and comes online later, glhf with your reliability!

    Ask me about the Christmas NAS which uses USB storage for everything...


  • Notification Spam Recipient

    @hungrier said in WTF Bites:

    Anyway, as usual, Windows made the right decision all along, to present drive letters that don't change even if the BIOS does something crazy like assign slot 2 to the first one

    This is only on the user facing side. If you take a look at disk management you might just be astonished.


  • Notification Spam Recipient

    @levicki said in WTF Bites:

    what I am guessing any sane person

    This here. This is what's unreasonable. There exists no such thing, so your argument is invalid.



  • @levicki said in WTF Bites:

    ignoring his stupid provocations from now on.

    9e391f92-3c3a-44ef-b6e2-97fe50e10f34-image.png



  • @levicki said in WTF Bites:

    @Vixen ? Are you saying my posts are intentionally provoking him into responding with retarded bullshit?

    intentionally?

    I cannot answer that one as I cannot read your intentions.

    Are they having the same effect as if they were intended as you say?

    Yep. That's how it looks from here.



  • @levicki said in WTF Bites:

    @Vixen said in WTF Bites:

    Yep. That's how it looks from here.

    Care to elaborate what part of my original WTF post about bad drive order was provoking?

    your original post? nah that's fine. your responses to people taking alternate points of view are what's reading as provoking.

    as soon as someone disagrees with you your tone shifts to dismissive at best and rude at worst, is really off putting, and the more you get called out on it or get further disagreed with the more you veer into reading like "retarded bullshit" territory.

    I'm certain you don't see it that way, but it's how you're coming across and we are reacting to how you present, not how you think you present. (or at least i buttume the others are as well, they might just be assholes piling on because you give good reaction)


  • Notification Spam Recipient

    @levicki said in WTF Bites:

    @Tsaukpaetra said in WTF Bites:

    This here. This is what's unreasonable. There exists no such thing, so your argument is invalid.

    Oh, sod off! Don't you have some other dead horse to get to the bottom of?

    No, I take dead horses places you'd rather not know about, but that's neither here nor there.



  • @levicki said in WTF Bites:

    That's akin to judging a person by what they wear instead of by what they know.

    No. We're judging you by what you say and HOW you say it. just like you judge us, or at least how I hope you judge us.

    @levicki said in WTF Bites:

    No wonder Trump is the president of the USA.

    YOU WASH YOUR MOUTH OUT WITH SOAP YOUNG MAN! We do not stand for such vile language here!

    @levicki said in WTF Bites:

    I'd say that's the most likely explanation.

    In that case I refer you to the image i previously posted above.


Log in to reply