Commit 535896e5 authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari
Browse files

rts: Fix parsing of profiler selectors

69822f0c broke this as it held on to a
reference into the `arg` string, which is later freed. Humbug.

Test Plan: Try using filtering

Reviewers: austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11810
parent 6b6bebaf
......@@ -1566,7 +1566,7 @@ static rtsBool read_heap_profiling_flag(const char *arg_in)
// However, for sanity we want to guarantee const-correctness and parsing
// really ought to be an immutable operation. To avoid rewriting the parser
// we just operate on a temporary copy of the argument.
char *arg = strdup(arg_in);
const char *arg = strdup(arg_in);
rtsBool error = rtsFalse;
switch (arg[2]) {
case '\0':
......@@ -1597,35 +1597,37 @@ static rtsBool read_heap_profiling_flag(const char *arg_in)
if (!right)
right = arg + strlen(arg);
*right = '\0';
char *selector = strndup(left, right - left);
switch (arg[2]) {
case 'c': // cost centre label select
RtsFlags.ProfFlags.ccSelector = left;
RtsFlags.ProfFlags.ccSelector = selector;
case 'C':
RtsFlags.ProfFlags.ccsSelector = left;
RtsFlags.ProfFlags.ccsSelector = selector;
case 'M':
case 'm': // cost centre module select
RtsFlags.ProfFlags.modSelector = left;
RtsFlags.ProfFlags.modSelector = selector;
case 'D':
case 'd': // closure descr select
RtsFlags.ProfFlags.descrSelector = left;
RtsFlags.ProfFlags.descrSelector = selector;
case 'Y':
case 'y': // closure type select
RtsFlags.ProfFlags.typeSelector = left;
RtsFlags.ProfFlags.typeSelector = selector;
case 'R':
case 'r': // retainer select
RtsFlags.ProfFlags.retainerSelector = left;
RtsFlags.ProfFlags.retainerSelector = selector;
case 'B':
case 'b': // biography select
RtsFlags.ProfFlags.bioSelector = left;
RtsFlags.ProfFlags.bioSelector = selector;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment