Live data from Hacker News

I found a bug in the .NET framework and fixed it by hand-altering the DLL

blog.nullspace.io

71–80 of 124 posts

Re: I found a bug in the .NET framework and fixed it by hand-altering the DLL

#71

The fact that you can even do this without setting off a ton of alarmbells about failed checksums is what really scares me.

How would you enforce that? First, hashing every byte of every loaded DLL destroys your runtime.

Second, if you're able to modify one DLL, you could overwrite whatever DLL was tasked with computing the checksum.

Re: I found a bug in the .NET framework and fixed it by hand-altering the DLL

#72
post #17

Earlier quoted context omitted.

> Well, GCC is next-to-impossible to compile for a target other than the host, especially if the target isn't x86 or ARM; You're exaggerating. I had no problems compiling gcc 3.something targeting MIPS-I on an x86 Linux host.

I can't tell if you're being sarcastic. Generally, compiling GCC to target another architecture involves not only recreating most of the root directory structure (notably include files) of the target on the host, but also compiling libc, bintools, and a few other more obscure libraries. And this all needs to be done in the correct order (which involves something like compiling half of libc before compiling GCC, and c…

Have you tried to use buildroot ? http://buildroot.uclibc.org/

Re: I found a bug in the .NET framework and fixed it by hand-altering the DLL

#73
post #17

I did this once with GCC. "But GCC's open source!" you say. Well, GCC is next-to-impossible to compile for a target other than the host, especially if the target isn't x86 or ARM; and GCC maintainers insist on precise test cases to vet a bug, even if the issue is immediately obvious from reading the source code and the bug only occurs in certain very complex situations. (/me looks forward to the day Clang/LLVM become…

> Well, GCC is next-to-impossible to compile for a target other than the host, especially if the target isn't x86 or ARM; You're exaggerating. I had no problems compiling gcc 3.something targeting MIPS-I on an x86 Linux host.

I tried to compile GCC for ARM (from X86 Windows), and it was a nightmare

Re: I found a bug in the .NET framework and fixed it by hand-altering the DLL

#74

Earlier quoted context omitted.

So, do you think this is Dino's fault? :P

Hah. Or Tomas. Not sure. The S.L.E.Interpreter is after my time :)

It might be my fault... The DLR interpreter got rolled into .NET native so that ETs could be interpreted (hence the weird EETypeRva:0x01588388 error). I actually did the initial set of work on that having had experience w/ the DLR interpreter and handed that off to the .NET team. I probably did the expression quoter but I don't quite remember :(

One thing I'll point out though, it's a Field on StrongBox for correctness not performance - the field needs to be capable of being passed by reference to get consistently correct semantics. That's simply not possible on .NET native using the interpreter so it will end up with copy in / copy out semantics (which could break people but it's pretty unlikely). Also StrongBox pre-existed the DLR expression compiler and was originally added w/ LINQ's ETs in 3.5 so we were also just re-using what they had already done. IronPython actually had Reference early on which grew into the DLR's version and then finally converged back on StrongBox.

Re: I found a bug in the .NET framework and fixed it by hand-altering the DLL

#75
post #25
post #7

The real news here is that this is considered special. In most other languages, they'd have forked the source, fixed it, recompiled it for their own uses and submitted a pull request or patch. I'm a big .NET fan, but the fact that we have to jump through such hoops to find and fix a bug, and then still have near certainty that we're going to have to reapply the patch for many updates to come, well, that's just a bit…

I've very rarely heard of shops running forked, re-compiled runtimes for languages like python or ruby. Normally if you find a bug in the core you might try to monkeypatch but many times that won't work so you have to suck it up and just work around it.

There's actually a bunch of shops running forked and recompiled runtimes for languages like python and ruby. I happen to work for a company who maintained such a fork (Ruby Enterprise Edition, by Phusion), and we weren't the only ones who had forks. Most famous were the MBARI patches, made by a guy who worked at MBARI and needed those for running ruby in a submarine or something :P The patches were actually very impressive, despite coming from a biology research institute.

