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
Athas
Aug 6, 2007

fuck that joker

Not saying this.

Adbot
ADBOT LOVES YOU

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Athas posted:

Not saying this.

i get that you arent, but i am

Kazinsal
Dec 13, 2011

Xarn
Jun 26, 2015
Maybe in the 70s

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Athas
Aug 6, 2007

fuck that joker
Lots of people saying things I wouldn't say.

Cybernetic Vermin
Apr 18, 2005

what is kind of weird is that pascal looked to be winning out for quite some time, but c then returned to relevance.

at any rate and all history aside c should go away on security grounds ityool 2024.

Ocean of Milk
Jun 25, 2018

oh yeah
C is a p-lang

tinaun
Jun 9, 2011

                  tell me...
C is blood.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Cybernetic Vermin posted:

what is kind of weird is that pascal looked to be winning out for quite some time, but c then returned to relevance.

at any rate and all history aside c should go away on security grounds ityool 2024.

eh. most of the security issues that aren't also problems in other languages have warnings available

yes there are flags you should enable in 2024CE. but there's heinous poo poo you can do in all languages if you ignore recommendations

Cybernetic Vermin
Apr 18, 2005

leper khan posted:

eh. most of the security issues that aren't also problems in other languages have warnings available

yes there are flags you should enable in 2024CE. but there's heinous poo poo you can do in all languages if you ignore recommendations

much like properly handled and bonded into some other material asbestos is really entirely safe.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
the difference being that asbestos is intrinsically excellent at insulating

c is not intrinsically efficient or mechanically sympathetic for modern machines, it just has a gigantic amount of inertia and platform nepotism in its favor

bob dobbs is dead
Oct 8, 2017

I love peeps
Nap Ghost
look, serious world-power nation-states have tried to make their own os's from scratch and have failed, so that platform nepotism thing is not a useful statement because we can't really get off of posix-and-windows

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
yeah. there’s a huge amount of inertia behind the existing platforms. it’s quite straightforward to introduce a new one but, guess what, now you’re just yet another platform with no software, which it’s still on you to fix. basically every talking point about windows vs mac from the last thirty years but amped to 11 because your userbase is optimistically in the three figures. nobody can get their work done there yet, not even the people writing software for it. embracing an existing platform and providing a compelling alternative that plays well with it is a far more plausible way to move things forward

c isn’t intrinsically good at anything but it does have a very simple translation model which makes it easy to optimize, for both the compiler and the programmer. compiler optimizations are limited by some facets of the model, but that model also avoids a lot of implicit work that other languages are prone to. and if we’re traveling back to the 70’s, most of the languages it was competing with were even worse from a safety perspective

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

leper khan posted:

eh. most of the security issues that aren't also problems in other languages have warnings available

yes there are flags you should enable in 2024CE. but there's heinous poo poo you can do in all languages if you ignore recommendations

are there warnings for data races or use-after-free in C in modern compilers? I haven’t honestly written pure C in a long time

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Subjunctive posted:

are there warnings for data races or use-after-free in C in modern compilers? I haven’t honestly written pure C in a long time

use after free yes. not sure about data races, but may have been added after C11's thread support

DELETE CASCADE
Oct 25, 2017

i haven't washed my penis since i jerked it to a phtotograph of george w. bush in 2003
i'm sorry, you want your C compiler to help you use the C programming language correctly? well, blah blah undecidable, blah undefined behavior. so we gave up, sorry

Share Bear
Apr 27, 2004

the general attitude from the outside seem to be; you're just supposed to know which functions to use, and if you don't, and if you havent read the spec, you shouldn't be a C/C++ programmer

like not even a linter or static analyzer that's like "hey you cant use memcpy() (or whatever this is the first one that poppped into mind) anymore"

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

all the modern compilers warn on stuff like gets or whatever, and the various risky str* functions, but those are easy to detect

I'm impressed by use-after-free detection, I didn't know that C compilers could model lifecycles well enough at this point!

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Subjunctive posted:

are there warnings for data races or use-after-free in C in modern compilers? I haven’t honestly written pure C in a long time

yes, especially if you’re willing to add an understanding of a particular host operating system or technology’s multiprocessing features to the analysis tooling

(which isn’t really any different than adding detection of use after free, since things like malloc and free are library-not-language too)

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
this is typically an analyzer feature though not a compiler feature directly

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

Share Bear posted:

the general attitude from the outside seem to be; you're just supposed to know which functions to use, and if you don't, and if you havent read the spec, you shouldn't be a C/C++ programmer

like not even a linter or static analyzer that's like "hey you cant use memcpy() (or whatever this is the first one that poppped into mind) anymore"

