should not segfault on profile errors

Bug #981053 reported by Thomas Bushnell BSG
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
dconf
Fix Released
Medium
d-conf (Ubuntu)
Triaged
High
Unassigned
Precise
Won't Fix
High
Unassigned

Bug Description

I'm trying to create a system dconf configuration, and it's causing lightdm to crash.

In /etc/dconf/profile/user I have
user-db:user
system-db:local
system-db:site

Then I create empty files /etc/dconf/db/local and /etc/dconf/db/site.

On start, lightdm crashes, and x-0-greeter.log has this:

/usr/lib/lightdm/lightdm-greeter-session: line 35: 5782 Trace/breakpoint trap (core dumped) exec $@

If I remove the system configs, it works fine.

If I don't have the empty files in /etc/dconf/db, I get a warning that the local one can't be found, and then the crash (I don't get a warning about the site one).

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. Please try to obtain a backtrace following the instructions at http://wiki.ubuntu.com/DebuggingProgramCrash and upload the backtrace (as an attachment) to the bug report. This will greatly help us in tracking down your problem.

Changed in lightdm:
importance: Undecided → High
status: New → Incomplete
Revision history for this message
Thomas Bushnell BSG (tb-becket) wrote :

Not surprisingly, the crash is in libdconfsettings inside unity-greeter. Backtrace on its way shortly.

Revision history for this message
Thomas Bushnell BSG (tb-becket) wrote :

The trash is in the pointer dereference in gvdb_table_is_valid in gvdb/gvdb-reader.c.

Since the database file is zero-length, I assume that something hasn't noticed and we get SEGV.

When the files are gone, we get an assertion failure.

These are both bad failure modes, but not critical bugs. What is clear then is that it is mandatory that /etc/dconf/db/foo exist whenever you have system-db:foo, and it must exist as a real gvdb database. That's annoying, because we only want to use the foo.d directory to hold a textual key specification. However, it's something we can work around, I think.

So please leave this open as a bug that the program should not crash when the database files are incorrect, but (assuming my understanding above is correct) there is no urgency for us.

Now we have a different problem, however. There is no way I can see to create a proper empty gvdb database. The dconf program doesn't do it, and dconf-settings certainly doesn't.

This is a rather serious gap.

Revision history for this message
Thomas Bushnell BSG (tb-becket) wrote :

Hrm. I see, for example, various cases where code in the wild creates empty dconf databases by just touching the filename.

So I take it back: I believe that a zero-length file is supposed to work, and the aforementioned crashing pointer dereference is the actual bug.

Revision history for this message
Thomas Bushnell, BSG (tbushnell) wrote :
Revision history for this message
Thomas Bushnell BSG (tb-becket) wrote :

I believe I see the bug. I'm not in a position to conveniently test it, and I'm terribly confident of the data model.

But in a struct _GvdbTable, there is a pointer "const gchar *data". In gvdb_table_new, this is initialized to the contents of the file passed in. Then gvdb_table_is_valid is checked, which does this:
  return !!*table->data;

Note carefully. What that does is check whether the first byte of the table's contents is zero or not. IOW, there's an extra dereference. The point is actually, presumably, to check whether the data pointer is NULL, not whether the first byte is zero. For an empty file, of course, the first byte dereference fails entirely.

Revision history for this message
Thomas Bushnell BSG (tb-becket) wrote :

Er, I meant to say, "I'm not terribly confident of the data model".

Revision history for this message
Allison Karlitskaya (desrt) wrote :

This is upstream here: https://bugzilla.gnome.org/show_bug.cgi?id=662141

This only happens in the event of a user (read: administrator) error. Those errors are somewhat easy to make, though, and the result is more or less an entirely unusable system. The intention is to ignore these errors and enter a degraded state with lots of console output.

I will get to it in the 3.6 cycle.

Revision history for this message
Sebastien Bacher (seb128) wrote :

Ryan says the segfault is https://bugzilla.gnome.org/show_bug.cgi?id=662141 and he plans to improve tolerance to such errors next cycle, do you hit that bug in some production mode or while hacking around to define profiles for your config?

affects: lightdm → dconf
Changed in d-conf (Ubuntu):
importance: Undecided → High
status: New → Triaged
Changed in dconf:
importance: High → Unknown
status: Incomplete → Unknown
Revision history for this message
Thomas Bushnell BSG (tb-becket) wrote :

Sorry for the churn here. I'm not actually concerned about the bug in https://bugzilla.gnome.org/show_bug.cgi?id=662141. I agree that's user error, and there's nothing particularly crucial about improving the error reporting here.

The bug at this point is that when the file does exist, and is zero-length, you get a crash in gvdb_table_is_valid.

Revision history for this message
Thomas Bushnell BSG (tb-becket) wrote :

Also, on Ubuntu, there is no system table at all by default, so a failure to open one that's configured probably doesn't degrade the system much. ;)

Revision history for this message
Thomas Bushnell BSG (tb-becket) wrote :

When we crash, table->data is in fact null.

I presume this is the expected behavior of g_mapped_file_get_contents for an empty file.

Fixing the erroneous extra * will turn this into a check whether table->data is null. But that's still going to have a bug.

If it returns zero, then dconf_engine_refresh_system will deconfigure that table, and that's wrong, because we want to use the .d directory for a textual definition.

Changed in dconf:
importance: Unknown → Medium
status: Unknown → New
Revision history for this message
Thomas Bushnell BSG (tb-becket) wrote :

I submit that the importance of this bug is High. It completely prevents creating a system configuration as far as I can tell.

There is no way to create a non-zero binary database. And zero-length binary databases are broken. (And the obvious fix also prevents loading of the textual ones in .d.)

Revision history for this message
Thomas Bushnell BSG (tb-becket) wrote :

Please remove the reference to gnome-bugs #662141. This is NOT that bug.

Changed in dconf:
importance: Medium → Undecided
Changed in d-conf (Ubuntu):
assignee: nobody → Ryan Lortie (desrt)
summary: - Creating system dconf configuration crashes lightdm
+ Creating system dconf configuration crashes Unity greeter
Revision history for this message
Allison Karlitskaya (desrt) wrote : Re: Creating system dconf configuration crashes Unity greeter

This really is a case of user error.

Why are you creating empty files in the place where dconf databases are supposed to be? Of course dconf would consider those to be corrupt. I agree that we should deal more gracefully with that case, but it is your mistake...

Please follow the instructions here for creating those files: https://live.gnome.org/dconf/SystemAdministrators

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thomas, why did you wrote "There is no way to create a non-zero binary database."? How did you try to create it?

the "Key File Directories" section of the wiki Ryan pointed should cover that, did you try to create a "/etc/dconf/db/local.d/something", what did you put it in? Did you run "sudo dconf update" then? Do you get a file /etc/dconf/db/local in result?

Revision history for this message
Thomas Bushnell, BSG (tbushnell) wrote : Re: [Bug 981053] Re: Creating system dconf configuration crashes Unity greeter

I'm frustrated that we have no time for delay and this information is in
the bug. When I create an empty .d directory and no file, I get told that
it cannot open the DB and an abort.
On Apr 16, 2012 7:25 AM, "Sebastien Bacher" <email address hidden> wrote:

> Thomas, why did you wrote "There is no way to create a non-zero binary
> database."? How did you try to create it?
>
> the "Key File Directories" section of the wiki Ryan pointed should cover
> that, did you try to create a "/etc/dconf/db/local.d/something", what
> did you put it in? Did you run "sudo dconf update" then? Do you get a
> file /etc/dconf/db/local in result?
>
> --
> You received this bug notification because you are a member of Goobuntu
> Team, which is subscribed to the bug report.
> https://bugs.launchpad.net/bugs/981053
>
> Title:
> Creating system dconf configuration crashes Unity greeter
>
> Status in A simple key-based configuration system:
> New
> Status in “d-conf” package in Ubuntu:
> Triaged
> Status in “d-conf” source package in Precise:
> Triaged
>
> Bug description:
> I'm trying to create a system dconf configuration, and it's causing
> lightdm to crash.
>
> In /etc/dconf/profile/user I have
> user-db:user
> system-db:local
> system-db:site
>
> Then I create empty files /etc/dconf/db/local and /etc/dconf/db/site.
>
> On start, lightdm crashes, and x-0-greeter.log has this:
>
> /usr/lib/lightdm/lightdm-greeter-session: line 35: 5782
> Trace/breakpoint trap (core dumped) exec $@
>
> If I remove the system configs, it works fine.
>
> If I don't have the empty files in /etc/dconf/db, I get a warning that
> the local one can't be found, and then the crash (I don't get a
> warning about the site one).
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/dconf/+bug/981053/+subscriptions
>

Revision history for this message
Thomas Bushnell, BSG (tbushnell) wrote :

I have tried update but I do not recall in what order. I could find no
documentation for it and I do not recall seeing it mentioned on the
sysadmin's guide page mentioned.
On Apr 16, 2012 7:31 AM, "Thomas Bushnell, BSG" <email address hidden>
wrote:

> I'm frustrated that we have no time for delay and this information is in
> the bug. When I create an empty .d directory and no file, I get told that
> it cannot open the DB and an abort.
> On Apr 16, 2012 7:25 AM, "Sebastien Bacher" <email address hidden> wrote:
>
>> Thomas, why did you wrote "There is no way to create a non-zero binary
>> database."? How did you try to create it?
>>
>> the "Key File Directories" section of the wiki Ryan pointed should cover
>> that, did you try to create a "/etc/dconf/db/local.d/something", what
>> did you put it in? Did you run "sudo dconf update" then? Do you get a
>> file /etc/dconf/db/local in result?
>>
>> --
>> You received this bug notification because you are a member of Goobuntu
>> Team, which is subscribed to the bug report.
>> https://bugs.launchpad.net/bugs/981053
>>
>> Title:
>> Creating system dconf configuration crashes Unity greeter
>>
>> Status in A simple key-based configuration system:
>> New
>> Status in “d-conf” package in Ubuntu:
>> Triaged
>> Status in “d-conf” source package in Precise:
>> Triaged
>>
>> Bug description:
>> I'm trying to create a system dconf configuration, and it's causing
>> lightdm to crash.
>>
>> In /etc/dconf/profile/user I have
>> user-db:user
>> system-db:local
>> system-db:site
>>
>> Then I create empty files /etc/dconf/db/local and /etc/dconf/db/site.
>>
>> On start, lightdm crashes, and x-0-greeter.log has this:
>>
>> /usr/lib/lightdm/lightdm-greeter-session: line 35: 5782
>> Trace/breakpoint trap (core dumped) exec $@
>>
>> If I remove the system configs, it works fine.
>>
>> If I don't have the empty files in /etc/dconf/db, I get a warning that
>> the local one can't be found, and then the crash (I don't get a
>> warning about the site one).
>>
>> To manage notifications about this bug go to:
>> https://bugs.launchpad.net/dconf/+bug/981053/+subscriptions
>>
>

Revision history for this message
Thomas Bushnell, BSG (tbushnell) wrote :

Note that I need to be able to have an empty DB so that I can have a site
one I create and an empty one for the machine owner, as in the suggested
config.
On Apr 16, 2012 7:33 AM, "Thomas Bushnell, BSG" <email address hidden>
wrote:

> I have tried update but I do not recall in what order. I could find no
> documentation for it and I do not recall seeing it mentioned on the
> sysadmin's guide page mentioned.
> On Apr 16, 2012 7:31 AM, "Thomas Bushnell, BSG" <email address hidden>
> wrote:
>
>> I'm frustrated that we have no time for delay and this information is in
>> the bug. When I create an empty .d directory and no file, I get told that
>> it cannot open the DB and an abort.
>> On Apr 16, 2012 7:25 AM, "Sebastien Bacher" <email address hidden> wrote:
>>
>>> Thomas, why did you wrote "There is no way to create a non-zero binary
>>> database."? How did you try to create it?
>>>
>>> the "Key File Directories" section of the wiki Ryan pointed should cover
>>> that, did you try to create a "/etc/dconf/db/local.d/something", what
>>> did you put it in? Did you run "sudo dconf update" then? Do you get a
>>> file /etc/dconf/db/local in result?
>>>
>>> --
>>> You received this bug notification because you are a member of Goobuntu
>>> Team, which is subscribed to the bug report.
>>> https://bugs.launchpad.net/bugs/981053
>>>
>>> Title:
>>> Creating system dconf configuration crashes Unity greeter
>>>
>>> Status in A simple key-based configuration system:
>>> New
>>> Status in “d-conf” package in Ubuntu:
>>> Triaged
>>> Status in “d-conf” source package in Precise:
>>> Triaged
>>>
>>> Bug description:
>>> I'm trying to create a system dconf configuration, and it's causing
>>> lightdm to crash.
>>>
>>> In /etc/dconf/profile/user I have
>>> user-db:user
>>> system-db:local
>>> system-db:site
>>>
>>> Then I create empty files /etc/dconf/db/local and /etc/dconf/db/site.
>>>
>>> On start, lightdm crashes, and x-0-greeter.log has this:
>>>
>>> /usr/lib/lightdm/lightdm-greeter-session: line 35: 5782
>>> Trace/breakpoint trap (core dumped) exec $@
>>>
>>> If I remove the system configs, it works fine.
>>>
>>> If I don't have the empty files in /etc/dconf/db, I get a warning that
>>> the local one can't be found, and then the crash (I don't get a
>>> warning about the site one).
>>>
>>> To manage notifications about this bug go to:
>>> https://bugs.launchpad.net/dconf/+bug/981053/+subscriptions
>>>
>>

Revision history for this message
Thomas Bushnell BSG (tb-becket) wrote : Re: Creating system dconf configuration crashes Unity greeter

Ok, thank you very much (sorry for my impatience in the hastily written messages above while I was logging in to vpn).

If I create an empty .d directory, and run "dconf update" it creates 61-byte database files and all is ok.

So this bug is similar to the other one mentioned, in that it is a real bug (there should be an error message and not SIGSEGV for an improper database file), but it is not urgent and can wait just like the other for release. I notice that if the file is corrupted, there is all kinds of logic to detect this, and I'd suggest something similar to detect databases in which the initial header information can't be read should produce a warning of some kind and not a crash--much confusion would have been eliminated with that.

I'd also strongly urge either writing a manpage for the "dconf" tool, or else some real in-tool documentation via the "help" command. "dconf help update" says only "update the system dconf databases", but if you don't already know what it does, this doesn't explain it. Perhaps "update system database files from information in key file (.d) directories" or something like that at least.

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks Thomas, good that you got something working, updating the documentation would be nice indeed. I'm setting back the bug to the state it was in friday then pointing to https://bugzilla.gnome.org/show_bug.cgi?id=662141, that's not a precise blocker but something we should really look at improving next cycle (then maybe backport some of the improvements to the lts)

Changed in d-conf (Ubuntu Precise):
assignee: Ryan Lortie (desrt) → nobody
Changed in dconf:
importance: Undecided → Unknown
status: New → Unknown
summary: - Creating system dconf configuration crashes Unity greeter
+ should not segfault on profile errors
Changed in dconf:
importance: Unknown → Medium
status: Unknown → Fix Released
Revision history for this message
Steve Langasek (vorlon) wrote :

The Precise Pangolin has reached end of life, so this bug will not be fixed for that release

Changed in d-conf (Ubuntu Precise):
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.