(Note that these were forks because they changed aspects of Ruby that were not in line with Ruby's general purposeness, so they were not allowed to merge into mainline Ruby)

Re: I found a bug in the .NET framework and fixed it by hand-altering the DLL

#76
post #9

Earlier quoted context omitted.

---Author here--- I should disclose that I actually work for Microsoft, and still chose the hard way. Fuck the police!

Out of curiosity, would you have been able to read the actual source if you wanted?

And an extension called Ref12 will also allow you to browse to the online code from Visual Studio.

Re: I found a bug in the .NET framework and fixed it by hand-altering the DLL

#77
post #9
post #7

The real news here is that this is considered special. In most other languages, they'd have forked the source, fixed it, recompiled it for their own uses and submitted a pull request or patch. I'm a big .NET fan, but the fact that we have to jump through such hoops to find and fix a bug, and then still have near certainty that we're going to have to reapply the patch for many updates to come, well, that's just a bit…

---Author here--- I should disclose that I actually work for Microsoft, and still chose the hard way. Fuck the police!

[deleted]

Re: I found a bug in the .NET framework and fixed it by hand-altering the DLL

#78
post #9
post #7

The real news here is that this is considered special. In most other languages, they'd have forked the source, fixed it, recompiled it for their own uses and submitted a pull request or patch. I'm a big .NET fan, but the fact that we have to jump through such hoops to find and fix a bug, and then still have near certainty that we're going to have to reapply the patch for many updates to come, well, that's just a bit…

---Author here--- I should disclose that I actually work for Microsoft, and still chose the hard way. Fuck the police!

You chose the really hard way, the reference source is public - http://referencesource.microsoft.com :P

Re: I found a bug in the .NET framework and fixed it by hand-altering the DLL

#79
post #72

Earlier quoted context omitted.

I can't tell if you're being sarcastic. Generally, compiling GCC to target another architecture involves not only recreating most of the root directory structure (notably include files) of the target on the host, but also compiling libc, bintools, and a few other more obscure libraries. And this all needs to be done in the correct order (which involves something like compiling half of libc before compiling GCC, and c…

Have you tried to use buildroot ? http://buildroot.uclibc.org/

Unfortunately this had to cooperate with an existing root environment on the target, so buildroot (as fantastic as it is) was not an option.

Re: I found a bug in the .NET framework and fixed it by hand-altering the DLL

#80

Sidebar: I haven't done deep C# in several years, since moving to F#. This code is getting to look butt-ugly. It is not a good thing if it continues like this. We already have C++. Don't need another one.

I do both C# and F#. But, at this point I think in ML no matter what which language I'm using. That said, though I'm delighted by F#, there are things that I really miss about C#:

* Haskell's type classes are awesome, and neither F# nor C# have them. But, you can realize them with a really simple pattern in C# whereas in F# you have to resort to reflection or generic hacks[1] (but inline functions usually make such hacks nicer in F#).

* Sum types are awesome. F# realizes them in two ways: with discriminated unions and pattern matching (mainly), or with abstract classes and inheritance. Both are powerful approaches, but the latter is particularly useful when you need unbounded sum types. Unfortunately, inheritance is somewhat crippled in F# because you can't define protected members (though you can override them). I find myself needing this when I'm designing a solution rather than merely implementing one. For instance, I find that designing a language/compiler is much easier with C# than with idiomatic F#.

* This is kind of a summary of the first two points: idiomatic C# is a better dynamic language, and I'm not referring to the `dynamic` keyword, though it certainly helps. I've created some really nice and secure APIs by making use of user-defined conversions. System.Linq.Xml is a good example of what I'm talking about.

* Finally, idiomatic C# is a nicer classical OO language than idiomatic F#. This is kind of obvious since F# is a "functional language" with OO features whereas C# is an OO language with functional features. But, when I say classical OO, I mean the Smalltalk style OO that came before C++. Alan Kay defined that kind of OOP as (1) Encapsulation, (2) Message Passing, and (3) extreme late binding. Neither C# nor F# quite has (2) and (3), but C# gets me the closest without coloring too far outside of the lines. Of course, this begs the question that OO is better than functional. Having done both for a long time, I'm convinced that it is the case (though I do think learning functional programming is the fastest path to getting good at OO). Lamentably, I can't yet defend this point too vigorously because I've only just discovered the joy or Smalltalk. But, here is a preview of sorts: Imagine being able to update a database schema and having your statically-typed code continue to run without needing to recompile.

[1] http://stackoverflow.com/questions/9868327/f-type-constraint...

Post reply on HN