https://developers.redhat.com/articles/2024/04/03/improvements-static-analysis-gcc-14-compiler#analyzing_c_string_operations people are still developing on the tools used for C, its amazing!

Kazinsal
Dec 13, 2011
in gcc, -Wuse-after-free will emit warnings if it detects a use after free scenario. iirc if you tag a custom alloc/free as being an alloc/free function it'll do use after free detections on those as well

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
1. there are some very good static analyses that catch common bugs in c/c++

2. they are almost all still static analyses and therefore conservative rather than strict. nobody has made c into a safe language

3. there are a whole bunch of projects to impose a stricter model by default on c. i’ll brag on clang’s -fbounds-safety, which my coworkers are doing, but there are similar efforts out of msr and academia

4. nobody is saying that #3 is in any way adequate except, unfortunately, a lot of the leaders of the c++ community

crazypenguin
Mar 9, 2005
nothing witty here, move along
yeah, "c has use-after-free detection" is one of those things that sounds good until you see the list of asterisks, at which point it sounds like "c does not have use-after-free detection"

Bloody
Mar 3, 2013

c has use after free detection if you never allocate

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
it's fitting that every pointer in c comes with an asterisk

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



pokeyman posted:

it's fitting that every pointer in c comes with an asterisk

pseudorandom name
May 6, 2007

simply unmap the pages when you free the memory and never use them again. easy.

FlapYoJacks
Feb 12, 2009
There’s something nice about going back to the simplicity of C and bare-metal programming. Been doing that for a bit for a small client of the business and it’s nice. Just me, registers, and pointers. :unsmith:

redleader
Aug 18, 2005

Engage according to operational parameters

Share Bear posted:

the general attitude from the outside seem to be; you're just supposed to know which functions to use, and if you don't, and if you havent read the spec, you shouldn't be a C/C++ programmer

like not even a linter or static analyzer that's like "hey you cant use memcpy() (or whatever this is the first one that poppped into mind) anymore"

there are six thousand c functions called things like strlncpy and strnl_cpy and lnstr_nlcpy_st and if you use one of the 5998 old, wrong ones then your program will result in the complete takeover of your machine. and different platforms will have different subsets of these functions available

redleader
Aug 18, 2005

Engage according to operational parameters

pokeyman posted:

it's fitting that every pointer in c comes with an asterisk

thread title

Xarn
Jun 26, 2015

redleader posted:

there are six thousand c functions called things like strlncpy and strnl_cpy and lnstr_nlcpy_st and if you use one of the 5998 old, wrong ones then your program will result in the complete takeover of your machine. and different platforms will have different subsets of these functions available

They are also all wrong.

strcpy is the dangerous one
strncpy is the one that looks correct and is also the dangerous one,
strlcpy is just extremely dumb

Buck Turgidson
Feb 6, 2011

𓀬𓀠𓀟𓀡𓀢𓀣𓀤𓀥𓀞𓀬
strcpy_ver4_FINAL_USE_THIS_ONE

Plorkyeran
Mar 22, 2007

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

pseudorandom name posted:

simply unmap the pages when you free the memory and never use them again. easy.

that's not entirely unlike what asan does

pseudorandom name
May 6, 2007

once you’ve cycled through the entire 2^48 bit address space you should serialize your execution state and restart the program because something else has surely gone wrong by now.

good practice for crash only software too

Soricidus
Oct 21, 2010
freedom-hating statist shill

Xarn posted:

They are also all wrong.

strcpy is the dangerous one
strncpy is the one that looks correct and is also the dangerous one,
strlcpy is just extremely dumb

it’s almost like the real problem was nul-terminated strings all along

DELETE CASCADE
Oct 25, 2017

i haven't washed my penis since i jerked it to a phtotograph of george w. bush in 2003

FlapYoJacks posted:

There’s something nice about going back to the simplicity of C and bare-metal programming. Been doing that for a bit for a small client of the business and it’s nice. Just me, registers, and pointers. :unsmith:

c is pretty far from bare metal on a modern system and that’s half the problem. registers are a nice example. feel free to use the register keyword in c, chances are it does nothing at all. even your assembly registers aren’t the real registers and haven’t been for decades. it might tickle the feels to program for a nice simple pdp-11 inspired architecture, but that’s not the architecture you have. might as well just be another virtual machine

Grum
May 7, 2007
sup guys just got back from my job in the instrinsics mines

Adbot
ADBOT LOVES YOU

akadajet
Sep 14, 2003

DELETE CASCADE posted:

even your assembly registers aren’t the real registers and haven’t been for decades.

w- what are you trying to say? :ohdear:

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