Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Dylan16807
May 12, 2010

hackbunny posted:

I'm not sure I get it. Is it the shader compiler doing an unsafe transformation of floating point code? Using one kind of operation in one place and a slightly different kind in another, and erroneously considering them equivalent?

And in doing so, it's creating a situation where if (a<b) can execute neither branch when a and b are too close together.

Adbot
ADBOT LOVES YOU

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!

The Fool posted:

All of humanity's problems can be traced back to the invention of numbers.
Pure mathematics is symbolic salvation.

Oh wait numbers are symbols. Transitively, all of humanity's problems can be traced to sexual reproduction.


In other news, I'm not quite sure how many code reviews it's going to take before this engineer understands the difference between configuration validation, operational preparation, and execution. Stop preparing case-specific settings in the execution code. For fucks sake, go read an intro OO/SOLID principles book "senior" software developer.

Colonel Taint
Mar 14, 2004


I just spent the past week looking into possible reasons left/right channels are swapped on a device's input roughly 4% of the time. The device in question runs on linux 2.6.36 or so.

There are a few key places throughout the kernel's sound framework code where spin locks are employed, including in some threaded IRQ handlers

Today I found out that when the kernel is not configured with preemption or smp support (which is the case with the device in question), there are still kthreads but most in-kernel locking is basically optimized to no-op functions.

I still don't have any idea where the channel swap is coming from, but basically enabling kernel preemption is it's own pandora's box on this fairly mature system, and I'm left with no real good way to have any sort of synchronization throughout the audio driver so I guess I basically have to say 'gently caress it' now.

FlapYoJacks
Feb 12, 2009

Colonel Taint posted:

I just spent the past week looking into possible reasons left/right channels are swapped on a device's input roughly 4% of the time. The device in question runs on linux 2.6.36 or so.

There are a few key places throughout the kernel's sound framework code where spin locks are employed, including in some threaded IRQ handlers

Today I found out that when the kernel is not configured with preemption or smp support (which is the case with the device in question), there are still kthreads but most in-kernel locking is basically optimized to no-op functions.

I still don't have any idea where the channel swap is coming from, but basically enabling kernel preemption is it's own pandora's box on this fairly mature system, and I'm left with no real good way to have any sort of synchronization throughout the audio driver so I guess I basically have to say 'gently caress it' now.

Is it a TI DSP?

Colonel Taint
Mar 14, 2004


Yes it is. I was able to mostly deal with the interleaving alsa/irq threads, and cut down the error rate in a test program from ~1 error in 100 test cases to ~1 in 10000 test cases. When it does reach an error case now, there's seemingly no indication at all from the hardware - no IRQs or anything. On top of that, when I run real-world tests with the thread interleaving fixed, it doesn't seem to make a difference compared to without the fix.

Colonel Taint fucked around with this message at 03:15 on Dec 23, 2017

FlapYoJacks
Feb 12, 2009
Code that was giving me a headache today from systemd:

C++ code:
case SD_BUS_TYPE_BYTE:
        if (p)
                *(uint8_t*) p = *(uint8_t*) q;
        break;

case SD_BUS_TYPE_BOOLEAN:
        if (p)
                *(int*) p = !!*(uint8_t*) q;
        break;

case SD_BUS_TYPE_INT16:
case SD_BUS_TYPE_UINT16:
        if (p)
                *(uint16_t*) p = BUS_MESSAGE_BSWAP16(m, *(uint16_t*) q);
        break;

case SD_BUS_TYPE_INT32:
case SD_BUS_TYPE_UINT32:
        if (p)
                *(uint32_t*) p = BUS_MESSAGE_BSWAP32(m, *(uint32_t*) q);
        break;

case SD_BUS_TYPE_INT64:
case SD_BUS_TYPE_UINT64:
case SD_BUS_TYPE_DOUBLE:
        if (p)
                *(uint64_t*) p = BUS_MESSAGE_BSWAP64(m, *(uint64_t*) q);
        break;
Bools are bytes. WHY IS IT A INT IN SYSTEMD?

FrantzX
Jan 28, 2007
Considering that all the other casts are using types with explicit sizes, my first question would be, what is result of sizeof(int)?

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
I have to admit the first thing I was wondering is why the "if (p)" wasn't put outside the switch statement.

ToxicFrog
Apr 26, 2008


