Skip to content

Instantly share code, notes, and snippets.

@awreece
awreece / gist:c4a2d8e28b7da00aa3e2
Last active August 29, 2015 14:06
spot the bug 2013
def swap(threaded_array, i, j):
threaded_array.locks[i].lock()
threaded_array.locks[j].lock()
threaded_array.data[i], threaded_array.data[j] = \
threaded_array.data[j], threaded_array.data[i]
threaded_array.locks[j].unlock()
threaded_array.locks[i].unlock()
memlib.c: In function 'mem_sbrk':
memlib.c:64:13: error: 'sbrk' is deprecated (declared at /usr/include/unistd.h:582) [-Werror=deprecated-declarations]
sbrk(incr) == (void *) -1) {
^
cc1: all warnings being treated as errors
// Align p to a multiple of w bytes
static inline void* align(const void const* p, unsigned char w) {
return (void*)(((uintptr_t)(p) + (w-1)) & ~(w-1));
}
#ifndef NDEBUG
#define ASSERT3(x, op, y) \
do { \
if (!((x) op (y))) { \
fprintf(stderr, "Assertion failure on %s:%d: " \
"expected " #x" (0x%lx) " #op \
" " #y " (0x%lx)\n\n", \
__FILE__, __LINE__, \
(uintptr_t)x, (uintptr_t)y); \
print_backtrace(0); \
void print_backtrace(int skip) {
void *backtrace_array[MAX_STACK];
int stack_size = backtrace(backtrace_array, MAX_STACK);
backtrace_symbols_fd(&backtrace_array[skip+1],
stack_size - skip - 1, STDERR_FILENO);
}
void signal_backtrace(int signum) {
fprintf(stderr, "%s\n\n", strsignal(signum));
print_backtrace(2);
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <string.h>
#define UNW_LOCAL_ONLY
#include <libunwind.h>
#define MAX_FUNC_NAME 128
diff --git a/usr/src/common/avl/avl.c b/usr/src/common/avl/avl.c
index dd39c12..f0e010d 100644
--- a/usr/src/common/avl/avl.c
+++ b/usr/src/common/avl/avl.c
@@ -863,6 +863,24 @@ avl_update(avl_tree_t *t, void *obj)
return (B_FALSE);
}
+void
+avl_swap(avl_tree_t *tree1, avl_tree_t *tree2)
$ gcc -fPIC -shared -c myctor.c -o myctor.o
$ gcc -fPIC -shared myctor.o -o libmyctor.so
$ LD_PRELOAD=$(pwd)/libmyctor.so ls
myctor
libmyctor.so myctor.c myctor.o
$ % dis -t .init libmyctor.so
disassembly for libmyctor.so
<html>
<TITLE>Course Web Page</TITLE>
This course is about programming
in C++.
<li><a href="http://www.cs.fsu.edu/somefile.html">Click here</a>
<!-- almost done! -->
</html>
# pkg install pkg:/omniti/database/postgresql-926
pkg install: No matching version of omniti/database/postgresql-926 can be installed:
Reject: pkg://ms.omniti.com/omniti/database/[email protected],5.11-0.151006:20131205T171425Z
Reason: All versions matching 'require' dependency pkg:/[email protected],5.11-0.151006 are rejected
Reject: pkg://omnios/[email protected],5.11-0.151006:20130506T161045Z
Reason: Newer version pkg://omnios/[email protected],5.11-0.151008:20131204T022241Z is already installed
This version is excluded by installed incorporation pkg://omnios/consolidation/osnet/[email protected],5.11-0.151008:20131204T022427Z
This version is excluded by installed incorporation pkg://omnios/incorporation/jeos/illumos-gate@11,5.11-0.151008:20131204T024149Z
Reject: pkg://omnios/[email protected],5.11-0.151008:20131204T022241Z
Reason: All versions matching 'require' dependency pkg:/consolidation/osnet/osnet-incorporation are rejected