Let op: Tweakers stopt per 2023 met Tweakblogs. In dit artikel leggen we uit waarom we hiervoor hebben gekozen.

Temporarily disabling Address Space Layout Randomization on Linux en

By Soultaker on zondag 24 september 2017 15:15 - Comments are closed
Category: Tips & Tricks, Views: 10.350

Address Space Layout Randomization

Address Space Layout Randomization (ASLR) is a kernel feature which causes the kernel to randomize the addresses at which the code and data of a program are loaded, including the addresses of dynamic allocations and memory mappings. The intent is to improve security: when addresses are unpredictable, it is more difficult for attackers to exploit vulnerabilities like buffer overflows, because the code they inject cannot refer to absolute addresses.

However, there is a downside, too: when using memory debuggers (like mtrace) the heap addresses and code locations those tools report are randomized, and it may be difficult to determine what they reference. One way to work around this is to look at the memory maps (e.g. in /proc/${pid}/maps) while the program is running, but this is cumbersome, error-prone and doesn't help if a memory region has already been unmapped or the program has already exited. The easier solution is to temporarily disable ASLR for debugging.

It turns out that in Linux, there are two easy ways to do that. (Note that although many operating systems support ASLR in some form, this post is only about Linux, which happens to be my primary development platform.)

Read more »

Facebook Hacker Cup 2016: Round 2 problem analysis

Door Soultaker op zondag 24 januari 2016 20:40 - Reacties (1)
Categorie: -, Views: 5.558

Yesterday Round 2 of the Facebook Hacker Cup was held. This round lasted only 3 hours, and competition was fierce. Only 200 of over 2000 competitors would advance. In the end, over 177 competitors solved all problems. To advance without a perfect score, you could only fail on the easiest problem, and you'd have to submit the other solutions pretty quickly, too.

Unfortunately, under time pressure, I made a small mistake in my solution to the fourth problem, and so I won't be participating in Round 3 this year. :'( On the bright side, at least I'll get a nice T-shirt for my troubles. And you get to read another one of my write-ups!

Lees verder »

Facebook Hacker Cup 2016: Round 1 problem analysis en

By Soultaker on zondag 17 januari 2016 19:00 - Comments are closed
Category: -, Views: 7.395

The first round of the Facebook Hacker Cup has just concluded! As of writing, there are over 600 competitors that have submitted solutions for all four problems. Since only the top 500 advance (including anyone tied for 500th place) a perfect score may be a requirement, though it's also possible that a significant fraction of those solutions turns out to be wrong, as the final results have not yet been announced.

The scoreboard has been updated. 395 people scored 100 points. The minimum score necessary to advance is 85 points, and that covers the top 560.

In the context of the entire contest, Round 1 is quite unique, because it's the only round where accuracy is of critical importance and solution speed does not matter (that is, as long as you manage to solve the problems within 24 hours). Last year, my accuracy was less than perfect and I failed to advance. Hopefully, I did better this year!

Fortunally, the problems were not too difficult. Let's have a look!

Read more »

Facebook Hacker Cup 2016: Qualification Round problem analysis en

By Soultaker on dinsdag 12 januari 2016 01:00 - Comments (1)
Category: Programming Contests, Views: 7.028

As I'm writing this, the Qualification Round of the Facebook Hacker Cup 2016 is about to finish. For those not in the know: the Hacker Cup is an annual algorithmic programming contest, where contestants solve mathematical puzzles by writing some code (no "hacking" in the contemporary sense involved).

Over the past few years I've been posting my analysis of the problems on my blog, and I thought I might as well continue the tradition. As usual, there are major spoilers ahead, as well as code, and some bonus questions for those that managed to solve all the problems already. So let's begin!

Read more »

Facebook Hacker Cup 2015: Qualification Round problem analysis en

By Soultaker on maandag 12 januari 2015 09:50 - Comments (5)
Category: Programming Contests, Views: 12.869

Another year, another Facebook Hacker Cup, and another opportunity for smart people who know at least one programming language to put their problem solving skills to the test. As in earlier years, I will post a short analysis along with my solution for each problem, and I'll add some follow-up questions that people who have already solved the problems might find interesting.

A. Cooking the Books

Problem Statement (official link).

The qualification round starts off easily. For the first problem, we're given a number, and we're supposed to turn it into the highest/lowest value possible, by swapping just two digits. Warning: spoilers ahead!

Read more »