ratbert90 posted:

Code that was giving me a headache today from systemd:

Bools are bytes. WHY IS IT A INT IN SYSTEMD?

C doesn't have a boolean type (C++ does, but AFAIK systemd is written in plain C). Functions in C that take or return "booleans" conventionally use int, not uint8_t or similar -- see, for example, feof(3). So this looks entirely reasonable -- it's 1 byte on the wire, but an int in memory.

The real horror is over in bus-type.c:

code:
int bus_type_get_size(char c) {
    switch (c) {
        // ...
        case SD_BUS_TYPE_BOOLEAN:
        case SD_BUS_TYPE_INT32:
        case SD_BUS_TYPE_UINT32:
        case SD_BUS_TYPE_UNIX_FD:
                return 4;
        // ...
    }

        return -EINVAL;
}
Where it cheerfully assumes that sizeof(int) == sizeof(int32) == 4. (All the standard guarantees is that plain int is "at least 16 bits", IIRC.)

Soricidus
Oct 21, 2010
freedom-hating statist shill

ToxicFrog posted:

C doesn't have a boolean type (C++ does, but AFAIK systemd is written in plain C).

this fact brought to you by the year 1998

ToxicFrog
Apr 26, 2008


Soricidus posted:

this fact brought to you by the year 1998

:doh: I keep forgetting <stdbool.h> exists.

feedmegin
Jul 30, 2008

ToxicFrog posted:

C doesn't have a boolean type (C++ does, but AFAIK systemd is written in plain C). Functions in C that take or return "booleans" conventionally use int, not uint8_t or similar -- see, for example, feof(3). So this looks entirely reasonable -- it's 1 byte on the wire, but an int in memory.

The real horror is over in bus-type.c:

code:
int bus_type_get_size(char c) {
    switch (c) {
        // ...
        case SD_BUS_TYPE_BOOLEAN:
        case SD_BUS_TYPE_INT32:
        case SD_BUS_TYPE_UINT32:
        case SD_BUS_TYPE_UNIX_FD:
                return 4;
        // ...
    }

        return -EINVAL;
}
Where it cheerfully assumes that sizeof(int) == sizeof(int32) == 4. (All the standard guarantees is that plain int is "at least 16 bits", IIRC.)

While this is true, to be fair, systemd isn't trying to run on an Atari ST or MSDOS or something. Are there any Linux platforms where gcc has a 16 bit int?

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


I remember that at last year's systemd.conf there was a contingent of folks from some automotive manufacturer.

Soricidus
Oct 21, 2010
freedom-hating statist shill

feedmegin posted:

While this is true, to be fair, systemd isn't trying to run on an Atari ST or MSDOS or something. Are there any Linux platforms where gcc has a 16 bit int?

iirc one of the unix standards linux follows does guarantee that int is at least 32 bits

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
does C99 bool have any size constraints either? i thought it was just "at least large enough to hold 0 or 1"

iospace
Jan 19, 2038


In C, a byte is 8 bools, if you want.

iospace fucked around with this message at 20:48 on Dec 23, 2017

Dylan16807
May 12, 2010
There's language about things needing to be made of entire bytes, and you'd likely be violating some rules with pointers.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
_Bool is guaranteed to only hold 0 or 1. Converting a value to _Bool does a nonzero test exactly equivalent to what happens with && and if-conditions. That is the whole point of having a special _Bool type.

sizeof(_Bool) is not guaranteed to be 1, and in fact it’s 4 on old PPC ABIs (including macOS), presumably out of some dumb attempt to preserve ABI compatibility with int.

Nude
Nov 16, 2014

I have no idea what I'm doing.
Not sure this is a coding horror, cause I guess I should of known better. In csharp, you can do class Foo : object or class Foo (they mean the same thing). I do the first one, I suppose for just being explicit I guess. Anyway, in Unity I had some objects on a list and when accessing I kept getting object is null. So I thought oh I must of messed up adding objects to a list. So I made a quick test file, and I was still getting objects are null. Finally I tested the objects themselves, and low and behold they were null even though I very clearly declared them on the line above. In desperation and about to rip my own hair out, I decided to look through Unity docs to see if they do anything weird with the Object class.

