[committed] Fix incorrect res arg for wait_child_exit
Tom de Vries
tdevries@suse.de
Mon Mar 29 06:36:38 GMT 2021
Hi,
In dwz_files_1 we have:
...
file = files[i];
struct file_result *res = &resa[i];
if (nr_forks == max_forks)
{
int thisret = wait_child_exit (-1, pids, i, res);
...
The -1 pid argument to wait_child_exit means that any child status will be
returned, while the res argument passes the result array element for
the file we want to start processing, which is incorrect.
Fix this by passing the result array instead, and letting wait_child_exit
figure out which element to use.
Committed to trunk.
Thanks,
- Tom
Fix incorrect res arg for wait_child_exit
2021-03-29 Tom de Vries <tdevries@suse.de>
* dwz.c (wait_child_exit): Find appropriate element in result array.
(dwz_files_1): Use resa when using pid -1.
---
dwz.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/dwz.c b/dwz.c
index 0ba04c5..377e1be 100644
--- a/dwz.c
+++ b/dwz.c
@@ -16446,7 +16446,7 @@ decode_child_exit_status (int state, struct file_result *res)
/* Wait on child exit with PID, update PIDS and RES. */
static int
wait_child_exit (pid_t pid, pid_t *pids, int nr_pids,
- struct file_result *res)
+ struct file_result *resa)
{
int state;
pid_t got_pid = waitpid (pid, &state, 0);
@@ -16460,7 +16460,7 @@ wait_child_exit (pid_t pid, pid_t *pids, int nr_pids,
}
assert (i < nr_pids);
- return decode_child_exit_status (state, res);
+ return decode_child_exit_status (state, &resa[i]);
}
/* Wait on exit of chilren in PIDS, update RESA. */
@@ -16541,12 +16541,10 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink,
{
int i = workset[j];
int thisret;
- file = files[i];
- struct file_result *res = &resa[i];
if (nr_forks == max_forks)
{
- int thisret = wait_child_exit (-1, pids, i, res);
+ int thisret = wait_child_exit (-1, pids, i, resa);
if (thisret == 1)
ret = 1;
nr_forks--;
@@ -16556,6 +16554,8 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink,
assert (fork_res != -1);
if (fork_res == 0)
{
+ file = files[i];
+ struct file_result *res = &resa[i];
thisret = dwz_with_low_mem (file, NULL, res);
return encode_child_exit_status (thisret, res);
}
@@ -16644,13 +16644,10 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink,
for (j = 0; j < workset_size; j++)
{
int i = workset[j];
- file = files[i];
- struct file_result *res = &resa[i];
- multifile_mode = MULTIFILE_MODE_FI;
if (nr_forks == max_forks)
{
- int thisret = wait_child_exit (-1, pids, i, res);
+ int thisret = wait_child_exit (-1, pids, i, resa);
if (thisret == 1)
ret = 1;
nr_forks--;
@@ -16660,6 +16657,9 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink,
assert (fork_res != -1);
if (fork_res == 0)
{
+ file = files[i];
+ struct file_result *res = &resa[i];
+ multifile_mode = MULTIFILE_MODE_FI;
int thisret = dwz (file, NULL, res);
return encode_child_exit_status (thisret, res);
}
More information about the Dwz
mailing list