Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#10005 closed Patch - Bug Fix (fixed)

If $LANG isn't set, mythbackend segfaults after v0.25pre-3161-g0fd3987

Reported by: Bill Meek <keemllib@…> Owned by: beirdo
Priority: minor Milestone: 0.25
Component: MythTV - General Version: Master Head
Severity: medium Keywords:
Cc: Ticket locked: no


Running on Ubuntu 10.04.3 LTS, starting mythbackend from upstart, LANG is not set. 0fd3987 adds a check for it, but segfaults if it is not set.

/var/log/mythtv/mythbackend.*.PID.log size is 0.

The following patch eliminates the segfault and allows the error message to print.

diff --git a/mythtv/libs/libmythbase/mythcorecontext.cpp b/mythtv/libs/libmythbase/mythcorecontext.cpp
index 960ccbb..f3ddfbc 100644
--- a/mythtv/libs/libmythbase/mythcorecontext.cpp
+++ b/mythtv/libs/libmythbase/mythcorecontext.cpp
@@ -194,7 +194,7 @@ bool MythCoreContext::Init(void)
 #ifndef _WIN32
     char *lang = getenv("LANG");
-    if (!strcmp(lang, "C") || (strlen(lang) == 0))
+    if (lang == 0 || !strcmp(lang, "C") || (strlen(lang) == 0))
                 "This application expects to be running a UTF locale, and "
                 "many features may behave improperly with your current LANG "

Attachments (2)

version.txt (753 bytes) - added by Bill Meek <keemllib@…> 10 years ago.
gdb.log (4.4 KB) - added by Bill Meek <keemllib@…> 10 years ago.

Download all attachments as: .zip

Change History (6)

Changed 10 years ago by Bill Meek <keemllib@…>

Attachment: version.txt added


Changed 10 years ago by Bill Meek <keemllib@…>

Attachment: gdb.log added


comment:1 Changed 10 years ago by beirdo

Owner: set to beirdo
Status: newassigned

comment:2 Changed 10 years ago by Github

Milestone: unknown0.25
Resolution: fixed
Status: assignedclosed

Deal with a missing LANG env variable on startup

Although this really should be fixed in the startup script, we should not be crashing if someone doesn't set LANG.

Fixes #10005

Signed-off-by: Gavin Hurlbut <ghurlbut@…>

Branch: master Changeset: da6be99c9d9770424fe82056f3d8e0c9ad7af708

comment:3 Changed 10 years ago by beirdo

Bill: you really need to fix your startup script to set LANG to a UTF-8 language if you want the MythTV setup to work correctly. Thanks for the crash-prevention, though.

comment:4 in reply to:  3 Changed 10 years ago by Bill Meek <keemllib@…>

Replying to beirdo:

Gavin, thanks for the quick response! I tested my patch with and without the upstart script fix. Tomorrow I'll make an addition to: reflecting the new check.

Note: See TracTickets for help on using tickets.