News for hackers. Stuff that matters.
Re:Make CPython segfault in 5 lines of code by dependenttypes on Thursday December 19, 2019 @12:18AM (#21832151)
This would not have happened in a language with a proper type system as the type checker would have rejected the program at compile time.
Re:Make CPython segfault in 5 lines of code by shakna on Thursday December 19, 2019 @04:00AM (#21833198)
> This would not have happened in a language with a proper type system as the type checker would have rejected the program at compile time.

How about in Rust, then? [0]

Bugs happen in every language. When memory corruption occurs, you can segfault.

[0] https://users.rust-lang.org/t/rust-guarantees-no-segfaults-w...

Re:Make CPython segfault in 5 lines of code by dependenttypes on Thursday December 19, 2019 @05:07AM (#21833506)
I said "a language with a proper type system". Rust is not one such language.
Re:Make CPython segfault in 5 lines of code by shakna on Thursday December 19, 2019 @08:55AM (#21834874)
You'll need to define "proper type system" then.

At a guess, you want something with dependent types?

Like Idris, or Haskell. You already have a Haskell example. This [0] release of Idris fixed a segfault when concatenating strings.

Maybe you meant a language that is proven from the ground up. Like CakeML. You can find a segfault example here [1].

Maybe you meant a language with an algebraic type system like Ada. You can find a segfault example here [2].

Maybe you meant something like Dotty (Research for the next version of Scala). You can find a segfault example here [3].

In short: You'll need to describe what you believe to be a "proper" type system, and name the languages you think fit that description, or no one can have a conversation with you.

[0] https://www.idris-lang.org/idris-1-1-1-released/

[1] https://github.com/CakeML/cakeml/issues/438

[2] https://stackoverflow.com/questions/56227629/segmentation-fa...

[3] https://github.com/lampepfl/dotty/pull/7466/

Re:Make CPython segfault in 5 lines of code by dependenttypes on Friday December 20, 2019 @10:13AM (#21844724)
You can trivially prove bottom in Haskell. Something like Agda or Idris would indeed fit the bill better.

Anyway, I said that this specific issue would not occur in a language with dependent types -- where incorrect code would cause the implementation to crash. Not that it is impossible to have a buggy compiler that at certain cases produces segfaults.

Re:Make CPython segfault in 5 lines of code by shakna on Friday December 20, 2019 @03:54PM (#21847309)
> Not that it is impossible to have a buggy compiler that at certain cases produces segfaults.

That's exactly what happened here, however. The instance check was missing from the interpreter.

Dependant types wouldn't have solved the underlying problem.

Re:Make CPython segfault in 5 lines of code by Znafon on Thursday December 19, 2019 @05:40AM (#21833674)
Can you give an example of such language so we don't have to guess?

Apparently neither Rust, Haskell nor Go fit.

Re:Make CPython segfault in 5 lines of code by dependenttypes on Friday December 20, 2019 @10:14AM (#21844728)
check my username
Re:Make CPython segfault in 5 lines of code by _ZeD_ on Thursday December 19, 2019 @01:47AM (#21832596)
literally 3 seconds with google:"ghc segfault"

https://github.com/lehins/ghc-segfault

Re:Make CPython segfault in 5 lines of code by saagarjha on Thursday December 19, 2019 @01:26AM (#21832487)
Type confusion and memory corruption is still possible in statically-typed languages, generally due to bugs in the runtime.