Skip to content

Commit 11cd37c

Browse files
committed
SWDEV-490256 - Fix uri_decode logic to handle Memory URI.
Uri decoder logic currently silently ignores processing of memory uri. This patch enables the existing logic to handle the processing of offset and size related to loaded code-object having memory URI. Change-Id: If03579cefb11d91f667410464dc89404df9270a3
1 parent dff8197 commit 11cd37c

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed

rocclr/device/devsanitizer.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ void handleSanitizerService(Payload* packt_payload, uint64_t activemask,
9696
int64_t loadAddrAdjust = 0;
9797
auto uri_fd = amd::Os::FDescInit();
9898
if (uri_locator) {
99-
device::UriLocator::UriInfo fileuri_info = uri_locator->lookUpUri(callstack[0]);
100-
std::tie(offset, size) = uri_locator->decodeUriAndGetFd(fileuri_info, &uri_fd);
101-
loadAddrAdjust = fileuri_info.loadAddressDiff;
99+
device::UriLocator::UriInfo uri_info = uri_locator->lookUpUri(callstack[0]);
100+
std::tie(offset, size) = uri_locator->decodeUriAndGetFd(uri_info, &uri_fd);
101+
loadAddrAdjust = uri_info.loadAddressDiff;
102102
}
103103

104104
#if defined(__linux__)

rocclr/device/rocm/rocurilocator.cpp

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ std::pair<uint64_t, uint64_t> UriLocator::decodeUriAndGetFd(UriInfo& uri,
106106
if (uri.uriPath.size() == 0)
107107
return {0,0};
108108
auto pos = uri.uriPath.find("//");
109-
if (pos == std::string::npos || uri.uriPath.substr(0, pos) != "file:") {
109+
if (pos == std::string::npos) {
110110
uri.uriPath="";
111111
return {0,0};
112112
}
@@ -126,32 +126,31 @@ std::pair<uint64_t, uint64_t> UriLocator::decodeUriAndGetFd(UriInfo& uri,
126126
else {
127127
rspos = uri.uriPath.size()-1;
128128
}
129-
pos += 2;
130-
//decode filepath
131-
for (auto i=pos; i<= rspos;) {
132-
cur = uri.uriPath[i];
133-
if (isalnum(cur) || cur == '/' || cur == '-' ||
134-
cur == '_' || cur == '.' || cur == '~') {
135-
ss << cur;
136-
i++;
137-
}
138-
else {
139-
//characters prefix with '%' char
140-
char tbits = uri.uriPath[i+1], lbits = uri.uriPath[i+2];
141-
uint8_t t = (tbits < 58) ? ( tbits - 48) : ((tbits - 65) + 10);
142-
uint8_t l = (lbits < 58) ? ( lbits - 48) : ((lbits - 65) + 10);
143-
ss << (char)(((0b00000000 | t)<<4) | l);
144-
i += 3;
129+
if (uri.uriPath.substr(0, pos) == "file:") {
130+
pos += 2;
131+
// decode filepath
132+
for (auto i = pos; i <= rspos;) {
133+
cur = uri.uriPath[i];
134+
if (isalnum(cur) || cur == '/' || cur == '-' || cur == '_' || cur == '.' || cur == '~') {
135+
ss << cur;
136+
i++;
137+
} else {
138+
// characters prefix with '%' char
139+
char tbits = uri.uriPath[i + 1], lbits = uri.uriPath[i + 2];
140+
uint8_t t = (tbits < 58) ? (tbits - 48) : ((tbits - 65) + 10);
141+
uint8_t l = (lbits < 58) ? (lbits - 48) : ((lbits - 65) + 10);
142+
ss << (char)(((0b00000000 | t) << 4) | l);
143+
i += 3;
144+
}
145145
}
146+
uri.uriPath = ss.str();
147+
size_t fd_size;
148+
(void)amd::Os::GetFileHandle(uri.uriPath.c_str(), uri_fd, &fd_size);
149+
// As per URI locator syntax, range_specifier is optional
150+
// if range_specifier is absent return total size of the file
151+
// and set offset to begin at 0.
152+
if (size == 0) size = fd_size;
146153
}
147-
uri.uriPath = ss.str();
148-
size_t fd_size;
149-
(void) amd::Os::GetFileHandle(uri.uriPath.c_str(), uri_fd, &fd_size);
150-
// As per URI locator syntax, range_specifier is optional
151-
// if range_specifier is absent return total size of the file
152-
// and set offset to begin at 0.
153-
if (size == 0)
154-
size = fd_size;
155154
return {offset, size};
156155
}
157156

0 commit comments

Comments
 (0)