They do. And what's worse is the object behaves like a regular old object with one tiny exception. When you do Foo foo = new Foo(); using Unity's object, it will of course always return null. So I guess that's one reason I should change my habit to just class Foo...

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Interesting. At a quick Googling it seems like their special object with custom behaviour is actually named UnityEngine.Object. Was it a namespace import that caused you to inherit from the wrong Object, or were you actually inheriting System.Object?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Nude posted:

So I guess that's one reason I should change my habit to just class Foo...

Here's another reason: Redundant code is bad. It's the same reason that writing var foo = new List<Bar>() is better than writing List<Bar> foo = new List<Bar>() or writing if (booleanExpression) {} is better than writing if (booleanExpression == true){}.

EssOEss
Oct 23, 2006
128-bit approved
I hear a lot about how Unity's .NET/C# functionality is very limited compared to the real thing but I never saw an article covering it in depth with any juicy details. Is there some good reading material to understand it in depth? I want more than horrorsnippets!

Nude
Nov 16, 2014

I have no idea what I'm doing.

NihilCredo posted:

Interesting. At a quick Googling it seems like their special object with custom behaviour is actually named UnityEngine.Object. Was it a namespace import that caused you to inherit from the wrong Object, or were you actually inheriting System.Object?

Guilty as charge, I did have using UnityEngine, as I was using Unity's math library because they use float over double for everything. It's why I don't consider this to be a "true horror" cause I should of considered Unity could be overwriting the object class. But the reason I posted it cause I thought it was pretty :psyduck: that Unity purposely made the object return null no matter what.

New Yorp New Yorp posted:

Here's another reason: Redundant code is bad. It's the same reason that writing var foo = new List<Bar>() is better than writing List<Bar> foo = new List<Bar>() or writing if (booleanExpression) {} is better than writing if (booleanExpression == true){}.

Good point, didn't think of it as redundant, but it is.

EssOEss posted:

I hear a lot about how Unity's .NET/C# functionality is very limited compared to the real thing but I never saw an article covering it in depth with any juicy details. Is there some good reading material to understand it in depth? I want more than horrorsnippets!

I would love to read that as well if anyone has it.

One thing I know is serialization. Unity's engine only supports serialization for one collection which is lists. And the list serialization doesn't support polymorphed objects. It also doesn't support serialization of properties. Not trying to put down Unity too much tho as I still enjoy using it. You do have access to .net's serialization libraries, so if it's a .net object you have way more serialization options. Which is why I personally switched, but then stumbled upon what I just posted above :v:.

Nude fucked around with this message at 22:36 on Dec 24, 2017

canis minor
May 4, 2011

https://twitter.com/slatestarcodex/status/944739157988974592

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Nude posted:

low and behold

You meant "lo and behold" btw

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Thank god for the computer wizards making all our lives so easy and trouble-free

Eleeleth
Jun 21, 2009

Damn, that is one suave eel.
The real horror is the dude in the replies to that tweet yelling about how easy it is to just turn off autocorrect as though that's the real issue.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Autocorrect replacing correct words with other words is a pretty common thing, so it's not exactly surprising that it does so in cases where it's dangerous rather than merely confusing or funny. I'm not sure that a solution to that problem exists.

Volguus
Mar 3, 2009

Plorkyeran posted:

Autocorrect replacing correct words with other words is a pretty common thing, so it's not exactly surprising that it does so in cases where it's dangerous rather than merely confusing or funny. I'm not sure that a solution to that problem exists.

Hmm, I don't know, maybe it can actually update its dictionary? So that it can learn new words? Auto-suggestions I understand suggesting the wrong thing, after all is just a guess. Autocorrect is supposed to correct a misspelling, a something that doesn't exist in the language's dictionary with something that does. Therefore which and witch would be both perfectly valid words, though only one of them appropriate in a resume.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Plorkyeran posted:

Autocorrect replacing correct words with other words is a pretty common thing, so it's not exactly surprising that it does so in cases where it's dangerous rather than merely confusing or funny. I'm not sure that a solution to that problem exists.

iOS autocorrect has being doing some strange poo poo recently, I wouldn’t be surprised if that medication thing is some machine learning gone awry and is genuinely a new issue. You’re right in the abstract of course but there’s a new autocorrect implementation or someone flipped a switch or something because it used to be completely different. May be new to iOS 11.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Volguus posted:

