-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
STACK: Change PATH_MAX stack allocation to heap #10127
STACK: Change PATH_MAX stack allocation to heap #10127
Conversation
8cb5ec5
to
2149869
Compare
bbc428e
to
92fdb9a
Compare
92fdb9a
to
4920c1e
Compare
66bbe34
to
27e63b9
Compare
src/tools/vfs/vfs_main.c
Outdated
} | ||
|
||
/* Remove mount point directory */ | ||
vfs_log("removing directory '%s'", mountpoint); | ||
ret = rmdir(mountpoint); | ||
if (ret < 0) { | ||
vfs_error("failed to remove directory '%s': %m", mountpoint); | ||
return ret; | ||
goto out_free_mountpoint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why need goto?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed it, thanks, done
@@ -433,10 +433,10 @@ void ucs_memtrack_init() | |||
return; | |||
} | |||
|
|||
ucs_memtrack_vfs_init(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that change related to this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I changed allocation at VFS to heap and it revealed this issue - an invalid count in the memtrack (tests were failing)
src/ucs/vfs/sock/vfs_sock.c
Outdated
ret = mkdir(dirname(sock_path_dir), S_IRWXU); | ||
if ((ret < 0) && (errno != EEXIST)) { | ||
ucs_log(log_level, "failed to create directory '%s': %m", | ||
sock_path_dir); | ||
return -errno; | ||
ret = -errno; | ||
goto out_free_sock_path_dir; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why need goto?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed it, thanks, done
5ec4d39
to
9f41e2d
Compare
8510c36
to
54cbfe1
Compare
54cbfe1
to
3b439c3
Compare
3b439c3
to
5f64c2c
Compare
src/ucs/config/parser.c
Outdated
status = ucs_string_alloc_path_buffer(&path, "path"); | ||
if (status != UCS_OK) { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- this can be moved inside the "if" block in lines 1780..1782 (along with ucs_free)?
- there are multiple places where ucs_string_alloc_path_buffer is used along with "strncpy" + "dirname", can we unite them to a single function that allocates a dirname?
char *ucs_string_get_dirname(const char *path)
that returns an allocated directory path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
fd_p); | ||
|
||
ucs_free(file_path); | ||
out: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: space line before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/ucs/sys/topo/base/topo.c
Outdated
@@ -445,6 +445,7 @@ ucs_topo_get_distance_sysfs(ucs_sys_device_t device1, | |||
} | |||
|
|||
/* Report best perf for common PCI bridge or sysfs parsing error */ | |||
status = ucs_topo_get_distance_default(device1, device2, distance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now can we remove line 408 and goto here (restore distance_default label)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restored it, please check now
5e1cce5
to
962125b
Compare
553acc0
to
643c6e6
Compare
643c6e6
to
f04244e
Compare
cacaf3f
to
e161c38
Compare
What?
This PR changes all stack allocations of char arrays sized
PATH_MAX
to heap allocations.Why?
Customers with limited stack sizes have recently experienced stack overflow issues when running UCX. Moving these allocations to the heap prevents such overflows.
How?
Heap allocations replace stack allocations for char arrays of size
PATH_MAX
.