Categories
embedded systems English articles misc OpenWrt Tech

GDB behaves strange while debugging threads

While debugging issues involving binaries on a system running Linux, having a debugger such as GDB available is quite helpful.

However while working on a certain project we recently experienced quite some issues debugging applications involving threads.

Debugging the application on my local workstation worked quite fine, however on OpenWrt-targets – ARM as well as MIPS – it behaved rather strange: stack corruptions, missing traces, weird signals got issued…

After quite some time of debugging the debug issue, we found out the issue is caused by a stripped version of libpthread.so.

Stripped – not in the sense of a more lightweight but compatible version of the pthread library – but stripped by the utility “strip”, which purges all debug- and “other unneeded” symbols out of binaries to reduce their size, which usually is applied on all binaries by the OpenWrt framework automatically.

Usually binaries stripped by “strip” are still fully-fledged binaries, still usable with GDB (however without debugging symbols available of course). Applying strip on libpthread.so* however, it seems to strip out also stuff needed by GDB following and tracing threads. Without these symbols / meta-information not needed for running the actual application, but for tracking its threads, GDB results in mentioned issues above.

One might ask why someone is debugging binaries without debug symbols compiled in – reasons are obvious:

  • there’s not enough storage available
  • there’s not enough RAM available
  • using gdbserver and having the binaries with debug symbols compiled in on another machine communicating with gdbserver

To check whether an object got stripped or not is quite easy using the “file” util:

$ file build_dir/target-arm_v5te_uClibc-0.9.30.1_eabi/root-foo/lib/libpthread-0.9.30.1.so
build_dir/target-arm_v5te_uClibc-0.9.30.1_eabi/root-foo/lib/libpthread-0.9.30.1.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked (uses shared libs), stripped

$ file staging_dir/target-arm_v5te_uClibc-0.9.30.1_eabi/root-foo/lib/libpthread-0.9.30.1.so
staging_dir/target-arm_v5te_uClibc-0.9.30.1_eabi/root-foo/lib/libpthread-0.9.30.1.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

Long story short: When debugging applications involving threads, always use a non-stripped version of libpthread.so, even if debug symbols are not needed!

Categories
Bali (Indonesia) English articles misc My life Trips

closing…

Being back home for almost two month now, I finally find some time to close this category, my trip to Bali.

I’ve been in Tanah Lot – an area where a rather famous temple of the same denominator is located. It’s kind of an island during high tide but accessible when tide is low.

Because of it’s formation, location and a spring of freshwater inside, a priest declared it as an holy place in the 15th century.

Seriously, it’s an amazing place (however flooded by tourists and locals trying to sell stuff).

After Tanah Lot I got back to Sanur, wanted to stay there just a few days and then move to the so called Gili islands…

…however unfortunately I got ill, got the Dengue fever.

I don’t want to elaborate my almost last 10 days on Bali, however it was everything but nice and I do not wish anyone getting this bloody fever – seriously…

Closing statement:

It was great (apart from the fever I got)!

Seriously, Bali is no place where you’re going to struggle in any way… the Balinese economy is based on tourism, so you can get there almost every (western) stuff – it’s everything but a survival training (assumed you’re not getting ill).

Bali is a perfect mix of paradise-like beach and sea (have a look at the photos posted a few posts below) and cultural experiences (despite the tourism the Balinese people try hard to keep and practise their culture) like their huge amount of temples, sacrificial offerings several times a day, performances, etc.

There is lot’s of tourism, and partially too much of it for sure (for example Kuta and surroundings) – however the locals are really lovely and open-minded, it’s quite easy to socialise and get in touch with them…

Sharing some time of their everyday life is a definite recommendation if you’re not just there for beach, sea and sun but interested as well in their daily grind and culture.

They are more than pleased to show you around, quiet interested in western politics, habits, views, etc. – answering your questions in exchange for yours 🙂

To those Balinese / Indonesian I met there, reading this:

Thanks you so much for the great time !!

Categories
Bali (Indonesia) Brussels (Belgium) Dalian (china) embedded systems English articles fun German articles misc My life Openmoko OpenWrt qi-hardware Taipei (Taiwan) Tech Trips Windows Mobile

comments, twitter…

I recognized just a few hours ago, there were comments written, which needed to be approved…

Did so now and tried to respond to them – sorry for the delay and thanks a lot for your input/contributions!

As most people reading my blog do know already anyway and I no longer feel ashamed of using it…

My twitter username: foobarbablub – respectively the twitter page: http://twitter.com/foobarblablub

Polluting the twitter cloud with statements / impressions I don’t think they’re worth a whole blog post… most tweets are not related to technical / computer stuff by the way – used language is mostly English…

Categories
English articles fun misc Tech

PHP – fooled me once again…

I was asked to take a look at several free and opensource software web-projects which are capable for so called “ISP configuration management”, managing web-, mail-, database-servers, etc. – handling clients, resellers and admins and having specialized frontends for them…

Anyway… I trigerred a weird bug in one of the projects where I got into an if-condition where I shouldn’t get into… which not just caused a weird behaviour of the application but was also a big security hole in this special case.

The code was something like that (simplified and not tested):


get_sql($value) {
   if ($ret = mysql_query ("SELECT * FROM `table` WHERE foo='%s'"),
       mysql_real_escape_string($value))
   {
     return $ret;
   }
   else
   {
     return false;
   }
}
<br />
$result = get_sql($foo);
if (count($result) &gt; 0) {
&nbsp;&nbsp; // privileged area...
}

Ugly code – anyway… how it was expected to behave by the author?
1) function get_sql() gets executed and therefore a sql-query
2) get_sql() returns an array of results
3) the number of results is checked via count($result) and when the result-array is greater than 0 jump into the if-block

Okay, so far so good…

However – I finally found out the SQL-query in get_sql() fails because of a typo.
No error was thrown in the above code – so what’s happening?
1) function get_sql() gets executed and therefore a sql-query
2) get_sql() returns the boolean false, because the sql-query failed
3) count($result), evaluated count(false) is called

As the software just did behave different and didn’t throw an error an intermediate result is:

count() applied on a boolean is valid !

So what’s count(false) going to return?

1! – the integer one!

count(false) is 1 and in PHP therefore true!

Proof:


$ php
&lt;? echo count(false); ?&gt;
1
$

Even better: this behaviour is kind of “documented” within an example at http://php.net/manual/en/function.count.php without any comment.

Okay, now guess:
What’s count(true) returning? And this is not documented!

1! – the integer one!

PHP – dine in hell…

Categories
Brussels (Belgium) embedded systems English articles German articles misc Tech Trips Uncategorized

FOSDEM

Me and most of the other OpenWrt-guys are going to FOSDEM – the Free And Open Software Developement Meeting in Brussels.

See you there! 🙂

Categories
English articles misc

changes…

Hey,

now I set up wordpress again and invested a lot of time for merging all posts from previous blogs / cm-systems.

I also recategorized them, added a new lightweight design and decided to start writing some of the future posts (like this) in English, ’cause this blog is mainly tech-oriented and – at least – these posts should also be readable by non-german-speaking visitors.

But this decision is associated with a huge disadvantage: you have to read my fucking bad English 😉

Categories
German articles misc My life

ich will euch ja nicht nerven…

…aber irgendwie macht das Blog-Schreiben Spaß.

Ich überlege, ob ich sämtliche Inhalte, welche jetzt noch auf www.nanl.de/nanl/ liegen hierhin transferriere, da ich in keinster Weise von mambo begeistert bin und es relativ overskilled ist für ein bisschen Doku zu meinen Projekten und “Lebensberichten” 😛

Sooo… erstmal frühstücken…

So long…

Categories
German articles misc

Design

Auch wenn dieses Design ein wenig an die Anfänge der Pseudo-Hacker-Website-Designgeschichten erinnert, finde ich es trotzdem irgendwie cool.

Evtl. änder ich das bei Gelegenheit nochmal bzw. wenn mir ein seriöseres Theme in die Hände fällt.

So long…

Categories
German articles misc

WTF means nAnL ?!?!?11ßelf

nAnL war ein ehemaliger Counter-Strike-Fun-Clan dem ich angehörte (ja, so was gab’s mal :)), dessen Clan-Tag ausgeschrieben “nix Aim nur Luck” bedeutete.

Der Clan löste sich kurz darauf auf (wie so ziemlich alle, denen ich angehörte – ob sie vor meinem Skill flüchteten?) und ich hab mir die Domain unter den Nagel gerissen.

Kurze Domains mit Sinn sind selten, was im konkreten Fall wohl bedeutet, dass die DeNIC Geld an einer weiteren sinnlosen Domain verdient 🙂

So, das war mein erster Post.

So long,

d@ten