rm -rf command, I'll start by suggesting that
you hit ctl-c. The sooner the better.
Next, assuming you have some sort of backup, you'll be staring at two
monumentally large data sets, wondering exactly what was deleted from the
original.
With help from dkg, I
learned somethings about rm -rf. For one, it deletes one top level directory
at a time. So - a comparison of the top level directory listings of the
original and backup is a good place to start.
Top level directories that are entirely missing in the original are easy to
restore. However, the presence of a top level directory in the original doesn't
mean it was un-touched.
Next, you'll want to figure out which top level directory rm was operating on
when you hit ctl-c. dkg discovered that ls -UR will provide a listing in the
same order that rm -rf uses. The -U means do not sort. Note - the unsorted
listing of the backup directory might not be the same as the unsorted listing
of the original, so ls -UR is only really helpful on the original directory.
After selecting the first top level directory, rm -rf seems to delete all
files in that directory first (presumably in the same order that ls -UR will
list them), then it enters the first sub directory (as returned by ls -UR) and
repeats the process.
With a careful comparison of ls -UR on the original with the directory
listings on the backup, you should be able to pinpoint the exact sub
directories affected, allowing you to restore only the files and directories
that you deleted.
Thanks to dkg for technical and blog title suggestions.
The relationship between Debian and Ubuntu has been the subject of many
vigorous debates over the years, ever since Ubuntu s launch in 2004.
Six years later, the situation has improved and both projects
are communicating better. The Natty Narwhal Ubuntu Developer
Summit (UDS) featured like all UDS for more than 2 years a Debian
Health Check session where current cooperation issues and projects are
discussed. A few days after that session, Lucas Nussbaum gave a talk
during the mini-Debconf
Paris detailing the relationship between both projects, both at the
technical and social level. He also shared some concerns for Debian s
future and gave his point of view on how Debian should address them.
Both events give valuable insights on the current state of
the relationship.
Lucas Nussbaum s Debian-Ubuntu talk
Lucas started by introducing himself. He s an Ubuntu developer since 2006
and a Debian developer since 2007. He has worked to improve the collaboration
between both projects, notably by extending the Debian infrastructure to show
Ubuntu-related information. He attended conferences for both projects
(Debconf, UDS) and has friends in both communities. For all of these reasons,
he believes himself to be qualified to speak on this topic.
Collaboration at the technical level
He then quickly explained the task of a distribution: taking upstream
software, integrating it in standardized ways, doing quality assurance on
the whole, delivering the result to users, and assuring some support
afterward. He pointed out that in the case of Ubuntu, the distribution
has one special upstream: Debian.
Indeed Ubuntu gets most of its software from Debian (89%), and
only 7% are new packages coming from other upstream projects (the
remaining 4% are unknown, they are newer upstream releases of software
available in Debian but he was not able to find out whether the Debian
packaging had been reused or not). From all the packages imported from
Debian, 17% have Ubuntu-specific changes. The reasons for those changes
are varied: bugfixes, integration with Launchpad/Ubuntu One/etc., or
toolchain changes. The above figures are based on Ubuntu Lucid (10.04) while
excluding many Ubuntu-specific packages (language-pack-*, language-support-*,
kde-l10n-*, *ubuntu*, *launchpad*).
The different agendas and the differences in philosophy (Debian
often seeking perfect solutions to problems; Ubuntu accepting
temporary suboptimal workarounds) also explain why so many packages are
modified on the Ubuntu side. It s simply not possible to always do the
work in Debian first. But keeping changes in Ubuntu requires a lot of work
since they merge with Debian unstable every 6 months. That s why they have
a strong incentive to push changes to upstream and/or to Debian.
There are 3 channels that Ubuntu uses to push changes to Debian: they
file bug reports (between 250 to 400 during each Ubuntu release cycle),
they interact directly with Debian maintainers (often the case when
there s a maintenance team), or they do nothing and hope that the Debian
maintainer will pick up the patch directly from the Debian
Package Tracking System (it relays information provided by patches.ubuntu.com).
Lucas pointed out that those changes are not the only thing that
Debian should take back. Ubuntu has a huge user base resulting in lots of
bug reports sitting in Launchpad, often without anyone taking care of
them. Debian maintainers who already have enough bugs on their
packages are obviously not interested in even more bugs, but those who are
maintaining niche packages, with few reports, might be interested by the
user feedback available in Launchpad. Even if some of the reports are
Ubuntu-specific, many of them are advance warnings of problems
that will affect Debian later on, when the toolchain catches up with
Ubuntu s aggressive updates. To make this easier for Debian maintainers,
Lucas improved the Debian Package Tracking System so that they can easily
get Ubuntu bug reports for their packages even without interacting with
Launchpad.
Human feelings on both sides
Lucas witnessed a big evolution in the perception of Ubuntu on the Debian
side. The initial climate was rather negative: there were feelings of its work
being stolen, claims of giving back that did not match the observations of
the Debian maintainers, and problems with specific Canonical employees
that reflected badly on Ubuntu as a whole. These days most Debian developers find
something positive in Ubuntu: it brings a lot of new users to Linux, it
provides something that works for their friends and family, it brings new
developers to Debian, and it serves as a technological playground for
Debian.
On the Ubuntu side, the culture has changed as well. Debian is no
longer so scary for Ubuntu contributors and contributing to Debian is The
Right Thing to do. More and more Ubuntu developers are getting involved in Debian
as well. But at the package level there s not always much to contribute, as
many bugfixes are only temporary workarounds. And while Ubuntu s
community follows this philosophy, Canonical is a for-profit company that
contributes back mainly when it has compelling reasons to do so.
Consequences for Debian
In Lucas s eyes, the success of Ubuntu creates new problems. For many
new users Linux is a synonym for Ubuntu, and since much innovation happens
in Ubuntu first, Debian is overshadowed by its most popular derivative.
He goes as far as saying that because of that Debian becomes less
relevant .
He went on to say that Debian needs to be relevant because the
project defends important values that Ubuntu does not. And it needs to
stay as an independent partner that filters what comes out of Ubuntu,
ensuring that quality prevails in the long term.
Fixing this problem is difficult, and the answer should not be
to undermine Ubuntu. On the contrary, more cooperation is needed. If
Debian developers are involved sooner in Ubuntu s projects, Debian will
automatically get more credit. And if Ubuntu does more work in
Debian, their work can be showcased sooner in the Debian context as
well.
The other solution that Lucas proposed is that Debian needs to
communicate on why it s better than Ubuntu. Debian might not be better for
everybody but there are many reasons why one could prefer Debian over
Ubuntu. He listed some of them: Debian has better values
since it s a volunteer-based project where decisions are made publicly
and it has advocated the free software philosophy since 1993. On the other hand,
Ubuntu is under control of Canonical where some decisions are imposed, it
advocates some proprietary web services (Ubuntu One), the installer
recommends adding proprietary software, and copyright assignments are
required to contribute to Canonical projects.
Debian is also better in terms of quality because every package has a
maintainer who is often an expert in the field of the package. As a
derivative, Ubuntu does not have the resources to do the same and instead
most packages are maintained on a best effort basis by a limited set of
developers who can t know everything about all packages.
In conclusion, Lucas explained that Debian can neither ignore Ubuntu
nor fight it. Instead it should consider Ubuntu as a
chance and should leverage it to get back in the center
of the FLOSS ecosystem .
The Debian health check UDS session
While this session has existed for some time, it s only the second
time that a Debian Project Leader was present at UDS to discuss collaboration
issues. During UDS-M (the previous summit), this increased involvement
from Debian was a nice surprise to many. Stefano
Zacchiroli the Debian leader collected and shared the
feedback of Debian developers and the session ended up being very
productive. Six months later is a good time to look back and verify
if decisions made during UDS-M (see blueprint)
have been followed through.
Progress has been made
On the Debian side, Stefano set up a Derivatives
Front Desk so that derivative distributions (not just Ubuntu)
have a clear point of
contact when they are trying to cooperate but don t know where to start.
It s also a good place to share experiences among the various
derivatives. In parallel, a #debian-ubuntu channel has been started on OFTC (the
IRC network used by Debian). With more than 50 regulars coming from both
distributions, it s a good place for quick queries when you need advice
on how to interact with the distribution that you re not familiar
with.
Ubuntu has updated its documentation to prominently feature how to
cooperate with Debian. For example, the sponsorship process
documentation explains how to forward patches both to the upstream
developers and to Debian. It also recommends ensuring that the patch
is not Ubuntu-specific and gives some explanation on how to do it (which
includes checking against a list of common packaging
changes made by Ubuntu). The Debian Derivative Front Desk is
mentioned as a fallback when the Debian maintainer is unresponsive.
While organizing Ubuntu Developer
Week, Ubuntu now reaches out to Debian developers and tries to have
sessions on working with Debian . Launchpad has also been extended to provide a list of bugs with
attached patches and that information has been integrated in the Debian
Package Tracking system by Lucas Nussbaum.
Still some work to do
Some of the work items have not been completed yet: many
Debian maintainers would like a simpler way to issue a sync request (a
process used to inject a package from Debian into Ubuntu).
There s a requestsync command line tool provided by the ubuntu-dev-tools package (which is available in Debian) but it s not yet usable because
Launchpad doesn t know the GPG keys of Debian maintainers.
Another issue concerns packages which are first introduced in Ubuntu.
Most of them have no reason to be Ubuntu-specific and should also end up
in Debian. It has thus been suggested that people packaging new software
for Ubuntu also upload them to Debian. They could however
immediately file a request
for adoption (RFA) to find another Debian maintainer if they
don t plan to maintain it in the long term. If Ubuntu doesn t make
this effort, it can take a long time until someone decides to reintegrate
the Ubuntu package into Debian just because nobody knows about it.
This represents an important shift in the Ubuntu process and it s not
certain that it s going to work out. As with any important policy change,
it can take several years until people are used to it.
Both issues have been rescheduled for this release cycle, so they re still on the agenda.
This time the UDS session was probably less interesting than the
previous one. Stefano explained
once more what Debian considers good collaboration practices: teams
with members from both distributions, and forwarding of bugs
if they have been well triaged and are known to apply to Debian. He also
invited Ubuntu to discuss big changes with Debian before implementing
them.
An interesting suggestion that came up was that some Ubuntu developers could
participate in Debcamp (one week hack-together before Debconf) to work
with some Debian developers, go through Ubuntu patches, and merge the
interesting bits. This would nicely complement Ubuntu s increased presence
at Debconf: for the first time, community management team member Jorge Castro was at DebConf 10 giving a talk on
collaboration between Debian and Ubuntu.
There was also some brainstorming on how to identify packages where the
collaboration is failing. A growing number of Ubuntu revisions (identified
for example by a version like 1.0-1ubuntu62) could indicate that no
synchronization was made with Debian, but it would also identify packages
which are badly maintained on the Debian side. If Ubuntu consistently has
a newer upstream version compared to Debian, it can also indicate a
problem: maybe the person maintaining the package for Ubuntu would be better
off doing the same work in Debian directly since the maintainer is lagging or not
doing their work. Unfortunately this doesn t hold true for all packages
since many Gnome packages are newer in Ubuntu but are actively maintained
on both sides.
Few of those discussions led to concrete decisions. It seems most
proponents are reasonably satisfied with the current situation. Of course,
one can always do better and Jono Bacon is going to ensure that all
Canonical teams working on Ubuntu are aware of how to properly cooperate
with Debian. The goal is to avoid heavy package modifications without
coordination.
Conclusion
The Debian-Ubuntu relationships used to be a hot topic, but that s no
longer the case thanks to regular efforts made on both sides. Conflicts
between individuals still happen, but there are multiple places where they
can be reported and discussed (#debian-ubuntu channel, Derivatives
Front Desk at derivatives@debian.org on the
Debian side or debian@ubuntu.com on
the Ubuntu side). Documentation and infrastructure are in place to
make it easier for volunteers to do the right thing.
Despite all those process improvements, the best results still come out
when people build personal relationships by discussing what they
are doing. It often leads to tight cooperation, up to commit rights to the
source repositories. Regular contacts help build a real sense of
cooperation that no automated process can ever hope to achieve.
This article was first published in Linux Weekly News. You can get my monthly summary of the Debian/Ubuntu news, all you have to do is to click here to subscribe to my free newsletter.
5 comments Liked this article? Click here. My blog is Flattr-enabled.
This week I had to write a little tool that would collect input on
different channels, via socket / netcat, via a http server, .... Calls
for a parralel Design -- Maybe a good place to write something real in
Erlang. While erlang itself was really nice
to write -- I do like Prolog as well as the bunch of functional
languages -- doing networking in erlang seems a bit special, the
interfaces just aren't thin wrappers around the libc stuff.
Getting a Socket Text interface
What sounds like a easy challenge to accomplish was actually harder
than expected. All I found was some way to pass binaries representing
erlang code over a socket and evaluating it remotle. While it's nice
that such things are as easy to do as they are it doesn't help me with
my task of moving simple strings.
start() ->
ok, Listen = gen_tcp:listen(51622, [binary, packet, 0 ,
reuseaddr, true ,
active, true ]),
spawn(fun () -> accept_loop(Listen) end).
accept_loop(Listen) ->
ok, Socket = gen_tcp:accept(Listen),
accept_loop(Listen),
handle(Socket)
handle(Socket) ->
receive
tcp, Socket, Bin ->
io:format("~p~n", binary_to_list(Bin));
tcp_closed, Socket ->
Buffer
end.
So the socket is now up and receives text as wanted. However, as we
are already runnign a parralel program it would be nice to be hable to
handle multiple socket connections in parralel right? For that we just
need to add a spawn() at the right place. The right place is not
the handle(Socket) but the accept_loop(Listen) because the process
that called accept will receive all the tcp messages.
This last part was quite obvious after finding the documentation of
the active, _ properties for the socket. always here means that
you'll receive all data from the socket as erlang Messages, once
delivers one package and waits until it is activated again and false
requires calling a method -- this would have been possible as well
when forking handle(Socket).
The web server
Ok we also want a webserver. We do not want to run some
webapplication inside appache or so, just do some post/get and simple
pages. Erlang here provides a built-in httpd with some mod_esi
that calls some function depending on the URL used. It doesn't do
anything fancy like templating or DB backends or stuff, just taking
strings and building the http answers.
Unfortunately there are no examples around and basically noone seems
to be using this combination (apart from some hacks like mine
probably). So as I needed to get some additional information into the
handler function (a Pid to connect to some service), I, as a novice,
just couldn't find a way. Asking on IRC the solution was rather
simple: Just using erlang's process registry. For more complex stuf
gproc might prove usefull here.
Result
I guess I've got a huge step farther in programming erlang now. The
manpages are easily found by your search engine -- for python I have
to either walk through the (well structured) online documentation or
search for the right link in the search results, for erlang they're
typically first. Also
Joe Armstrong's Books
as proven usefull. The most dificult part probably is getting around
all the nice extras you can do (transfering functions over sockets et
al) and find out how to do the thing you need.
Maybe Facebook knows.
I ve written previously about my reading habits, online and offline, and the patterns I extrapolate to content consumption in general. I ve been talking with other people about this as well, and am beginning to develop a model to apply to my daily life.
There are plenty of unsatisfactory metaphors circulating in this area: we eat the information diet , drink from the fire hose , endure the information explosion , and so on. None of them describe the richness of my experience: the profound variations in style, texture, speed, depth and movement are lost in this kind of dry imagery.
Instead, I think of it like respiration.
We inhale information, and we also exhale it transformed. We do this, consciously or unconsciously, every moment of our lives. Sometimes we do it quickly, other times slowly, and it can be relaxing or stimulating. We only retain a small amount of what we take in, but it becomes a part of us. We can immerse ourselves deeply, meditatively, in a series of breaths, or fail to notice as we breathe shallowly or pause altogether. One breath may be virtually silent, the next filled with a song or a question or a piercing whistle.
We maintain a balance in our breathing, and I aspire to do the same with information: reading and writing, listening and speaking, seeing and being seen. I don t mean this simplistically, that I should do both in equal proportion (imagine trying to write as many words as you read!), but doing both consistently. It is often only when I share an idea that I come to understand it deeply, no matter how much I have read about it. By writing it down, or telling someone about it, I naturally fill in the gaps in my understanding and create mental structures which help me recall and apply what I ve learned.
My input and output should be balanced appropriately for my circumstances. Rapid-fire email is like hyperventilation: I can do it for a while, reading and replying in quick succession, and even feel energized by it, but if I go on for too long, I get dizzy. Running might call for a certain breathing ratio, and Yoga quite a different one. Both can be healthy practices, but they are different, and each requires focus and consistency.
Another key lesson from breathing is to let go. A friend recently told me about his daily online news routine, which included closing any unread tabs at the end of the session. I will sometimes hang onto an article or a video for days or weeks before I find the opportunity to take it in. I eventually get around to most of them, but meanwhile they are taking up space and causing a continuous low level of anxiety or guilt. This information isn t going anywhere, and if it s truly significant for me, it will most likely turn up again. If it doesn t, that s OK too.
Similarly, it s not wise to breathe stale, indoor air for too long. I will try to step outside regularly, and engage with people and media from outside my usual sphere. When the weather is tolerable, I ll open up the house and let plenty of fresh air circulate. This will help me avoid getting stuck in the echo chamber of my own ideas, or in groupthink.
Perhaps most significantly, I will try to remember that information exchange, like breathing, is not an end in itself. It is a means to action. This will remind me to get out of my head regularly, and do something significant with what I ve learned.
Ready? Breathe.
Earlier in the year, Romain and I did a bunch of initial work on a wrapper from
R to the
GNU GSL by way of our
Rcpp package for
seamless R and C++ integration. But other work kept us busy and this fell a
little to the side.
We have now found some time to finish this work for a first release, together
with a nicely detailed eleven page
package vignette.
As of today, the package is now a
CRAN package, and
Romain already posted a nice
announcement on his blog
and on
the rcpp-devel list.
So what does RcppGSL do? I gave the package
its own webpage here
as well and listed these points as key features of RcppGSL:
#include <RcppGSL.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_blas.h> extern "C" SEXP colNorm(SEXP sM) try RcppGSL::matrix<double> M = sM; // create gsl data structures from SEXP int k = M.ncol(); Rcpp::NumericVector n(k); // to store results for (int j = 0; j < k; j++) RcppGSL::vector_view<double> colview = gsl_matrix_column (M, j); n[j] = gsl_blas_dnrm2(colview); M.free() ; return n; // return vector catch( std::exception &ex ) forward_exception_to_r( ex ); catch(...) ::Rf_error( "c++ exception (unknown reason)" ); return R_NilValue; // -WallThis example function is implemented in an example package contained in the RcppGSL package itself -- so that users have a complete stanza to use in their packages. This will then build a user package on Linux, OS X and Windows provided the GSL is installed (and on Windows you have to do all the extra steps of defining an environment variable pointing to and of course install Rtools to build in the first place---Linux and OS X are so much easier for development). Another complete example is in the package itself and provides a faster (compiled) alternative to the standard lm() function in R; this example is the continuation of the same example I had in several versions of my Intro to HPC with R tutorials and in the Rcpp package itself as an early example. We will try to touch base with CRAN package authors using both GSL and Rcpp to see how this can help them. The API in our package may well be incomplete, but we are always happy to try to respond to requests for additional features brought to our attention, preferably via the rcpp-devel list. More information is on the RcppGSL page. Questions, comments etc should go to the rcpp-devel mailing list off the R-Forge page.
bash+ dash=1.4 baobab- that basically asks to install bash to the newest version, dash at version 1.4 and remove baobab. Suppose also that this is a complete solution, that is, all dependencies are satisfied and there are no conflicts.
The work flow of mpm (mancoosi package manager) is as follows :
Debugging a computer program is such an interesting activity because it's
not really a matter of fixing a program. It's a matter of fixing your own
understanding to the point that the cause of the bug becomes obvious.
So debugging means constantly challenging your assumptions, constantly
looking for the overlooked insignificant thing that turns out to be crucial.
I mostly debug by print statements. I don't like it much, but it works.
I add some print statements around the problem area and see if what's going
on matches what the model in my head thinks should be going on. If it
doesn't, I try to fix the model, and if it does, I focus the print statements
in tighter and tighter, deeper and deeper, until I finally reach the bug.
It's nasty and ah-hoc, but it works really well, mostly. And I know I'm in
good company doing it.
But that method can fail; I myself can end up caught in a loop. Like today,
tracking down an obscure bug in Branchable's
auditing subsystem, when I found myself at what was apparantly the point of a
bug: Function A was supposed to call function B, but B never seemed to be
called. So surely A was buggy, and I instrumented it to bits with print
statements and stuff, and started wondering if the libraries it relied on
were somehow breaking it in non-obvious ways before it could call B, or
maybe there was a bug in the runtime language that was breaking the call to B.
Going deeper and deeper didn't help, because the thing I was overlooking was up
at the top level -- one of the first print statements I inserted showed that
all this code was running twice. Why? Didn't seem relevant to the bug so I
ignored it. Of course what I was ignoring was a symptom of the real problem:
The first run was by another subsystem, that happened to redefine function
B temporarily..
Actually, one of the nice things about Haskell is that print statements are not
very helpful in debugging pure code. Pure code tends to get loaded up in ghci
and tested interactively, and the bug is then clear. Or a quickcheck test case
gets written with an invariant that the pure code should satisfy. I spent a
whole day a few weeks ago writing an inverse form of a buggy function in
git-annex just so I could feed them both into quickcheck and automate
debugging. (Most of that time was spent wrestling with unicode decomposition ..
ugh.) Being used to getting down in the buggy code with print statements, that
at the time felt rather like a waste of time unrelated to getting on with
making my program work, but it was very much worth it since I got my program
working 100% in even crazy edge cases, and got a test suite for free, too.
Most of my debugging of Haskell code so far has not involved bugs in pure
code. The most memorable bug was actually
a bug in ghc's IO manager,
which I'd have never tracked down without Josh's help. The problem with
finding bugs in the runtime environment or compiler is that after you've found
enough over the years, you're more likely to go down false paths distrusting
runtime environments, like I did with the bug today. The beginner's
assumption is that the runtime environment just works, but I by now may
have over-challenged that assumption. :)
Having rediscovered the wonders of GPG, I finally got around generating myself a 4096R key, signing it with my old key and issuing a transition statement. Given this, if
Developers are a crucial part of any successful software platform. In the same way that an operating system is just a means for people to use applications, a platform is just a means for developers to create applications and make them available to people.
There are three primary ways in which Ubuntu can help developers do their work. They are all related, but distinct, and so we should consider them individually:
1. Developing for Ubuntu
Today, Ubuntu bundles thousands of free software applications, for both clients and servers, most of which are packaged by Debian.
Ubuntu also carries certifications for a variety of third-party ISV software, both open source and proprietary, which are coordinated through Canonical s partner program.
In both of these cases, many of these applications are actually developed on other platforms, and ported to Ubuntu, either by the free software community or by the creators of the software.
2. Developing on Ubuntu
Ubuntu is already quite popular among developers, who mainly run Desktop Edition on their workstations. They might be developing:
=debian-x mailbox.
Debian XSF News #1
mesa 7.9
was uploaded to experimental by Julien Cristau.xserver-xorg-sun* drivers to experimental for us.mrconfig file to ease downloading/updating all XSF packages,
thanks to the mr tool, and
some bits of documentation. I also
added the git URL
to the upstream repositories to debian/watch* for all packages.DRI, and unfortunately, I
haven t digged into mesa yet, but thankfully we had some answers
from upstream there.xfonts-* packages, prepared by Julien Cristau.x11-* bundles as well. Why are we creating
bundles? Because there are many tiny applications, which (from the
distribution point of view) don t deserve their own package. For
example x11-apps contains toys like xclock, xeyes, or
xlogo.lib* packages, plus pixman. When there were no
fundamental changes (as in: no need for an shlibs bump, which
could prevent some packages from migrating), those were uploaded to
unstable, others went to experimental.libx11, from a stable
branch. The
2:1.3.3-4 version
has been unblocked for squeeze,
and brings support for
Compose O A and for
Compose \ o /.apple:badmap and
apple:goodmap options for macintosh keyboards in
xkeyboard-configuration (which produces the xkb-data binary
package), thanks to a
bugreport from Yves-Alexis Perez;
it s been unblocked for squeeze as
well. If someone notices an inversion of those keys after the
upgrade, that s probably because one of those options was added at
some point, was ignored and unnoticed, and finally taken into
account. Depending on the case, it s sufficient to switch to the
other one, or to remove it entirely.experimental.xserver-xorg-video-mga user (Ferenc W gner), we were
able to extract and apply a patch from
launchpad s #292214
to fix the dual head
breakage. Since we haven t seen any complains since then, we ll
probably ask for an unblock for squeeze.RC1 for
X11R7.6
and it d be nice to keep it that way, but that requires time/work.
Somebody linked me to this reddit story about the fact that Viewsonic appear to be engaging in the currently fashionable trend of shipping Android devices without providing any source. This one's more interesting though, in that Viewsonic appear to be entirely happy to publicly state that they have no intention of following their license obligations. I've pulled the kernel image for the device and confirmed that it contains code that's not present in the generic Android Tegra tree, so I don't think they have a leg to stand on here.
Alice: hey bob, got a second?? Bob: yes! Alice: alright cool, I want you to try something real quick Bob : ok Bob : :)At this point, I had zero suspicion about who was really talking to me..
Alice: alright bob, try this test and show me what you get.. i can't get over like a 105, its pathetic http://stupid-iq-test.comYes, looking at the stupid IQ test and knowing some facts about the person asking me to do it, I became suspicious, so I tried a first question:
Bob : what do I get from that ? :) Alice: lemme know what ya get plz, so far everyone beat me, except for Clarence LOL be carfeful some of the questions are hard ;-)Not too bad of an answer! Also, Clarence is one of our common friends and knowing Clarence, he could indeed have challenged Alice. But I was still suspicious so I tried a last question:
Bob: how much did you get ? Alice disconnectedTalking in real life, it appears that it was indeed a bot... I'm quite impressed, though. I wonder now the extend of work they have put in it to make it sound real to me...
I finally took some time to finish my color contrast corrector. It's now able to compare two colors and to tell if they are readable when used as foreground and background color for text rendering. If they are too close, the code corrects both colors so to they'll become distant enough to be readable. To do that, it uses color coordinates in the CIE L*a*b* colorspace. This allows to determine the luminance difference between 2 colors very easily by comparing the L component of the coordinates. The default threshold used to determine readability based on luminance difference is 40 (on 100), which seems to give pretty good results so far. Then it uses the CIE Delta E 2000 formula to obtain the distance between colors. A distance of 6 is considered to be enough for the colors to be distinctive in our case, but that can be adjusted anyway. That depends on reader's eyes. If both the color and luminance distances are big enough, the color pair is considered readable when used upon each other. If these criteria are not satisfied, the code simply tries to correct the color by adjusting the L (luminance) component of the colors so their difference is 40. Optionally, the background color can be fixed so only the foreground color would be adjusted; this is especially handy when the color background is not provided by any external style, but it the screen one (like the Emacs frame background in my case). Here is an example result generated over 10 pairs of random colors. Left colors are randomly generated, and right colors are the corrected one. <style type="text/css"> </style>
bg: DarkSeaGreen4 fg: gray67 -> fg: #4a6b4b bg: #cccccc bg: SlateGray4 fg: forest green -> fg: #9faec0 bg: #005700 bg: grey13 fg: grey36 -> fg: #131313 bg: #6c6c6c bg: MediumPurple2 fg: honeydew -> fg: #9e78ed bg: #f0fff0 bg: grey43 fg: chartreuse3 -> fg: #5e5e5e bg: #79de25 bg: linen fg: DeepPink2 -> fg: linen bg: DeepPink2 bg: CadetBlue4 fg: blue1 -> fg: #6c9fa4 bg: #0000e1 bg: gray33 fg: NavajoWhite3 -> fg: #525252 bg: #cfb58c bg: chartreuse1 fg: RosyBrown3 -> fg: #9cff38 bg: #b28282 bg: medium violet red fg: DeepPink1 -> fg: #9c0060 bg: #ff55b9All this has been written in Emacs Lisp. The code is now available in Gnus (and therefore in Emacs 24) in the packages color-lab and shr-color. A future work would be to add support for colour blindness. As a side note, several people pointed me at the WCAG formulas to determine luminance and contrast ratio. These are probably good criteria to choose your color when designing a user interface. However, they are not enough to determine if displayed color will be readable. This means you can use them if you are a designer, but IMHO they are pretty weak for detecting and correcting colors you did not choose.
libxul.so. The very patterns there s not much to do about, except enduring them, or hacking ld.so and/or the toolchain. The latter is not necessarily easy, and won t benefit everyone until all linux distros use an improved glibc and/or toolchain. This could take years before any actual result would reach end users.
But with a little creativity, one can overcome these limitations and improve the situation today. Here is a summary of my recent hacks.
Backwards static initializers
As Taras showed in the past, static initializers are executed in reverse order. It turns out it is an unfortunate design choice in gcc, and it also turns out not to impact all ELF binary files.
As far as I know there are currently two different implementations of the static initializers call loop, one provided by gcc, and one provided by ld.so.
In the gcc case, the compiler creates a .ctors section, starting with 0xffffffff, ending with 0x00000000, and filled with pointers to the various static initializer functions, in ascending order. The compiler also injects an initializer function, called from .init, going through this .ctors section, starting from the end (__do_global_ctors_aux in crtend.o). A similar .dtors section is created for functions to run when the library is unloaded, and the pointers in it are called in ascending order. There is actually no importance in the order in which .ctors and .dtors are executed. All that matters is that they are executed in reverse order from each other, because that limits the risks of bad ordering. It is only unfortunate that .ctors was chosen to be the one backwards.
In the ld.so case, the compiler creates a .init_array section, filled with pointers to the various static initializer functions, in ascending order. It also stores the location and the size of this section in the PT_DYNAMIC ELF header. At runtime, ld.so itself reads this information and executes the static initializers in ascending orders. A similar .fini_array section is created for functions to run when the library in unloaded, and ld.so goes through it in descending order.
The .init_array section is newer, and for backwards compatibility reasons, is not used on systems that have been using the .ctors approach forever. On the other hand, some newer ABIs, such as arm EABI, uses the new facility, which means they are not victim of backwards static initialization. I however wonder if backwards compatibility is still needed, considering how long .init_array support has been around (more than 11 years, according to glibc git repository).
While we could obviously bug the gcc maintainers to revert their .ctors execution order, or ditch .ctors support on glibc systems, which means we wouldn t get any immediate global benefit, we can also just revert the .ctors section content. Please note the source code out there doesn t take care of reverting the .dtors section accordingly, because it is currently empty in libxul.so.
Relocations
As I mentioned in an earlier post, relocations are what make it possible to load libraries at arbitrary locations. Unfortunately, a great number of relocations means awful I/O patterns: ld.so reads and applies them one by one, and while the kernel reads ahead by 128 KB chunks, when your relocation section exceeds that amount by more than an order of magnitude, it means I/O goes back and forth a lot between the relocation section and where the relocations take place.
There are two classes of relocations: REL and RELA. In both cases, there are several types of relocations, some of which require an addend. The difference between both classes is in REL relocations, the addend is stored at the offset the relocation takes place, and in RELA relocations, the addend is stored in the relocation entry. It means that RELA relocations effectively waste space, as the addend ends up actually being stored twice: it is also stored at the offset the relocation takes place, like with REL relocations, though it could technically be nulled out, there ; in any case, the space is wasted.
REL relocations thus take 2 words of storage, and RELA relocations, 3. On x86, the ELF ABI only uses REL relocations, and words are 32 bits, making each relocation take 8 bytes ; on x86-64, the ELF ABI only uses RELA relocations, and words are 64 bits, thus making each relocation take 24 bytes, 3 times that of x86 relocations. On ARM, both may be used, but apparently the compiler and the linker only use REL relocations.
These words of storage are used to store 3 or 4 bits of informations:
r_offset: the offset at which the relocation takes placer_info: containing both the relocation type and a symbol reference for the relocation. On 32 bits systems, the symbol reference is stored on 24 bits, and the relocation type on 8 bits. On 64 bits systems, the symbol reference is stored on 32 bits, and the relocation type on 32 bits (which means at least 24 bits are never going to be used: there are currently no ABI using more than 256 relocation types).r_addend: The addend, only in RELA relocationslibxul.so (taken from the mozilla-central nightly from Nov, the 22nd):
| dynamic relocations | PLT relocations | |||
|---|---|---|---|---|
| Architecture | number | size (bytes) | number | size (bytes) |
| x86 | 231,836 | 1,854,688 | 3,772 | 30,176 |
| x86-64 | 235,893 | 5,661,432 | 3,773 | 90,528 |
| Architecture | libxul.so size |
relocations size | % |
|---|---|---|---|
| x86 | 21,869,684 | 1,884,864 | 8.61% |
| x86-64 | 29,629,040 | 5,751,984 | 19.41% |
libxul.so:
| x86 relocation type | number | x86-64 relocation type | number |
|---|---|---|---|
| dynamic relocations | |||
R_386_TLS_DTPMOD32 |
1 | R_X86_64_DTPMOD64 |
1 |
R_386_GLOB_DAT |
213 | R_X86_64_GLOB_DAT |
238 |
R_386_32 |
27,643 | R_X86_64_64 |
27,611 |
R_386_RELATIVE |
203,979 | R_X86_64_RELATIVE |
208,043 |
| PLT relocations | |||
R_386_JUMP_SLOT |
3,772 | R_X86_64_JUMP_SLOT |
3,773 |
R_*_GLOB_DAT, R_*_JUMP_SLOT, R_386_32, R_X86_64_64)R_*_RELATIVE, R_386_TLS_DTPMOD32, R_X86_64_TLS_DTPMOD64)libxul.so are from that category. At this point, this is how much waste we identified:
| description | num. entries | waste per entry (bytes) | total | % of relocation size |
|---|---|---|---|---|
| x86 | ||||
| Relocation without symbol ref. | 203,980 | 3 | 611,937 | 32.46% |
| x86-64 | ||||
| Duplicated addend | 239,666 | 8 | 1,917,328 | 33.33% |
| Relocation type encoded on 32 bits | 239,666 | 3 | 718,998 | 12.49% |
| Relocation without symbol ref. | 208,044 | 4 | 832,176 | 14.46% |
| Total | 3,468,502 | 60.30% | ||
r_offset on 64 bits systems, as libxul.so is far from being bigger than 4GB. Anyways, that means we have room for improvement here, and it means that the ELF format, especially on 64 bits systems with RELA relocations, really doesn t help with big programs or libraries with a lot of relocations. (For that matter, the mach-o format used on OS-X has some kind of similar issues ; I don t know for the DLL format)
Another interesting data point is looking at how relocations r_offset are following each other, once relocations are reordered (to avoid too much symbol resolution, they are actually grouped by symbol). It turns out 206,739 relocations r_offset are at 4 bytes from the previous one on x86 (i.e. strictly following it), and 210,364 at 8 bytes from the previous on x86-64. The main reason why this happens is that most relocations are happening in pointer tables, and libxul.so has lots of them:
.ctors and .dtors sections, which are relocated as well (but not .init_array and .fini_array sections).libxul.so has lots of them, that s not an understatement: there are 184,320 relocations due to vtables (function tables you get when using virtual methods in C++) on x86 and 184,098 on x86-64. That s respectively 78.23% and 76.81% of the total number of relocations. Interestingly, while most of these relocations are R_*_RELATIVE, 26,853 are R_386_32, and 26,829 are R_X86_64_64. Except for a very few, these non relative relocations are for the __cxa_pure_virtual symbol, which is a dummy function that does nothing, used for pure virtual methods, such as the following:
class Abstract
public:
virtual void pure_virtual() = 0;
;
As for the remaining relative relocations, there are a few pointer tables responsible for several thousand relocations, such as JSString::length2StringTable, gEntries, GkAtoms_info, Html5Atoms_info, kUnixCharsets, nsIDOMCSS2Properties_properties, etc.
Packing relocations
While they are not detrimental to most binaries, we saw that relocations can have a bad effect on startup I/O for big binaries. Reducing how much space they take would have a direct impact on these startup I/Os. One way to do so is obviously to reduce the number of relocations. But as we saw above, the vast majority are due to vtables. While reducing vtables would be a nice goal, it s a long way before this can have a significant impact on the relocations number. So another possible way is to try to avoid wasting so much space in relocations.
The main problem is that relocations are applied by ld.so, and that, as mentioned in the introduction, while we can hack ld.so to do what we want, it won t work everywhere before a long time. Moreover, it s difficult to test various implementations, and binary compatibility needs to be guaranteed once something is applied in the upstream libc.
The idea I started to test a few weeks ago, is to effectively apply relocations by hand instead of relying on ld.so doing it. Considering the first thing ld.so does with a library after applying relocations is to call its DT_INIT function, the idea was to replace the dynamic relocations we can with a new DT_INIT function we would inject that d apply those relocations, while storing them in a more efficient manner. The function would obviously need to call the original DT_INIT function once done. Some parts of the PT_DYNAMIC section also obviously need to be adjusted accordingly.
The first iteration I tested a few weeks ago helped validating the idea, but didn t change much of the binary: the dynamic relocation section still was taking all the space it took before, though its content was mostly empty (we ll see further below how efficient even the current dumb format is). Once the theory that an injected DT_INIT function could apply the relocations without breaking everything, I went on to implement a program that would actually strip the ELF binary. I won t get too much into the gory details, but it required PT_LOAD splitting, thus program headers growth, which means moving the following sections, then removing a huge part of the relocations, shrinking the relocations section, injecting our code and the packed relocations as sections, and moving the remaining sections after these new sections, to avoid empty space, but still respecting the proper offsets for both PT_LOAD and the code itself.
So far, I only took care of the R_*_RELATIVE relocations. Some but not all other relocations could be taken care of, too, but everything involving symbol resolution from other libraries would be really difficult to handle from the injected code. The relocations are currently stored with a quite dumb format:
r_offsetr_offset, we just strip it from RELA relocations ; the binary being far from 4GB big, 32 bits is enough on 64 bits systems too. We also saw that a lot of relocations were next to the following ones, so instead of storing r_offset for each one, storing some kind of range is more efficient. As I ve so far been focusing on getting something that actually works more than on getting something really efficient, I only tested this format, but the results are already nice:
| x86 | x86-64 | |
|---|---|---|
| before | ||
| dynamic relocations (bytes) | 1,854,688 | 5,661,432 |
libxul.so size |
21,869,684 | 29,629,040 |
| after | ||
| dynamic relocations (bytes) | 222,856 | 668,400 |
| injected code size | 129 | 84 |
| packed relative relocations (bytes) | 224,816 | 228,568 |
libxul.so size |
20,464,836 (-6.42%) | 24,865,520 (-16.07%) |
__cxa_pure_virtual relocations would help getting this even further down, and an even better storage format could be used, too. Gathering new startup coverage data should be interesting as well.
The code is available via mercurial. Please note the Makefile deeply sucks, and that the code is in the middle of its third refactoring. Anyways, once you get the code to compile, you just need to run test-x86 or test-x64 depending on your architecture, from the build directory, and give it the libxul.so file as an argument. It will create a libxul.so.new file that you can use to replace libxul.so. You may successfully use the tool on other libraries, but chances are you ll bump into an assert(), or in the worst case, that the resulting library ends up broken. The tool might work on PIE executables, but most probably not on other executables. If you wonder, Chrome is not PIE. It s not even relocatable (which means ASLR won t work with it) ; or at least the x86-64 binaries I just got aren t.
More possible ELF hacking
The code I wrote to pack relocations allows to do various tricks on ELF files, and it opens various opportunities, such as:
.bss. As I wrote on this blog a while ago, ld.so fills the last page from the .data section with zeroes, starting at the offset of the .bss section. Unfortunately, this means reading ahead at most 128KB of data nobody needs, and the corresponding disk seek. Inserting a section full of zeroes between .data and .bss would get rid of that, while minimally wasting space (less than 4KB in a 20MB+ binary).PT_DYNAMIC section. It is one of the first bunch of data to be read from programs and libraries, yet it is near the end of the binary..ctors/.dtors with .init_array/.fini_array (thus removing the corresponding relocations, though there s only around 300 of them).__cxa_pure_virtual relocations with relative relocations pointing to an injected dummy function (it could even just point to any ret code in any existing function).-Bsymbolic)ld --verbose). And it s not guaranteed to work (Taras told me he had a hard time failing to align the .bss section). And as far as I know, you can t use the same thing depending whether you use ld or gold (AIUI, gold doesn t support the whole ld linker script syntax).
Today was quite strange day for me - at the morning I felt quite bad so I took sick day to rest a bit. During afternoon I turned on the computer to see announcement that Novell agrees to be bought in $2.2b deal. As this is company where I work, it of course has attracted my attention.
Novell was bought by Attachmate, a company with one quarter of our employees, and over a third of our revenue, what sounds strange. And this is the first time I hear of this company...
The information is now very scarce (we as employees were not really given more information than is available publicly), so all what remains to people is to speculate. What does it mean for openSUSE? What is the "certain intellectual property" transferred to CPTN Holdings LLC (owned by Microsoft Corp.)? And some people just comment on current situation of Novell and some of it's products :-).
Filed under: Suse 1 comments Flattr this!
Next.