Merge lp:~xnox/libnih/fix-for-997359 into lp:libnih

Proposed by Dimitri John Ledkov
Status: Work in progress
Proposed branch: lp:~xnox/libnih/fix-for-997359
Merge into: lp:libnih
Diff against target: 134 lines (+27/-21)
3 files modified
ChangeLog (+6/-0)
nih/logging.c (+8/-8)
nih/tests/test_logging.c (+13/-13)
To merge this branch: bzr merge lp:~xnox/libnih/fix-for-997359
Reviewer Review Type Date Requested Status
Dimitri John Ledkov (community) Disapprove
Scott James Remnant Pending
Review via email: mp+140155@code.launchpad.net

Description of the change

Cherry pick from lp:ubuntu/libnih to fix the linked bug.

To post a comment you must log in.
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

libnih development has moved on to github.

review: Disapprove

Unmerged revisions

1055. By James Hunt

* nih/logging.c: Use our own __nih_abort_msg rather than the (e)glibc
  private symbol __abort_msg to avoid upgrade issues (LP: #997359).
* nih/tests/test_logging.c: Update tests for __nih_abort_msg.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2011-09-01 18:41:03 +0000
+++ ChangeLog 2012-12-17 09:58:49 +0000
@@ -1,3 +1,9 @@
12012-10-25 James Hunt <james.hunt@ubuntu.com>
2
3 * nih/logging.c: Use our own __nih_abort_msg rather than the
4 (e)glibc private symbol __abort_msg to avoid upgrade issues (LP: #997359).
5 * nih/tests/test_logging.c: Update tests for __nih_abort_msg.
6
12011-08-31 James Hunt <james.hunt@ubuntu.com>72011-08-31 James Hunt <james.hunt@ubuntu.com>
28
3 * nih-dbus-tool/tests/test_com.netsplit.Nih.Test_object.c9 * nih-dbus-tool/tests/test_com.netsplit.Nih.Test_object.c
410
=== modified file 'nih/logging.c'
--- nih/logging.c 2010-02-04 18:24:58 +0000
+++ nih/logging.c 2012-12-17 09:58:49 +0000
@@ -39,11 +39,11 @@
3939
4040
41/**41/**
42 * __abort_msg:42 * __nih_abort_msg:
43 *43 *
44 * A glibc variable that keeps the assertion message in the core dump.44 * A variable that keeps the assertion message in the core dump.
45 **/45 **/
46extern char *__abort_msg __attribute__ ((weak));46char *__nih_abort_msg;
4747
48/**48/**
49 * logger:49 * logger:
@@ -114,19 +114,19 @@
114 * nih_log_abort_message:114 * nih_log_abort_message:
115 * @message: message to be logged.115 * @message: message to be logged.
116 *116 *
117 * Save @message in the glibc __abort_msg variable so it can be retrieved117 * Save @message in the __nih_abort_msg variable so it can be retrieved
118 * by debuggers if we should crash at this point.118 * by debuggers if we should crash at this point.
119 **/119 **/
120static void120static void
121nih_log_abort_message (const char *message)121nih_log_abort_message (const char *message)
122{122{
123 if (! &__abort_msg)123 if (! &__nih_abort_msg)
124 return;124 return;
125125
126 if (__abort_msg)126 if (__nih_abort_msg)
127 nih_discard (__abort_msg);127 nih_discard (__nih_abort_msg);
128128
129 __abort_msg = NIH_MUST (nih_strdup (NULL, message));129 __nih_abort_msg = NIH_MUST (nih_strdup (NULL, message));
130}130}
131131
132/**132/**
133133
=== modified file 'nih/tests/test_logging.c'
--- nih/tests/test_logging.c 2010-02-04 18:24:58 +0000
+++ nih/tests/test_logging.c 2012-12-17 09:58:49 +0000
@@ -31,7 +31,7 @@
31#include <nih/main.h>31#include <nih/main.h>
3232
3333
34extern char *__abort_msg __attribute__ ((weak));34extern char *__nih_abort_msg;
3535
36static NihLogLevel last_priority = NIH_LOG_UNKNOWN;36static NihLogLevel last_priority = NIH_LOG_UNKNOWN;
37static char * last_message = NULL;37static char * last_message = NULL;
@@ -156,13 +156,13 @@
156 }156 }
157157
158158
159 /* Check that a fatal message is also stored in the glibc __abort_msg159 /* Check that a fatal message is also stored in the __nih_abort_msg
160 * variable.160 * variable.
161 */161 */
162 if (&__abort_msg) {162 if (&__nih_abort_msg) {
163 TEST_FEATURE ("with fatal message");163 TEST_FEATURE ("with fatal message");
164 TEST_ALLOC_FAIL {164 TEST_ALLOC_FAIL {
165 __abort_msg = NULL;165 __nih_abort_msg = NULL;
166 last_priority = NIH_LOG_UNKNOWN;166 last_priority = NIH_LOG_UNKNOWN;
167 last_message = NULL;167 last_message = NULL;
168168
@@ -174,16 +174,16 @@
174 TEST_EQ (last_priority, NIH_LOG_FATAL);174 TEST_EQ (last_priority, NIH_LOG_FATAL);
175 TEST_EQ_STR (last_message, "message with some 20 formatting");175 TEST_EQ_STR (last_message, "message with some 20 formatting");
176176
177 TEST_NE_P (__abort_msg, NULL);177 TEST_NE_P (__nih_abort_msg, NULL);
178 TEST_ALLOC_PARENT (__abort_msg, NULL);178 TEST_ALLOC_PARENT (__nih_abort_msg, NULL);
179 TEST_EQ_STR (__abort_msg, "message with some 20 formatting");179 TEST_EQ_STR (__nih_abort_msg, "message with some 20 formatting");
180180
181 free (last_message);181 free (last_message);
182 }182 }
183183
184184
185 /* Check that a fatal message can safely overwrite one already stored185 /* Check that a fatal message can safely overwrite one already stored
186 * in the glibc __abort_msg variable.186 * in the __nih_abort_msg variable.
187 */187 */
188 TEST_FEATURE ("with second fatal message");188 TEST_FEATURE ("with second fatal message");
189 TEST_ALLOC_FAIL {189 TEST_ALLOC_FAIL {
@@ -191,7 +191,7 @@
191 msg = nih_strdup (NULL, "test");191 msg = nih_strdup (NULL, "test");
192 }192 }
193193
194 __abort_msg = msg;194 __nih_abort_msg = msg;
195 TEST_FREE_TAG (msg);195 TEST_FREE_TAG (msg);
196196
197 last_priority = NIH_LOG_UNKNOWN;197 last_priority = NIH_LOG_UNKNOWN;
@@ -207,14 +207,14 @@
207207
208 TEST_FREE (msg);208 TEST_FREE (msg);
209209
210 TEST_NE_P (__abort_msg, NULL);210 TEST_NE_P (__nih_abort_msg, NULL);
211 TEST_ALLOC_PARENT (__abort_msg, NULL);211 TEST_ALLOC_PARENT (__nih_abort_msg, NULL);
212 TEST_EQ_STR (__abort_msg, "message with some 20 formatting");212 TEST_EQ_STR (__nih_abort_msg, "message with some 20 formatting");
213213
214 free (last_message);214 free (last_message);
215 }215 }
216 } else {216 } else {
217 printf ("SKIP: __abort_msg not available\n");217 printf ("SKIP: __nih_abort_msg not available\n");
218 }218 }
219219
220220

Subscribers

People subscribed via source and target branches