Hmm, I don't know, maybe it can actually update its dictionary? So that it can learn new words? Auto-suggestions I understand suggesting the wrong thing, after all is just a guess. Autocorrect is supposed to correct a misspelling, a something that doesn't exist in the language's dictionary with something that does. Therefore which and witch would be both perfectly valid words, though only one of them appropriate in a resume.

This wouldn't help with the issue described in the tweet since it's pretty clear that "duloxetine" wasn't in iOS's dictionary at all, while "fluoxetine" was.

The only solutions are either have a dictionary that's constantly up to date with every single technical term and compound word for every discipline (not practical), or turn off the automatic correction and stick to suggestions, alerts, highlighting, anything that involves user confirmation basically.

QuarkJets
Sep 8, 2008

Hammerite posted:

You meant "lo and behold" btw

actually it's "low and beehold"

Soricidus
Oct 21, 2010
freedom-hating statist shill

NihilCredo posted:

This wouldn't help with the issue described in the tweet since it's pretty clear that "duloxetine" wasn't in iOS's dictionary at all, while "fluoxetine" was.

The tweet talks about MacBooks not iPhones. Does macOS proper do autocorrect now? Because that would be pretty stupid, as the only reason autocorrect is necessary in the first place is that touchscreen keyboards are so ridiculously inaccurate. Text entered with an actual physical keyboard should not be altered without user intervention.

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


E: thoroughly beaten, what soricidus said

QuarkJets
Sep 8, 2008

Plorkyeran posted:

Autocorrect replacing correct words with other words is a pretty common thing, so it's not exactly surprising that it does so in cases where it's dangerous rather than merely confusing or funny. I'm not sure that a solution to that problem exists.

The solution is to not autocorrect words in your OS by default. We're talking about a MacBook, not a phone

e: gently caress

Absurd Alhazred
Mar 27, 2010

by Athanatos

Hammerite posted:

Thank god for the computer wizards making all our lives so easy and trouble-free

DERP LEARNING, BRO!

boo_radley
Dec 30, 2005

Politeness costs nothing

QuarkJets posted:

actually it's "low and beehold"

low Dan beehive!

Volguus
Mar 3, 2009

NihilCredo posted:

This wouldn't help with the issue described in the tweet since it's pretty clear that "duloxetine" wasn't in iOS's dictionary at all, while "fluoxetine" was.

The only solutions are either have a dictionary that's constantly up to date with every single technical term and compound word for every discipline (not practical), or turn off the automatic correction and stick to suggestions, alerts, highlighting, anything that involves user confirmation basically.

The actual coding horror here is that autocorrect changes words when it knows for a fact that it does not have an up to date dictionary (you said it is not practical). When your name is Apple and the company is worth $700B you either make that update practical or you simply do not automatically correct, but instead suggest spelling mistakes and let the user decide. Can't have it both ways: I know I'm right and you're wrong, but I do not make sure that I'm right.

redleader
Aug 18, 2005

Engage according to operational parameters

Nude posted:

When you do Foo foo = new Foo(); using Unity's object, it will of course always return null.

What the gently caress? How? Why? How? Why?

I'm actually in awe - this is quite possibly the most perfect coding horror. I don't think this is even possible without loving up the runtime itself.

I guess Unity is just going to have to totally give up on the nullable reference type thing coming in C#8?

Nude posted:

It's why I don't consider this to be a "true horror" cause I should of considered Unity could be overwriting the object class

This is absolutely a true horror. Silently stealing the name of .NET's most fundamental type and then tacking on some loving absurd behavior is entirely Unity's fault. I'm surprised the compiler didn't complain about ambiguous class names. What happens if you do new object() vs new Object()?

Adbot
ADBOT LOVES YOU

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Volguus posted:

The actual coding horror here is that autocorrect changes words when it knows for a fact that it does not have an up to date dictionary (you said it is not practical). When your name is Apple and the company is worth $700B you either make that update practical or you simply do not automatically correct, but instead suggest spelling mistakes and let the user decide. Can't have it both ways: I know I'm right and you're wrong, but I do not make sure that I'm right.

It's not impractical in the sense that it costs too much. It's impractical in that having every sequence of characters that someone might want to type in your dictionary simply isn't possible, and would actually be less useful in many cases than a less inclusive dictionary (because many typos are technically words that someone might want to type).

Autocorrect on by default is dumb, but not because of this issue in particular.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply