I am trying to deploy an Rmarkdown document to RPubs. Required data are in subfolder /Data of the directory where the app is located. Previous errors were solved by loading some (but, mysteriously, not all) libraries on separate lines ('library(). Now, it says deployment is successful, but the website https://yettas.shinyapps.io/ShinyVEST-lite/ returns:
'Error: Error: An error has occurred. Check your logs or contact the app author for clarification.' Unlike previous attempts, I do not see an Error explicitly listed in the logs (see below). I am not sure what to look for other than the word 'Error'.
Thank you in advance for your help!
2022-11-07T15:57:05.864726+00:00 shinyapps[7537976]: 176:
signalCondition 2022-11-07T15:57:05.864730+00:00 shinyapps[7537976]:
175: signal_abort 2022-11-07T15:57:05.864734+00:00 shinyapps[7537976]:
174: abort 2022-11-07T15:57:05.864742+00:00 shinyapps[7537976]: 173:
h 2022-11-07T15:57:05.864759+00:00 shinyapps[7537976]: 172:
.handleSimpleError 2022-11-07T15:57:05.864763+00:00
shinyapps[7537976]: 171: between 2022-11-07T15:57:05.864771+00:00
shinyapps[7537976]: 170: mask$eval_all_filter
2022-11-07T15:57:05.864774+00:00 shinyapps[7537976]: 168:
filter_eval 2022-11-07T15:57:05.864777+00:00 shinyapps[7537976]:
167: filter_rows 2022-11-07T15:57:05.864780+00:00 shinyapps[7537976]:
166: filter.data.frame 2022-11-07T15:57:05.864787+00:00
shinyapps[7537976]: 165: NextMethod 2022-11-07T15:57:05.864797+00:00
shinyapps[7537976]: 164: stopifnot 2022-11-07T15:57:05.864828+00:00
shinyapps[7537976]: 163: .re_sf 2022-11-07T15:57:05.864838+00:00
shinyapps[7537976]: 162: filter.sf 2022-11-07T15:57:05.864842+00:00
shinyapps[7537976]: 161: filter 2022-11-07T15:57:05.864871+00:00
shinyapps[7537976]: 160: select 2022-11-07T15:57:05.864876+00:00
shinyapps[7537976]: 159: mutate 2022-11-07T15:57:05.864888+00:00
shinyapps[7537976]: 158: %!>(MISSING)%!(NOVERB)
2022-11-07T15:57:05.864906+00:00 shinyapps[7537976]: 157:
new.get.data 2022-11-07T15:57:05.864915+00:00 shinyapps[7537976]:
156: %!>(MISSING)%!(NOVERB) 2022-11-07T15:57:05.864927+00:00
shinyapps[7537976]: 155: eval 2022-11-07T15:57:05.864943+00:00
shinyapps[7537976]: 154: eval 2022-11-07T15:57:05.864966+00:00
shinyapps[7537976]: 153: eval_with_user_handlers
2022-11-07T15:57:05.864971+00:00 shinyapps[7537976]: 148:
evaluate_call 2022-11-07T15:57:05.864975+00:00 shinyapps[7537976]:
147: evaluate::evaluate 2022-11-07T15:57:05.864997+00:00
shinyapps[7537976]: 146: evaluate 2022-11-07T15:57:05.865006+00:00
shinyapps[7537976]: 143: eng_r 2022-11-07T15:57:05.865018+00:00
shinyapps[7537976]: 142: block_exec 2022-11-07T15:57:05.865037+00:00
shinyapps[7537976]: 141: call_block 2022-11-07T15:57:05.865059+00:00
shinyapps[7537976]: 140: process_group.block
2022-11-07T15:57:05.865071+00:00 shinyapps[7537976]: 137:
process_file 2022-11-07T15:57:05.865091+00:00 shinyapps[7537976]:
136: knitr::knit 2022-11-07T15:57:05.865096+00:00 shinyapps[7537976]:
135: 2022-11-07T15:57:05.865109+00:00 shinyapps[7537976]:
130: 2022-11-07T15:57:05.865113+00:00 shinyapps[7537976]:
114: doc 2022-11-07T15:57:05.865142+00:00 shinyapps[7537976]: 113:
renderUI 2022-11-07T15:57:05.865149+00:00 shinyapps[7537976]: 112:
func 2022-11-07T15:57:05.865165+00:00 shinyapps[7537976]: 99:
renderFunc 2022-11-07T15:57:05.865171+00:00 shinyapps[7537976]: 98:
output$reactivedoc 2022-11-07T15:57:05.865190+00:00
shinyapps[7537976]: 17:
2022-11-07T15:57:05.865194+00:00 shinyapps[7537976]: 15:
2022-11-07T15:57:05.865219+00:00 shinyapps[7537976]:
13: fn 2022-11-07T15:57:05.865227+00:00 shinyapps[7537976]: 8:
retry 2022-11-07T15:57:05.865245+00:00 shinyapps[7537976]: 7:
connect$retryingStartServer 2022-11-07T15:57:05.865250+00:00
shinyapps[7537976]: 6: eval 2022-11-07T15:57:05.865269+00:00
shinyapps[7537976]: 5: eval 2022-11-07T15:57:05.865273+00:00
shinyapps[7537976]: 4: eval 2022-11-07T15:57:05.865297+00:00
shinyapps[7537976]: 3: eval 2022-11-07T15:57:05.865323+00:00
shinyapps[7537976]: 2: eval.parent
2022-11-07T15:57:05.865339+00:00 shinyapps[7537976]: 1: local
Qt app crash but is not reproduced easily
I have captured the dump stack and how to find out the source code by the stack
compile tool: mingw
OS: windows
I work with android(linux) always before, we can use addr2line to find out the crash source code.
So:
How can we find out the source code function or line when app was tested by the test engineer and it crash with dump stack?
In the final,try my best,I find two ways to debug the crash app offline:
First, we can use the addr2line.exe, which is located at {mingw path}/bin. For example, if you get the crash log like that:
"E:\\qt\\untitled5.exe"
"Exception Addr: 00904B21 :Module: C:\\Qt\\Qt5.9.0\\5.9\\mingw53_32\\bin\\Qt5Widgetsd.dll"
"Exception Code: C0000005 :Read Address: 00000000"
"Instruction: 8B 01 8B 40 34 C7 04 24 00 00 00 00 FF D0 83 EC"
"Registers: "
"EAX: 00904B1E EBX: 185304C8 ECX: 00000000 EDX: 18500048"
"ESI: 1851DD60 EDI: 755E16DD ESP: 0028FD20 EBP: 0028FD68"
"EIP: 00904B21 EFlags: 00010202"
"00904B21 :C:\\Qt\\Qt5.9.0\\5.9\\mingw53_32\\bin\\Qt5Widgetsd.dll"
"0040187C :E:\\qt\\untitled5.exe"
"004017AB :E:\\qt\\untitled5.exe"
"004016BC :E:\\qt\\untitled5.exe"
"00403B45 :E:\\qt\\untitled5.exe"
and we use addr2line to find out the crash point
C:\Qt\Qt5.9.0\Tools\mingw530_32\bin>addr2line.exe -f -e e:\qt\untitled5.exe 0040187C 004017AB 004016BC 00403B45
_ZN4testC2Ev
E:\qt\untitled5/test.cpp:6
_ZN10MainWindowC2EP7QWidget
E:\qt\untitled5/mainwindow.cpp:12
_Z5qMainiPPc
E:\qt\untitled5/main.cpp:35
WinMain#16
c:\Users\qt\work\qt\qtbase\src\winmain/qtmain_win.cpp:104
second ,use ExcHndl, one part of Dr.mingw. It is a good tool I think. The github project link:
enter link description here
adn it also has an sample, you will not miss it. And it has an crash report like that:
Error occurred on Wednesday, September 6, 2017 at 14:25:57.
untitled5.exe caused an Access Violation at location 008F4B21 in module Qt5Widgetsd.dll Reading from location 00000000.
Registers:
eax=008f4b1e ebx=005ff278 ecx=00000000 edx=184b0048 esi=005fdf48 edi=755e16dd
eip=008f4b21 esp=0028fd20 ebp=0028fd68 iopl=0 nv up ei pl nz na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010202
AddrPC Params
008F4B21 00000001 00000000 00000001 Qt5Widgetsd.dll!hide [c:/Users/qt/work/qt/qtbase/src/widgets/kernel/qwidget.cpp # 8037]
00401890 00000001 00000000 00050900 untitled5.exe! ?? [E:/qt/untitled5/test.cpp # 6]
4: test::test()
5: {
> 6: test3 *p = new test3;
7: }
8:
004017BF 00000000 184CED38 00050900 untitled5.exe! ?? [E:/qt/untitled5/mainwindow.cpp # 10]
8: {
9: ui->setupUi(this);
> 10: test *t = new test;
11: }
12:
004016D2 00000001 184CED38 00673108 untitled5.exe!qMain [E:/qt/untitled5/main.cpp # 29]
27:
28: QApplication a(argc, argv);
> 29: MainWindow w;
30: w.show();
31:
I have been using Anthony Shoumikhin's elfhook utility to redirect certain function calls in a shared library.
As a proof of concept, I've created a shared library which calls various functions from the posix socket api.
void TestAPI::work()
{
int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
char buf[1024];
recv(fd, buf, sizeof(buf), 0);
listen(fd, 1);
}
I've then hooked these functions:
elf_hook(filename, base_address, "socket", hook_socket);
elf_hook(filename, base_address, "listen", hook_listen);
elf_hook(filename, base_address, "recv", hook_recv);
where a hooked function calls the original api function, but also logs what is happening, for example:
int hook_socket(int domain, int type, int protocol)
{
int fd = socket(domain, type, protocol);
printf("fd=%d domain=%d type=%d protocol=%d\n", fd, domain, type, protocol);
return fd;
}
This all works fine, until I attempt to hook a function which isn't called in my TestAPI shared library
elf_hook(filename, base_address, "bind", hook_bind);
elf_hook(filename, base_address, "connect", hook_connect);
As soon as I do this, I get a segmentation fault:
#0 elf_machine_fixup_plt (map=<optimized out>, t=<optimized out>, reloc=<optimized out>, value=139753823227104, reloc_addr=0x7f1afa15e188) at ../sysdeps/x86_64/dl-machine.h:235
#1 _dl_fixup (l=<optimized out>, reloc_arg=<optimized out>) at ../elf/dl-runtime.c:148
#2 0x00007f1afa176753 in _dl_runtime_resolve_avx () at ../sysdeps/x86_64/dl-trampoline.h:112
#3 0x0000000000561b20 in ?? ()
#4 0x00007f1afa16f8e0 in ?? () at dl-fini.c:105 from /lib64/ld-linux-x86-64.so.2
#5 0x00007f1afa16f5fb in call_init (env=0x7ffff0e3aae0, argv=0x4a7390 <_start>, argc=-253515440, l=<optimized out>) at dl-init.c:30
#6 _dl_init (main_map=0x0, argc=-253515440, argv=0x4a7390 <_start>, env=0x7ffff0e3aae0) at dl-init.c:120
#7 0x000000000000001c in ?? ()
#8 0x0000000000000001 in ?? ()
#9 0x00007ffff0e3c21f in ?? ()
#10 0x0000000000000000 in ?? ()
I've tested this by hooking a function, running my application, seeing it segfault, calling that function in my shared library, running again, and seeing work correctly.
My knowledge of libdl and elf is not up to scratch to know what is happening here or how to prevent it / catch the fact that I've tried to hook a function which doesn't get called.
How can I prevent this from happening?
Edit:
Per request, here is the output of readelf:
$ readelf -s -S --dyn-syms -r ./libtest_api.so
There are 36 section headers, starting at offset 0x14a208:
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .note.gnu.build-i NOTE 00000000000001c8 000001c8
0000000000000024 0000000000000000 A 0 0 4
[ 2] .gnu.hash GNU_HASH 00000000000001f0 000001f0
0000000000000044 0000000000000000 A 3 0 8
[ 3] .dynsym DYNSYM 0000000000000238 00000238
0000000000000240 0000000000000018 A 4 2 8
[ 4] .dynstr STRTAB 0000000000000478 00000478
00000000000001b4 0000000000000000 A 0 0 1
[ 5] .gnu.version VERSYM 000000000000062c 0000062c
0000000000000030 0000000000000002 A 3 0 2
[ 6] .gnu.version_r VERNEED 0000000000000660 00000660
0000000000000070 0000000000000000 A 4 3 8
[ 7] .rela.dyn RELA 00000000000006d0 000006d0
00000000000000f0 0000000000000018 A 3 0 8
[ 8] .rela.plt RELA 00000000000007c0 000007c0
00000000000000d8 0000000000000018 AI 3 22 8
[ 9] .init PROGBITS 0000000000000898 00000898
000000000000001a 0000000000000000 AX 0 0 4
[10] .plt PROGBITS 00000000000008c0 000008c0
00000000000000a0 0000000000000010 AX 0 0 16
[11] .plt.got PROGBITS 0000000000000960 00000960
0000000000000010 0000000000000000 AX 0 0 8
[12] .text PROGBITS 0000000000000970 00000970
0000000000000253 0000000000000000 AX 0 0 16
[13] .fini PROGBITS 0000000000000bc4 00000bc4
0000000000000009 0000000000000000 AX 0 0 4
[14] .rodata PROGBITS 0000000000000bd0 00000bd0
0000000000000105 0000000000000000 A 0 0 8
[15] .eh_frame_hdr PROGBITS 0000000000000cd8 00000cd8
0000000000000034 0000000000000000 A 0 0 4
[16] .eh_frame PROGBITS 0000000000000d10 00000d10
00000000000000cc 0000000000000000 A 0 0 8
[17] .init_array INIT_ARRAY 0000000000201dc0 00001dc0
0000000000000010 0000000000000000 WA 0 0 8
[18] .fini_array FINI_ARRAY 0000000000201dd0 00001dd0
0000000000000008 0000000000000000 WA 0 0 8
[19] .jcr PROGBITS 0000000000201dd8 00001dd8
0000000000000008 0000000000000000 WA 0 0 8
[20] .dynamic DYNAMIC 0000000000201de0 00001de0
00000000000001f0 0000000000000010 WA 4 0 8
[21] .got PROGBITS 0000000000201fd0 00001fd0
0000000000000030 0000000000000008 WA 0 0 8
[22] .got.plt PROGBITS 0000000000202000 00002000
0000000000000060 0000000000000008 WA 0 0 8
[23] .data PROGBITS 0000000000202060 00002060
0000000000000008 0000000000000000 WA 0 0 8
[24] .bss NOBITS 0000000000202068 00002068
0000000000000008 0000000000000000 WA 0 0 1
[25] .comment PROGBITS 0000000000000000 00002068
0000000000000034 0000000000000001 MS 0 0 1
[26] .debug_aranges PROGBITS 0000000000000000 0000209c
0000000000000040 0000000000000000 0 0 1
[27] .debug_info PROGBITS 0000000000000000 000020dc
0000000000007a3b 0000000000000000 0 0 1
[28] .debug_abbrev PROGBITS 0000000000000000 00009b17
00000000000009e1 0000000000000000 0 0 1
[29] .debug_line PROGBITS 0000000000000000 0000a4f8
00000000000052dd 0000000000000000 0 0 1
[30] .debug_str PROGBITS 0000000000000000 0000f7d5
000000000011cb84 0000000000000001 MS 0 0 1
[31] .debug_ranges PROGBITS 0000000000000000 0012c359
0000000000000030 0000000000000000 0 0 1
[32] .debug_macro PROGBITS 0000000000000000 0012c389
000000000001c8a8 0000000000000000 0 0 1
[33] .shstrtab STRTAB 0000000000000000 0014a0b4
0000000000000151 0000000000000000 0 0 1
[34] .symtab SYMTAB 0000000000000000 00148c38
0000000000000ba0 0000000000000018 35 102 8
[35] .strtab STRTAB 0000000000000000 001497d8
00000000000008dc 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), l (large)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
Relocation section '.rela.dyn' at offset 0x6d0 contains 10 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000201dc0 000000000008 R_X86_64_RELATIVE a40
000000201dc8 000000000008 R_X86_64_RELATIVE ba2
000000201dd0 000000000008 R_X86_64_RELATIVE a00
000000202060 000000000008 R_X86_64_RELATIVE 202060
000000201fd0 000200000006 R_X86_64_GLOB_DAT 0000000000000000 __gmon_start__ + 0
000000201fd8 000300000006 R_X86_64_GLOB_DAT 0000000000000000 _Jv_RegisterClasses + 0
000000201fe0 000800000006 R_X86_64_GLOB_DAT 0000000000000000 _ZNSt8ios_base4InitD1E#GLIBCXX_3.4 + 0
000000201fe8 000900000006 R_X86_64_GLOB_DAT 0000000000000000 _ITM_deregisterTMClone + 0
000000201ff0 000a00000006 R_X86_64_GLOB_DAT 0000000000000000 _ITM_registerTMCloneTa + 0
000000201ff8 000c00000006 R_X86_64_GLOB_DAT 0000000000000000 __cxa_finalize#GLIBC_2.2.5 + 0
Relocation section '.rela.plt' at offset 0x7c0 contains 9 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000202018 000400000007 R_X86_64_JUMP_SLO 0000000000000000 puts#GLIBC_2.2.5 + 0
000000202020 000500000007 R_X86_64_JUMP_SLO 0000000000000000 _ZNSt8ios_base4InitC1E#GLIBCXX_3.4 + 0
000000202028 001600000007 R_X86_64_JUMP_SLO 0000000000000bb8 _ZN5boost6none_tC1ENS0 + 0
000000202030 000600000007 R_X86_64_JUMP_SLO 0000000000000000 recv#GLIBC_2.2.5 + 0
000000202038 000700000007 R_X86_64_JUMP_SLO 0000000000000000 __cxa_atexit#GLIBC_2.2.5 + 0
000000202040 000b00000007 R_X86_64_JUMP_SLO 0000000000000000 listen#GLIBC_2.2.5 + 0
000000202048 000d00000007 R_X86_64_JUMP_SLO 0000000000000000 socket#GLIBC_2.2.5 + 0
000000202050 000e00000007 R_X86_64_JUMP_SLO 0000000000000000 __stack_chk_fail#GLIBC_2.4 + 0
000000202058 000f00000007 R_X86_64_JUMP_SLO 0000000000000000 send#GLIBC_2.2.5 + 0
Symbol table '.dynsym' contains 24 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000898 0 SECTION LOCAL DEFAULT 9
2: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
3: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses
4: 0000000000000000 0 FUNC GLOBAL DEFAULT UND puts#GLIBC_2.2.5 (2)
5: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _ZNSt8ios_base4InitC1Ev#GLIBCXX_3.4 (3)
6: 0000000000000000 0 FUNC GLOBAL DEFAULT UND recv#GLIBC_2.2.5 (4)
7: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __cxa_atexit#GLIBC_2.2.5 (2)
8: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _ZNSt8ios_base4InitD1Ev#GLIBCXX_3.4 (3)
9: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTab
10: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable
11: 0000000000000000 0 FUNC GLOBAL DEFAULT UND listen#GLIBC_2.2.5 (2)
12: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_finalize#GLIBC_2.2.5 (2)
13: 0000000000000000 0 FUNC GLOBAL DEFAULT UND socket#GLIBC_2.2.5 (2)
14: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __stack_chk_fail#GLIBC_2.4 (5)
15: 0000000000000000 0 FUNC GLOBAL DEFAULT UND send#GLIBC_2.2.5 (4)
16: 0000000000202070 0 NOTYPE GLOBAL DEFAULT 24 _end
17: 0000000000202068 0 NOTYPE GLOBAL DEFAULT 23 _edata
18: 0000000000000a70 172 FUNC GLOBAL DEFAULT 12 _ZN10ElfHookAPI4workEv
19: 0000000000202068 0 NOTYPE GLOBAL DEFAULT 24 __bss_start
20: 0000000000000898 0 FUNC GLOBAL DEFAULT 9 _init
21: 0000000000000bc4 0 FUNC GLOBAL DEFAULT 13 _fini
22: 0000000000000bb8 11 FUNC WEAK DEFAULT 12 _ZN5boost6none_tC1ENS0_8i
23: 0000000000000bb8 11 FUNC WEAK DEFAULT 12 _ZN5boost6none_tC2ENS0_8i
Symbol table '.symtab' contains 124 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000000001c8 0 SECTION LOCAL DEFAULT 1
2: 00000000000001f0 0 SECTION LOCAL DEFAULT 2
3: 0000000000000238 0 SECTION LOCAL DEFAULT 3
4: 0000000000000478 0 SECTION LOCAL DEFAULT 4
5: 000000000000062c 0 SECTION LOCAL DEFAULT 5
6: 0000000000000660 0 SECTION LOCAL DEFAULT 6
7: 00000000000006d0 0 SECTION LOCAL DEFAULT 7
8: 00000000000007c0 0 SECTION LOCAL DEFAULT 8
9: 0000000000000898 0 SECTION LOCAL DEFAULT 9
10: 00000000000008c0 0 SECTION LOCAL DEFAULT 10
11: 0000000000000960 0 SECTION LOCAL DEFAULT 11
12: 0000000000000970 0 SECTION LOCAL DEFAULT 12
13: 0000000000000bc4 0 SECTION LOCAL DEFAULT 13
14: 0000000000000bd0 0 SECTION LOCAL DEFAULT 14
15: 0000000000000cd8 0 SECTION LOCAL DEFAULT 15
16: 0000000000000d10 0 SECTION LOCAL DEFAULT 16
17: 0000000000201dc0 0 SECTION LOCAL DEFAULT 17
18: 0000000000201dd0 0 SECTION LOCAL DEFAULT 18
19: 0000000000201dd8 0 SECTION LOCAL DEFAULT 19
20: 0000000000201de0 0 SECTION LOCAL DEFAULT 20
21: 0000000000201fd0 0 SECTION LOCAL DEFAULT 21
22: 0000000000202000 0 SECTION LOCAL DEFAULT 22
23: 0000000000202060 0 SECTION LOCAL DEFAULT 23
24: 0000000000202068 0 SECTION LOCAL DEFAULT 24
25: 0000000000000000 0 SECTION LOCAL DEFAULT 25
26: 0000000000000000 0 SECTION LOCAL DEFAULT 26
27: 0000000000000000 0 SECTION LOCAL DEFAULT 27
28: 0000000000000000 0 SECTION LOCAL DEFAULT 28
29: 0000000000000000 0 SECTION LOCAL DEFAULT 29
30: 0000000000000000 0 SECTION LOCAL DEFAULT 30
31: 0000000000000000 0 SECTION LOCAL DEFAULT 31
32: 0000000000000000 0 SECTION LOCAL DEFAULT 32
33: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
34: 0000000000201dd8 0 OBJECT LOCAL DEFAULT 19 __JCR_LIST__
35: 0000000000000970 0 FUNC LOCAL DEFAULT 12 deregister_tm_clones
36: 00000000000009b0 0 FUNC LOCAL DEFAULT 12 register_tm_clones
37: 0000000000000a00 0 FUNC LOCAL DEFAULT 12 __do_global_dtors_aux
38: 0000000000202068 1 OBJECT LOCAL DEFAULT 24 completed.7585
39: 0000000000201dd0 0 OBJECT LOCAL DEFAULT 18 __do_global_dtors_aux_fin
40: 0000000000000a40 0 FUNC LOCAL DEFAULT 12 frame_dummy
41: 0000000000201dc0 0 OBJECT LOCAL DEFAULT 17 __frame_dummy_init_array_
42: 0000000000000000 0 FILE LOCAL DEFAULT ABS lib_elfhook.cpp
43: 0000000000000bd0 1 OBJECT LOCAL DEFAULT 14 _ZStL19piecewise_construc
44: 0000000000202069 1 OBJECT LOCAL DEFAULT 24 _ZStL8__ioinit
45: 0000000000000bd1 1 OBJECT LOCAL DEFAULT 14 _ZStL13allocator_arg
46: 0000000000000bd2 1 OBJECT LOCAL DEFAULT 14 _ZStL6ignore
47: 0000000000000bd3 1 OBJECT LOCAL DEFAULT 14 _ZStL10defer_lock
48: 0000000000000bd4 1 OBJECT LOCAL DEFAULT 14 _ZStL11try_to_lock
49: 0000000000000bd5 1 OBJECT LOCAL DEFAULT 14 _ZStL10adopt_lock
50: 0000000000000bd8 4 OBJECT LOCAL DEFAULT 14 _ZN9__gnu_cxxL21__default
51: 0000000000000bdc 4 OBJECT LOCAL DEFAULT 14 _ZN6google8protobuf8inter
52: 0000000000000be0 4 OBJECT LOCAL DEFAULT 14 _ZN6google8protobuf8inter
53: 0000000000000be4 4 OBJECT LOCAL DEFAULT 14 _ZN6google8protobufL9kint
54: 0000000000000be8 4 OBJECT LOCAL DEFAULT 14 _ZN6google8protobufL9kint
55: 0000000000000bf0 8 OBJECT LOCAL DEFAULT 14 _ZN6google8protobufL9kint
56: 0000000000000bf8 8 OBJECT LOCAL DEFAULT 14 _ZN6google8protobufL9kint
57: 0000000000000c00 4 OBJECT LOCAL DEFAULT 14 _ZN6google8protobufL10kui
58: 0000000000000c08 8 OBJECT LOCAL DEFAULT 14 _ZN6google8protobufL10kui
59: 0000000000000c10 4 OBJECT LOCAL DEFAULT 14 _ZN6google8protobuf8inter
60: 0000000000000c14 4 OBJECT LOCAL DEFAULT 14 _ZN3cay3logL9Level_MINE
61: 0000000000000c18 4 OBJECT LOCAL DEFAULT 14 _ZN3cay3logL9Level_MAXE
62: 0000000000000c1c 4 OBJECT LOCAL DEFAULT 14 _ZN3cay3logL15Level_ARRAY
63: 0000000000000c20 4 OBJECT LOCAL DEFAULT 14 _ZN3cay3logL13DEFAULT_LEV
64: 000000000020206a 1 OBJECT LOCAL DEFAULT 24 _ZN5boostL4noneE
65: 0000000000000c24 4 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL13days_per
66: 0000000000000c28 4 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL18days_per
67: 0000000000000c2c 4 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL16days_per
68: 0000000000000c30 4 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL18days_per
69: 0000000000000c34 4 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL18days_per
70: 0000000000000c38 8 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL12min_per_
71: 0000000000000c40 8 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL12sec_per_
72: 0000000000000c48 8 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL11ms_per_h
73: 0000000000000c50 8 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL11us_per_h
74: 0000000000000c58 8 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL11ns_per_h
75: 0000000000000c60 8 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL11sec_per_
76: 0000000000000c68 8 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL10ms_per_m
77: 0000000000000c70 8 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL10us_per_m
78: 0000000000000c78 8 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL10ns_per_m
79: 0000000000000c80 4 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL10ms_per_s
80: 0000000000000c84 4 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL10us_per_s
81: 0000000000000c88 4 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL10ns_per_s
82: 0000000000000c90 8 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL10sec_per_
83: 0000000000000c98 4 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL9us_per_ms
84: 0000000000000c9c 4 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL9ns_per_ms
85: 0000000000000ca0 8 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL10sec_per_
86: 0000000000000ca8 8 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL9ms_per_us
87: 0000000000000cb0 4 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL9ns_per_us
88: 0000000000000cb8 8 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL10sec_per_
89: 0000000000000cc0 8 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL9ms_per_ns
90: 0000000000000cc8 8 OBJECT LOCAL DEFAULT 14 _ZN3cay6chronoL9us_per_ns
91: 0000000000000b1c 134 FUNC LOCAL DEFAULT 12 _Z41__static_initializati
92: 0000000000000ba2 21 FUNC LOCAL DEFAULT 12 _GLOBAL__sub_I_lib_elfhoo
93: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
94: 0000000000000dd8 0 OBJECT LOCAL DEFAULT 16 __FRAME_END__
95: 0000000000201dd8 0 OBJECT LOCAL DEFAULT 19 __JCR_END__
96: 0000000000000000 0 FILE LOCAL DEFAULT ABS
97: 0000000000000cd8 0 NOTYPE LOCAL DEFAULT 15 __GNU_EH_FRAME_HDR
98: 0000000000202000 0 OBJECT LOCAL DEFAULT 22 _GLOBAL_OFFSET_TABLE_
99: 0000000000202068 0 OBJECT LOCAL DEFAULT 23 __TMC_END__
100: 0000000000202060 0 OBJECT LOCAL DEFAULT 23 __dso_handle
101: 0000000000201de0 0 OBJECT LOCAL DEFAULT 20 _DYNAMIC
102: 0000000000000a70 172 FUNC GLOBAL DEFAULT 12 _ZN10ElfHookAPI4workEv
103: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
104: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses
105: 0000000000000000 0 FUNC GLOBAL DEFAULT UND puts##GLIBC_2.2.5
106: 0000000000000bc4 0 FUNC GLOBAL DEFAULT 13 _fini
107: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _ZNSt8ios_base4InitC1Ev##
108: 0000000000000bb8 11 FUNC WEAK DEFAULT 12 _ZN5boost6none_tC1ENS0_8i
109: 0000000000000000 0 FUNC GLOBAL DEFAULT UND recv##GLIBC_2.2.5
110: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __cxa_atexit##GLIBC_2.2.5
111: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _ZNSt8ios_base4InitD1Ev##
112: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTab
113: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable
114: 0000000000000000 0 FUNC GLOBAL DEFAULT UND listen##GLIBC_2.2.5
115: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_finalize##GLIBC_2.2
116: 0000000000000bb8 11 FUNC WEAK DEFAULT 12 _ZN5boost6none_tC2ENS0_8i
117: 0000000000000000 0 FUNC GLOBAL DEFAULT UND socket##GLIBC_2.2.5
118: 0000000000202068 0 NOTYPE GLOBAL DEFAULT 24 __bss_start
119: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __stack_chk_fail##GLIBC_2
120: 0000000000000000 0 FUNC GLOBAL DEFAULT UND send##GLIBC_2.2.5
121: 0000000000202070 0 NOTYPE GLOBAL DEFAULT 24 _end
122: 0000000000202068 0 NOTYPE GLOBAL DEFAULT 23 _edata
123: 0000000000000898 0 FUNC GLOBAL DEFAULT 9 _init
So what basically his code does is when you create shared library libtest.so that calls libc.so within it the following items are created within your library
a dynamic symbol table ( that includes data of all functions you are calling from libc.so )
a relocation table ( a list of entries within your code that called the functions within libc.so, every entry in a relocation table says that function X that belongs to libc.so was called in libtest.so in lines a,b,c...
His code parses your shared library, pulls the dynsymtable and the relocation table out of it and swaps symbols to your request by calling elf_hook() (see elf_hook.c lines 434 - 442).
You called three functions out of the libc.so API, which is a HUGE API, hence the dynsym in your table should contain symbols for socket() listen() and recv()
We can see dyn-symbols 13 11 and 6 are accordingly socket#GLIBC, listen#GLIBC and recv#GLIBC.
What the relocation table does is basically say where within the ACTUAL code of yours are those functions called, and when those symbols would have a resolved address which addresses would need to be replaced in order for your code to call the actual functions, as we also can see at .rela.plt you've posted as an output of the readelf command we see that on 3 different entries you've called theses symbols. These are what we need to replace.
So what his code does is find the index of the symbol you're looking to replace, go through ALL relocations, and see if they are relevant to the index-symbol. If so that means that in the place this relocation entry is relevant, it needs to replace it with the code you want.
Back with our previous example, lets say you want to replace socket() with y() in your libtest.so. His code finds the symbol index of socket(), finds where in code have you called socket() and replaces that with the address of y() instead.
Trying to hook symbols which don't exist
What can go wrong is the fact that when trying to hook symbols that weren't called is that simply there are no relocation entries for that symbol AND that symbol doesn't exist, you can see that e.g there is no entry in the dynsym table ( readelf output ) of bind().
What SHOULD happen is that he wouldn't find the according symbol and wont hook anything.
I honestly haven't gone through his entire code but my guess is that something went wrong there and he didn't handle the case of trying to hook a symbol that doesn't exist right...
Note:
Another thing that I've noticed that seems to be terrible wrong is the filling relocations of rel.dyn.
He has chosen to load the libs in his example with RTLD_LAZY, which basically means that every call to a DLL function would end up in jumping to some table of offsets, which point to your dynamic linker, and when the dynamic linker is called it replaces the offset which it was called from with the actual offset of the function... this is run-time relocation...
As far as I know rel.dyn is usually meant for load-time relocation, when the operating system loads an executable it copies it's code and looks at all the relocation entries and replaces them in code....
During run-time the offsets a rel.dyn table entries are pointing at would be within an executable section of the executable image, which means they SHOULD have only READ / EXECUTE permissions, not WRITE hence attempting to write into them SHOULD cause some segfault....
To sum things up, this probably happens because his utility didn't handle trying to hook an API function that does not exist within symbol table ( not called within your code ) right... hopefully I've helped you understand a little bit more of what happened...
Also, try reading this, it helped me to learn a lot about the ELF subject back in the day :)
http://flint.cs.yale.edu/cs422/doc/ELF_Format.pdf
When I do (0x7fffffff | 0x8000000) I am getting 0xffffffffffffffff instead of the expected 0xffffffff. What am I missing?
Some sample code and output to illustrate my question.
Code:
#include <iostream>
using namespace std;
int main()
{
unsigned long long val = 0;
for (int i = 0; i < 64; i++) {
val |= 0x1 << i;
cout << i << ": " << std::hex << val << std::dec << endl;
}
return 0;
}
Output:
0: 1
1: 3
2: 7
3: f
4: 1f
5: 3f
6: 7f
7: ff
8: 1ff
9: 3ff
10: 7ff
11: fff
12: 1fff
13: 3fff
14: 7fff
15: ffff
16: 1ffff
17: 3ffff
18: 7ffff
19: fffff
20: 1fffff
21: 3fffff
22: 7fffff
23: ffffff
24: 1ffffff
25: 3ffffff
26: 7ffffff
27: fffffff
28: 1fffffff
29: 3fffffff
30: 7fffffff
31: ffffffffffffffff
32: ffffffffffffffff
33: ffffffffffffffff
34: ffffffffffffffff
35: ffffffffffffffff
36: ffffffffffffffff
37: ffffffffffffffff
38: ffffffffffffffff
39: ffffffffffffffff
40: ffffffffffffffff
41: ffffffffffffffff
42: ffffffffffffffff
43: ffffffffffffffff
44: ffffffffffffffff
45: ffffffffffffffff
46: ffffffffffffffff
47: ffffffffffffffff
48: ffffffffffffffff
49: ffffffffffffffff
50: ffffffffffffffff
51: ffffffffffffffff
52: ffffffffffffffff
53: ffffffffffffffff
54: ffffffffffffffff
55: ffffffffffffffff
56: ffffffffffffffff
57: ffffffffffffffff
58: ffffffffffffffff
59: ffffffffffffffff
60: ffffffffffffffff
61: ffffffffffffffff
62: ffffffffffffffff
63: ffffffffffffffff
Firstly your code does not do what you say in your title/question; I have edited the title.
The problem is 1 << 31. If you have 32-bit int (which apparently you do, judging by the results), this cause arithmetic overflow. In C++14 this is implementation-defined behaviour; prior to C++14 it causes undefined behaviour. Reference.
Usually the implementation-defined behaviour will be to generate the int with the sign bit set and the other bits unset. In 2's complement this value is INT_MIN. You then perform arithmetic between an unsigned long long and an int. This is defined as: the int is converted to unsigned long long.
Converting signed integers to unsigned is done by wrapping it around (modular arithmetic) modulo ULLONG_MAX+1. So the result of (unsigned long long)INT_MIN is a very large positive number, in fact 0xFFFFFFFF80000000. (To check this, add 0x80000000 to it to get 0).
So you are actually doing 0x7FFFFFFF | 0xFFFFFFFF80000000 which gives the observed result.
Later on it gets worse: 1 << 32 and larger causes undefined behaviour due to shifting by the whole width of the type.
To fix this, change 0x1 in your code to 1ull. The you will be shifting an unsigned long long, instead of an int.
because of sign extension val is an unsigned long long. But val is not what you are shifting. You are shifting 0x1, an int, then extending it to long long for the '|='
My project.clj file looks like this
(defproject cljs-template "0.1.0-SNAPSHOT"
:description "FIXME: write this!"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.4.0-beta4"]
[noir-cljs "0.3.0"]
[fetch "0.1.0-alpha2"]
[noir "1.3.0-beta2"]
[org.clojure/core.cache "0.5.0"]
[com.datomic/datomic "0.1.3142"
:exclusions [org.slf4j/slf4j-nop org.slf4j/slf4j-log4j12]]
[ch.qos.logback/logback-classic "1.0.1"]]
:plugins [[lein-swank "1.4.3"]]
;:cljsbuild {:builds [{}]}
:main ^{:skip-aot true} cljs-template.server)
and my /src/cljs_template/server.clj begins as the following:
(ns cljs-template.server
(:require [noir.server :as server]
[noir.cljs.core :as cljs]
[cljs-template.tree :as tree])
(:use [datomic.api :only [db q] :as d]))
I then start up swank, run (in-ns 'cljs-template.server) within it, move my cursor to the end of the (ns) function call, and attempt to run the (ns) method using Ctrl-x Ctrl-e. When I do so, I get the following error.
No message.
[Thrown class java.lang.ExceptionInInitializerError]
Restarts:
0: [QUIT] Quit to the SLIME top level
1: [CAUSE1] Invoke debugger on cause org.apache.lucene.index.IndexWriterConfig [Thrown class java.lang.ClassNotFoundException]
Backtrace:
0: (Unknown Source) java.lang.Class.forName0
1: Class.java:247 java.lang.Class.forName
2: RT.java:2030 clojure.lang.RT.loadClassForName
3: RT.java:417 clojure.lang.RT.load
4: RT.java:398 clojure.lang.RT.load
5: core.clj:5386 clojure.core/load[fn]
6: core.clj:5385 clojure.core/load
7: RestFn.java:408 clojure.lang.RestFn.invoke
8: core.clj:5200 clojure.core/load-one
9: core.clj:5237 clojure.core/load-lib
10: RestFn.java:142 clojure.lang.RestFn.applyTo
11: core.clj:602 clojure.core/apply
12: core.clj:5271 clojure.core/load-libs
13: RestFn.java:137 clojure.lang.RestFn.applyTo
14: core.clj:602 clojure.core/apply
15: core.clj:5352 clojure.core/require
16: RestFn.java:436 clojure.lang.RestFn.invoke
17: fulltext_index.clj:4 datomic.fulltext-index/loading
18: (Unknown Source) datomic.fulltext_index__init.load
19: (Unknown Source) datomic.fulltext_index__init.<clinit>
20: (Unknown Source) java.lang.Class.forName0
21: Class.java:247 java.lang.Class.forName
22: RT.java:2030 clojure.lang.RT.loadClassForName
23: RT.java:417 clojure.lang.RT.load
24: RT.java:398 clojure.lang.RT.load
25: core.clj:5386 clojure.core/load[fn]
26: core.clj:5385 clojure.core/load
27: RestFn.java:408 clojure.lang.RestFn.invoke
28: core.clj:5200 clojure.core/load-one
29: core.clj:5237 clojure.core/load-lib
30: RestFn.java:142 clojure.lang.RestFn.applyTo
31: core.clj:602 clojure.core/apply
32: core.clj:5271 clojure.core/load-libs
33: RestFn.java:137 clojure.lang.RestFn.applyTo
34: core.clj:602 clojure.core/apply
35: core.clj:5352 clojure.core/require
36: RestFn.java:703 clojure.lang.RestFn.invoke
37: db.clj:4 datomic.db/loading
38: (Unknown Source) datomic.db__init.load
39: (Unknown Source) datomic.db__init.<clinit>
40: (Unknown Source) java.lang.Class.forName0
41: Class.java:247 java.lang.Class.forName
42: RT.java:2030 clojure.lang.RT.loadClassForName
43: RT.java:417 clojure.lang.RT.load
44: RT.java:398 clojure.lang.RT.load
45: core.clj:5386 clojure.core/load[fn]
46: core.clj:5385 clojure.core/load
47: RestFn.java:408 clojure.lang.RestFn.invoke
48: core.clj:5200 clojure.core/load-one
49: core.clj:5237 clojure.core/load-lib
50: RestFn.java:142 clojure.lang.RestFn.applyTo
51: core.clj:602 clojure.core/apply
52: core.clj:5271 clojure.core/load-libs
53: RestFn.java:137 clojure.lang.RestFn.applyTo
54: core.clj:602 clojure.core/apply
55: core.clj:5352 clojure.core/require
56: RestFn.java:703 clojure.lang.RestFn.invoke
57: query.clj:4 datomic.query/loading
58: (Unknown Source) datomic.query__init.load
59: (Unknown Source) datomic.query__init.<clinit>
60: (Unknown Source) java.lang.Class.forName0
61: Class.java:247 java.lang.Class.forName
62: RT.java:2030 clojure.lang.RT.loadClassForName
63: RT.java:417 clojure.lang.RT.load
64: RT.java:398 clojure.lang.RT.load
65: core.clj:5386 clojure.core/load[fn]
66: core.clj:5385 clojure.core/load
67: RestFn.java:408 clojure.lang.RestFn.invoke
68: core.clj:5200 clojure.core/load-one
69: core.clj:5237 clojure.core/load-lib
70: RestFn.java:142 clojure.lang.RestFn.applyTo
71: core.clj:602 clojure.core/apply
72: core.clj:5271 clojure.core/load-libs
73: RestFn.java:137 clojure.lang.RestFn.applyTo
74: core.clj:602 clojure.core/apply
75: core.clj:5352 clojure.core/require
76: RestFn.java:421 clojure.lang.RestFn.invoke
77: api.clj:6 datomic.api/loading
78: (Unknown Source) datomic.api__init.load
79: (Unknown Source) datomic.api__init.<clinit>
80: (Unknown Source) java.lang.Class.forName0
81: Class.java:247 java.lang.Class.forName
82: RT.java:2030 clojure.lang.RT.loadClassForName
83: RT.java:417 clojure.lang.RT.load
84: RT.java:398 clojure.lang.RT.load
85: core.clj:5386 clojure.core/load[fn]
86: core.clj:5385 clojure.core/load
87: RestFn.java:408 clojure.lang.RestFn.invoke
88: core.clj:5200 clojure.core/load-one
89: core.clj:5237 clojure.core/load-lib
90: RestFn.java:142 clojure.lang.RestFn.applyTo
91: core.clj:602 clojure.core/apply
92: core.clj:5271 clojure.core/load-libs
93: RestFn.java:137 clojure.lang.RestFn.applyTo
94: core.clj:604 clojure.core/apply
95: core.clj:5363 clojure.core/use
96: RestFn.java:408 clojure.lang.RestFn.invoke
97: NO_SOURCE_FILE:1 cljs-template.server/eval1941[fn]
98: NO_SOURCE_FILE:1 cljs-template.server/eval1941
99: Compiler.java:6465 clojure.lang.Compiler.eval
100: Compiler.java:6455 clojure.lang.Compiler.eval
101: Compiler.java:6431 clojure.lang.Compiler.eval
102: core.clj:2795 clojure.core/eval
103: core.clj:532 swank.core/eval782[fn]
104: MultiFn.java:163 clojure.lang.MultiFn.invoke
105: basic.clj:54 swank.commands.basic/eval-region
106: basic.clj:44 swank.commands.basic/eval-region
107: basic.clj:73 swank.commands.basic/eval968[fn]
108: Var.java:401 clojure.lang.Var.invoke
109: (Unknown Source) user/eval1937
110: Compiler.java:6465 clojure.lang.Compiler.eval
111: Compiler.java:6431 clojure.lang.Compiler.eval
112: core.clj:2795 clojure.core/eval
113: core.clj:100 swank.core/eval-in-emacs-package
114: core.clj:256 swank.core/eval-for-emacs
115: Var.java:409 clojure.lang.Var.invoke
116: AFn.java:167 clojure.lang.AFn.applyToHelper
117: Var.java:518 clojure.lang.Var.applyTo
118: core.clj:600 clojure.core/apply
119: core.clj:107 swank.core/eval-from-control
120: core.clj:330 swank.core/spawn-worker-thread[fn]
121: AFn.java:159 clojure.lang.AFn.applyToHelper
122: AFn.java:151 clojure.lang.AFn.applyTo
123: core.clj:600 clojure.core/apply
124: core.clj:326 swank.core/spawn-worker-thread[fn]
125: RestFn.java:397 clojure.lang.RestFn.invoke
126: AFn.java:24 clojure.lang.AFn.run
127: Thread.java:662 java.lang.Thread.run
I then press 0 to close the stacktrace, and press Ctrl-x Ctrl-e on the (ns) call again, now my error is:
Could not initialize class datomic.api__init
[Thrown class java.lang.NoClassDefFoundError]
Restarts:
0: [QUIT] Quit to the SLIME top level
Backtrace:
0: (Unknown Source) java.lang.Class.forName0
1: Class.java:247 java.lang.Class.forName
2: RT.java:2030 clojure.lang.RT.loadClassForName
3: RT.java:417 clojure.lang.RT.load
4: RT.java:398 clojure.lang.RT.load
5: core.clj:5386 clojure.core/load[fn]
6: core.clj:5385 clojure.core/load
7: RestFn.java:408 clojure.lang.RestFn.invoke
8: core.clj:5200 clojure.core/load-one
9: core.clj:5237 clojure.core/load-lib
10: RestFn.java:142 clojure.lang.RestFn.applyTo
11: core.clj:602 clojure.core/apply
12: core.clj:5271 clojure.core/load-libs
13: RestFn.java:137 clojure.lang.RestFn.applyTo
14: core.clj:604 clojure.core/apply
15: core.clj:5363 clojure.core/use
16: RestFn.java:408 clojure.lang.RestFn.invoke
17: NO_SOURCE_FILE:1 cljs-template.server/eval6292[fn]
18: NO_SOURCE_FILE:1 cljs-template.server/eval6292
19: Compiler.java:6465 clojure.lang.Compiler.eval
20: Compiler.java:6455 clojure.lang.Compiler.eval
21: Compiler.java:6431 clojure.lang.Compiler.eval
22: core.clj:2795 clojure.core/eval
23: core.clj:532 swank.core/eval782[fn]
24: MultiFn.java:163 clojure.lang.MultiFn.invoke
25: basic.clj:54 swank.commands.basic/eval-region
26: basic.clj:44 swank.commands.basic/eval-region
27: basic.clj:73 swank.commands.basic/eval968[fn]
28: Var.java:401 clojure.lang.Var.invoke
29: (Unknown Source) cljs-template.server/eval6288
30: Compiler.java:6465 clojure.lang.Compiler.eval
31: Compiler.java:6431 clojure.lang.Compiler.eval
32: core.clj:2795 clojure.core/eval
33: core.clj:100 swank.core/eval-in-emacs-package
34: core.clj:256 swank.core/eval-for-emacs
35: Var.java:409 clojure.lang.Var.invoke
36: AFn.java:167 clojure.lang.AFn.applyToHelper
37: Var.java:518 clojure.lang.Var.applyTo
38: core.clj:600 clojure.core/apply
39: core.clj:107 swank.core/eval-from-control
40: core.clj:330 swank.core/spawn-worker-thread[fn]
41: AFn.java:159 clojure.lang.AFn.applyToHelper
42: AFn.java:151 clojure.lang.AFn.applyTo
43: core.clj:600 clojure.core/apply
44: core.clj:326 swank.core/spawn-worker-thread[fn]
45: RestFn.java:397 clojure.lang.RestFn.invoke
46: AFn.java:24 clojure.lang.AFn.run
47: Thread.java:662 java.lang.Thread.run
What am I doing wrong? How do I get datomic working in my emacs using swank/slime.
Turns out I was executing the wrong command.
I was running lein deps and getting the following error.
...
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=com.datomic -DartifactId=datomic -Dversion=0.1.3157 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=com.datomic -DartifactId=datomic -Dversion=0.1.3157 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) org.apache.maven:super-pom:pom:2.0
2) com.datomic:datomic:jar:0.1.3157
I saw that the README file in the downloaded datomic code also contained mention of adding datomic to my mvn. Naturally (here comes the stupid part) I assumed that they sort of said the same thing.
lein will tell you that you should execute
mvn install:install-file -DgroupId=com.datomic -DartifactId=datomic -Dversion=0.1.3157 -Dpackaging=jar -Dfile=/path/to/file
the README says you should execute
mvn install:install-file -DgroupId=com.datomic -DartifactId=datomic -Dfile=datomic-${DATOMIC-VERSION}.jar -DpomFile=pom.xml
Did you notice that the README instructions also includes a pom.xml file? Neither did I! Yeah, that is important.
Anyway, be sure to also include the pom.xml file. If you were trying to add datomic 0.1.3157 to your mvn repository, you would execute the following in the datomic directory you downloaded.
mvn install:install-file -DgroupId=com.datomic -DartifactId=datomic -Dfile=datomic-0.1.3157.jar -DpomFile=pom.xml
I posted a working project here
my usual suspect in debugging swank problems are:
is leiningen up to date
the version of lein-swank
version of emacs (Emacs 24, I have found to be much more reliable)
leftover old dependencies in the lib dir
EDIT: the correct way to get the datomic jar is as Stephen Cagle says, copied from his comment below:
mvn install:install-file -DgroupId=com.datomic -DartifactId=datomic -Dfile=datomic-${DATOMIC-VERSION}.jar