Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/biter/biterc.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ static int init_locks(biterc_session_t *session)
{
shminfo_t *shm = session->shm;
biter_header_t *header = &shm->shared_header->biter;
session->pipe_lock.lock = header->locks + 0;
session->pipe_lock.held_by = header->locks + 1;
session->queue_lock.lock = header->locks + 2;
session->queue_lock.held_by = header->locks + 3;
session->write_lock.lock = header->locks + 4;
session->write_lock.held_by = header->locks + 5;
session->pipe_lock.lock = header->lock + 0;
session->pipe_lock.held_by = header->held_by + 0;
session->queue_lock.lock = header->lock + 1;
session->queue_lock.held_by = header->held_by + 1;
session->write_lock.lock = header->lock + 2;
session->write_lock.held_by = header->held_by + 2;
return init_heap_lock(shm);
}

Expand Down
14 changes: 7 additions & 7 deletions src/biter/biterd.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ typedef struct biterd_session {
int s2c_fd;
char *c2s_path;
char *s2c_path;
int num_clients;
int clients_accepted;
uint32_t num_clients;
uint32_t clients_accepted;
void *proc_messages;
msg_header_t polled_data;
int has_polled_data;
Expand All @@ -55,7 +55,7 @@ typedef struct biterd_session {
} biterd_session_t;

static biterd_session_t sessions[BITER_MAX_SESSIONS];
static int max_session = 0;
static uint32_t max_session = 0;

extern void init_queue(int num_procs, void *session);

Expand Down Expand Up @@ -117,7 +117,7 @@ int biterd_newsession(const char *tmpdir, int cn_id)
char *c2s_path = NULL, *s2c_path = NULL;
int result, c2s_fd = -1, s2c_fd = -1;
int path_len = strlen(tmpdir) + 32;
int session_id, i, unique_number, num_clients;
uint32_t session_id, i, unique_number, num_clients;

assert(sizeof(int) == sizeof(uint32_t)); //Fix FD_* macros if this fails on new platform

Expand Down Expand Up @@ -393,7 +393,7 @@ int biterd_has_data_avail(int session_id, fd_set *readset)
int client_id;
int fd = sessions[session_id].c2s_fd;
int aux_fd = get_aux_fd();
int i, orig;
uint32_t i, orig;

session = sessions + session_id;

Expand Down Expand Up @@ -422,8 +422,8 @@ int biterd_has_data_avail(int session_id, fd_set *readset)

int biterd_get_session_proc_w_aux_data(int *session_result, int *proc_result)
{
static int last_session = 0;
int cur_session, start_session, j;
static uint32_t last_session = 0;
uint32_t cur_session, start_session, j;
biterd_session_t *session;
cur_session = start_session = last_session;

Expand Down
3 changes: 3 additions & 0 deletions src/biter/client_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ int init_message(int num_procs, void *header_ptr, void *session)

void get_message(int for_proc, void **msg_data, size_t *msg_size, size_t *bytes_read, void *session)
{
(void)session;
message_t *msg;
sheep_ptr_t *msgp = proc_messages + for_proc;
assert(!IS_SHEEP_NULL(msgp));
Expand All @@ -103,6 +104,7 @@ void get_message(int for_proc, void **msg_data, size_t *msg_size, size_t *bytes_

int has_message(int for_proc, void *session)
{
(void)session;
sheep_ptr_t *msgp = proc_messages + for_proc;
return !IS_SHEEP_NULL(msgp);
}
Expand Down Expand Up @@ -209,6 +211,7 @@ int get_message_space(size_t msg_size, unsigned char **msg_space, void **header_

void update_bytes_read(int for_proc, size_t newval, void *session)
{
(void)session;
message_t *msg;
sheep_ptr_t *msgp = proc_messages + for_proc;
assert(!IS_SHEEP_NULL(msgp));
Expand Down
2 changes: 1 addition & 1 deletion src/biter/demultiplex.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA

typedef struct msg_header_t {
uint32_t msg_size;
uint32_t msg_target;
int msg_target;
} msg_header_t;

extern int test_pipe_lock(void *session);
Expand Down
2 changes: 1 addition & 1 deletion src/biter/ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#define IDS_H_

int biterc_get_job_id();
unsigned int biterc_get_rank();
unsigned int biterc_get_rank(int session_id);

#endif
7 changes: 7 additions & 0 deletions src/biter/linux_daemon_ids.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ int biterd_num_compute_nodes()

int biterd_ranks_in_cn(int cn_id)
{
(void)cn_id;
char *proc_s = getenv("PROCS");
if (proc_s)
return atoi(proc_s);
Expand All @@ -34,20 +35,26 @@ int biterd_ranks_in_cn(int cn_id)

int biterd_unique_num_for_cn(int cn_id)
{
(void)cn_id;
return 0;
}

int biterd_get_rank(int compute_node_id, int client_id)
{
(void)compute_node_id;
return client_id;
}

int biterd_register_rank(int session_id, uint32_t client_id, uint32_t rank)
{
(void)session_id;
(void)client_id;
(void)rank;
return 0;
}

int biterd_init_comms(const char *tmpdir)
{
(void)tmpdir;
return 0;
}
8 changes: 8 additions & 0 deletions src/biter/server_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,36 +45,43 @@ void init_queue(int num_procs, void *session)

int test_pipe_lock(void *session)
{
(void)session;
return 1;
}

int release_pipe_lock(void *session)
{
(void)session;
return 0;
}

int take_queue_lock(void *session)
{
(void)session;
return 0;
}

int release_queue_lock(void *session)
{
(void)session;
return 0;
}

int take_write_lock(void *session)
{
(void)session;
return 0;
}

int release_write_lock(void *session)
{
(void)session;
return 0;
}

int take_pipe_lock(void *session)
{
(void)session;
return 0;
}

Expand Down Expand Up @@ -124,6 +131,7 @@ int enqueue_message(int for_proc, void *msg_data, size_t msg_size, void *header_

int get_message_space(size_t msg_size, unsigned char **msg_space, void **header_space, void *session)
{
(void)session;
*msg_space = (unsigned char *) malloc(msg_size);
*header_space = malloc(sizeof(message_t));
return 0;
Expand Down
4 changes: 2 additions & 2 deletions src/biter/shmutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ int init_heap_lock(shminfo_t *shminfo)
return 0;
initialized = 1;

shminfo->mem_lock.lock = shminfo->shared_header->base.locks + 0;
shminfo->mem_lock.held_by = shminfo->shared_header->base.locks + 1;
shminfo->mem_lock.lock = shminfo->shared_header->base.lock;
shminfo->mem_lock.held_by = shminfo->shared_header->base.held_by;
return 0;
}

Expand Down
14 changes: 9 additions & 5 deletions src/biter/shmutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#if !defined(SHMUTIL_H_)
#define SHMUTIL_H_

#include <sys/types.h>
#include "sheep.h"
#include "spindle_launch.h"

typedef struct {
volatile unsigned long *lock;
volatile unsigned long *held_by;
volatile pid_t *held_by;
int ref_count;
} lock_t;

typedef struct {
volatile int cur_id;
unsigned long locks[2];
Copy link
Member

@mplegendre mplegendre Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm nervous about changing the locks[] layout here. I don't remember why I wrote it this way, but I wouldn't have done something this odd without reason. Given that arrays and structs can have different packing (even if on x86_64 it shouldn't pack struct vs array different here), it might have had something to do with that. There's also some memory barriers around the code that uses these arrays, and there's always tough subtleties when those are involved.

That said, I can't re-determine why these should be arrays with just code inspection. And it's too bad I didn't comment why it's like this.

Given that this is a warning cleanup commit, let's not risk subtle semantic changes.

(And this applies to the two other array->struct conversions below as well)

unsigned long *lock;
pid_t *held_by;
} base_header_t;

#include "demultiplex.h"
Expand All @@ -43,11 +45,13 @@ typedef struct {
int num_ranks;
int read_file;
int num_started;
unsigned long locks[6];
unsigned long lock[3];
pid_t held_by[3];
} biter_header_t;

typedef struct {
unsigned long locks[2];
unsigned long *lock;
pid_t *held_by;
sheep_ptr_t hash;
sheep_ptr_t lru_head;
sheep_ptr_t lru_end;
Expand Down Expand Up @@ -85,6 +89,6 @@ int setup_ids(shminfo_t *shminfo);
int take_heap_lock(shminfo_t *shminfo);
int release_heap_lock(shminfo_t *shminfo);

void update_shm_id();
void update_shm_id(shminfo_t *shminfo);

#endif
4 changes: 4 additions & 0 deletions src/client/auditclient/auditclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ extern void restore_pathpatch();

unsigned int spindle_la_version(unsigned int version)
{
(void)version;
patchDTV_init();
return 1;
}
Expand All @@ -51,6 +52,8 @@ void spindle_la_activity (uintptr_t *cookie, unsigned int flag)

unsigned int spindle_la_objopen(struct link_map *map, Lmid_t lmid, uintptr_t *cookie)
{
(void)lmid;
(void)cookie;
char buffer[4096];
char *exe_name, *exe_name2;

Expand All @@ -73,5 +76,6 @@ unsigned int spindle_la_objopen(struct link_map *map, Lmid_t lmid, uintptr_t *co

unsigned int spindle_la_objclose(uintptr_t *cookie)
{
(void)cookie;
return 0;
}
7 changes: 7 additions & 0 deletions src/client/auditclient/auditclient_x86_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ Elf64_Addr la_x86_64_gnu_pltenter(Elf64_Sym *sym,
const char *symname,
long int *framesizep)
{
(void)ndx;
(void)defcook;
(void)flags;
(void)framesizep;
struct link_map *map = get_linkmap_from_cookie(refcook);
unsigned long reloc_index = *((unsigned long *) (regs->lr_rsp-8));
Elf64_Addr target = client_call_binding(symname, sym->st_value);
Expand All @@ -53,6 +57,9 @@ uintptr_t la_symbind64(Elf64_Sym *sym, unsigned int ndx,
{
// struct link_map *rmap = get_linkmap_from_cookie(refcook);
// struct link_map *dmap = get_linkmap_from_cookie(defcook);
(void)ndx;
(void)refcook;
(void)defcook;
updateDataBindingQueue(0);
Elf64_Addr target = client_call_binding(symname, sym->st_value);
*flags = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/client/auditclient/bindgot.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Elf64_Addr doPermanentBinding_noidx(uintptr_t *refcook, uintptr_t *defcook,
Elf64_Addr target, const char *symname,
void *stack_begin, void *stack_end)
{
(void)defcook;
int plt_reloc_idx;
Elf64_Rela *rels = NULL, *rel;
Elf64_Xword relsize = 0;
Expand Down Expand Up @@ -247,6 +248,7 @@ Elf64_Addr doPermanentBinding_idx(struct link_map *map,
Elf64_Addr target,
const char *symname)
{
(void)symname;
Elf64_Dyn *dynamic_section = map->l_ld;
Elf64_Addr *got_entry;
Elf64_Rela *rel = NULL;
Expand Down
7 changes: 4 additions & 3 deletions src/client/auditclient/writablegot.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ int add_wgot_library(struct link_map *map)
unsigned long rel_size = 0, relent_size = 0, relcount = 0, plt_gotsize = 0, start, end;
unsigned long datarels_size = 0, largest_datarel_target = 0, smallest_datarel_target = 0;
signed int i;
unsigned int j;
struct got_range_t *tmprange;


Expand Down Expand Up @@ -118,9 +119,9 @@ int add_wgot_library(struct link_map *map)
plt_gotsize = (relcount + EXTRA_GOT_ENTRIES + 1) * sizeof(void*);

if (datarels) {
for (i = 0; i < datarels_size / relent_size; i++) {
unsigned long target = datarels[i].r_offset + map->l_addr;
if (ELF64_R_TYPE(datarels[i].r_info) != DATA_GOT_TYPE)
for (j = 0; j < datarels_size / relent_size; j++) {
unsigned long target = datarels[j].r_offset + map->l_addr;
if (ELF64_R_TYPE(datarels[j].r_info) != DATA_GOT_TYPE)
continue;
largest_datarel_target = MAX(target, largest_datarel_target);
if (!smallest_datarel_target) smallest_datarel_target = target;
Expand Down
1 change: 1 addition & 0 deletions src/client/beboot/spindle_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ static void get_clientlib()

void test_log(const char *name)
{
(void)name;
}

static int handle_exec_failure(char **cmdline, int errno_val)
Expand Down
2 changes: 2 additions & 0 deletions src/client/client/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ static char *concatStrings(const char *str1, const char *str2)
static int find_libs_iterator(struct dl_phdr_info *lib,
size_t size, void *data)
{
(void)size;
(void)data;
if (!libc_name && (strstr(lib->dlpi_name, "libc.") || strstr(lib->dlpi_name, "libc-"))) {
libc_name = lib->dlpi_name;
libc_phdrs = lib->dlpi_phdr;
Expand Down
2 changes: 1 addition & 1 deletion src/client/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void remove_libc_rogot();
int handle_stat(const char *path, struct stat *buf, int flags);
int open_worker(const char *path, int oflag, mode_t mode, int is_64);
FILE *fopen_worker(const char *path, const char *mode, int is_64);
void remap_executable();
void remap_executable(int ldcsid);
int get_ldso_metadata_bindingoffset(signed int *binding_offset);
int get_ldso_metadata_statdata(signed long *stat_offset, signed long *lstat_offset, signed long *errno_offset);

Expand Down
3 changes: 2 additions & 1 deletion src/client/client/exec_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ int adjust_if_script(const char *orig_path, char *reloc_path, char **argv, char
for (i = 0; i < interp_argc; i++)
(*new_argv)[j++] = spindle_strdup(interpreter_args[i]);
/* If argv[0] is not a path, replace with absolute path to mimic kernel behavior */
(*new_argv)[j++] = (argv[0] && strchr(argv[0], '/')) ? argv[0] : orig_path;
char *orig_path_copy = strdup( orig_path ); /* Preserve constness of orig_path. */
(*new_argv)[j++] = (argv[0] && strchr(argv[0], '/')) ? argv[0] : orig_path_copy;
for (i = 1; i < argc; i++) {
(*new_argv)[j++] = argv[i];
}
Expand Down
Loading