Revision a4641c8b75b93ce30b706fceed7d2af976f8e578 authored by Jameson Nash on 06 May 2020, 19:12:05 UTC, committed by GitHub on 06 May 2020, 19:12:05 UTC
Ensures that we are holding some lock (a new one) while mutating the internal global `jl_current_modules` table. While reading these binding values is not memory-safe to do simultaneously (it may invent pointers from thin-air and segfault), this commit ensures that a data conflict during the writes to them will not corrupt the values written into memory.
1 parent c3d6a46
stringreplace.c
// This file is a part of Julia. License is MIT: https://julialang.org/license
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main( int argc, char ** argv ) {
if( argc < 5 ) {
printf("Usage:\n");
printf(" %s <hex offset> <string to write> <maxlen> <file>\n", argv[0] );
return -1;
}
unsigned long offset = strtoul(argv[1], NULL, 16);
char * replacement = argv[2];
unsigned long maxlen = strtoul(argv[3], NULL, 10);
FILE * f = fopen( argv[4], "r+" );
if( !f ) {
printf( "ERROR: Could not open %s for writing!\n", argv[4] );
return -1;
}
if( strlen(replacement) > maxlen ) {
printf( "ERROR: Replacement string length (%lu) is greater than maxlen! (%lu)\n", strlen(replacement), maxlen );
return -1;
}
fseek( f, offset, SEEK_SET );
fwrite( replacement, strlen(replacement)+1, 1, f );
fclose( f );
return 0;
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...