[augeas-devel] [Augeas] #123: unref of static value causes segfault
Augeas
trac at fedorahosted.org
Tue Jun 22 20:35:53 UTC 2010
#123: unref of static value causes segfault
-------------------------+--------------------------------------------------
Reporter: fgiraldeau | Owner: lutter
Type: defect | Status: new
Priority: minor | Milestone: next
Component: Augeas | Version: 0.7.0
Resolution: | Keywords:
-------------------------+--------------------------------------------------
Comment (by fgiraldeau):
Function exn_error creates a static const value:
{{{
struct value *exn_error(void) {
static const struct exn exn = {
.info = NULL, .seen = 1, .error = 1,
.message = (char *) "Error during evaluation",
.nlines = 0, .lines = NULL };
static const struct value value = {
.ref = REF_MAX, /* Protect against being freed */
.info = NULL, .tag = V_EXN,
{ .exn = (struct exn *) &exn } };
return (struct value *) &value;
}
}}}
And macro unref tries to always assign 0 to value->info
{{{
#define unref(s, t) \
do { \
if ((s) != NULL && (s)->ref != REF_MAX) { \
assert((s)->ref > 0); \
if (--(s)->ref == 0) { \
/*memset(s, 255, sizeof(*s));*/ \
free_##t(s); \
} \
} \
(s) = NULL; \
} while(0)
}}}
Could we assign the value only if it's not yet 0?
--
Ticket URL: <https://fedorahosted.org/augeas/ticket/123#comment:6>
Augeas <http://augeas.net/>
a configuration API
More information about the augeas-devel
mailing list