Skip to content

Commit

Permalink
Fix segfault.
Browse files Browse the repository at this point in the history
Make xla::MemorySpaceDescription back its own pointers. Also, add missing
reserve() so memory_description_pointers don't go uninitialized.

PiperOrigin-RevId: 708047563
  • Loading branch information
matthiaskramm authored and Google-ML-Automation committed Dec 19, 2024
1 parent ca3ddd2 commit 7fe54d9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions xla/pjrt/pjrt_c_api_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,7 @@ PjRtCApiDeviceDescription::memory_spaces() const {
extension->PJRT_DeviceDescription_MemoryDescriptions(&mem_desc_args),
c_api_);

memory_space_descriptions_.reserve(mem_desc_args.num_memory_descriptions);
for (int i = 0; i < mem_desc_args.num_memory_descriptions; i++) {
PJRT_MemoryDescription_Kind_Args kind_args;
kind_args.struct_size = PJRT_MemoryDescription_Kind_Args_STRUCT_SIZE,
Expand Down
4 changes: 2 additions & 2 deletions xla/pjrt/pjrt_device_description.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ class PjRtMemorySpaceDescription {

// A platform-dependent string that uniquely identifies the kind of the
// memory space.
absl::string_view kind() const { return kind_; }
absl::string_view kind() const { return absl::string_view(kind_); }

// An ID uniquely identifies the kind of the memory space among those attached
// to the same `PjRtClient`. The IDs assigned to a kind is implementation
// specific.
int kind_id() const { return kind_id_; }

private:
absl::string_view kind_;
std::string kind_;
int kind_id_;
};

Expand Down

0 comments on commit 7fe54d9

Please sign in to comment.