Comments (3)
Not only sprintf causes seg fault, the following as well
int
main(void)
{
char buff[10] = {0};
printf("%s", buff);
return 0;
}
#0 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:65
65 ../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory.
(gdb) bt
#0 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:65
#1 0x00007fd838a91e95 in __vfprintf_internal (s=s@entry=0x7ffd7ab834c0, format=format@entry=0x7ffd7ab83700 "%s", ap=ap@entry=0x7ffd7ab83600, mode_flags=mode_flags@entry=6) at vfprintf-internal.c:1688
#2 0x00007fd838a9e279 in __vsprintf_internal (string=0x7ffd7ab83770 "", maxlen=maxlen@entry=1000, format=0x7ffd7ab83700 "%s", args=args@entry=0x7ffd7ab83600, mode_flags=mode_flags@entry=6) at iovsprintf.c:95
#3 0x00007fd838b46edb in ___sprintf_chk (s=s@entry=0x7ffd7ab83770 "", flag=flag@entry=1, slen=slen@entry=1000, format=<optimized out>) at sprintf_chk.c:40
#4 0x000055ace9a30a85 in sprintf (__fmt=<optimized out>, __s=<optimized out>) at /usr/include/x86_64-linux-gnu/bits/stdio2.h:36
#5 lle_X_sprintf (FT=FT@entry=0x55acebaadd20, Args=std::vector of length 3, capacity 3 = {...}) at ExternalFunctions.cpp:445
#6 0x000055ace9a31d4f in lle_X_printf (FT=0x55acebaadd20, Args=std::vector of length 2, capacity 2 = {...}) at ExternalFunctions.cpp:469
#7 0x000055ace9a3323a in llvm::Interpreter::callExternalFunction (this=this@entry=0x55acebb7c5c0, F=F@entry=0x55acebb5bfa8, ArgVals=std::vector of length 2, capacity 2 = {...}) at ExternalFunctions.cpp:297
#8 0x000055ace9a1c1c1 in llvm::Interpreter::callFunction (this=0x55acebb7c5c0, F=0x55acebb5bfa8, ArgVals=std::vector of length -185212533053011061, capacity 2931805465809 = {...}) at Execution.cpp:4371
#9 0x000055ace9a1c8ce in llvm::Interpreter::callFunction (ArgVals=std::vector of length 2, capacity 2 = {...}, F=0x55acebb5bfa8, this=0x55acebb7c5c0) at /usr/lib/llvm-8/include/llvm/Support/Casting.h:255
#10 llvm::Interpreter::visitCallInstWrapper (this=0x55acebb7c5c0, CS=...) at Execution.cpp:1633
#11 0x000055ace9a1d497 in llvm::Interpreter::run (this=this@entry=0x55acebb7c5c0) at Execution.cpp:4484
#12 0x000055ace9990d83 in llvm::Interpreter::runFunction (this=0x55acebb7c5c0, F=0x55aceba8b9a8, ArgValues=...) at Interpreter.cpp:750
#13 0x00007fd83aafd9de in llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, char const* const*) () from /usr/lib/x86_64-linux-gnu/libLLVM-8.so.1
#14 0x000055ace99702fa in GenMCDriver::explore (this=this@entry=0x55acebb53f30) at GenMCDriver.cpp:633
#15 0x000055ace9970469 in GenMCDriver::run (this=0x55acebb53f30) at GenMCDriver.cpp:464
#16 0x000055ace994cf28 in main (argc=<optimized out>, argv=0x7ffd7ab87a28) at main.cpp:194
or
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
int
main(void)
{
char buff[10] = {0};
int x = atoi(buff);
return 0;
}
#0 __GI_____strtol_l_internal (nptr=0x1ace2c44 <error: Cannot access memory at address 0x1ace2c44>, endptr=endptr@entry=0x0, base=base@entry=10, group=group@entry=0, loc=0x7f2b963344a0 <_nl_global_locale>) at ../stdlib/strtol_l.c:292
292 ../stdlib/strtol_l.c: No such file or directory.
(gdb) bt
#0 __GI_____strtol_l_internal (nptr=0x1ace2c44 <error: Cannot access memory at address 0x1ace2c44>, endptr=endptr@entry=0x0, base=base@entry=10, group=group@entry=0, loc=0x7f2b963344a0 <_nl_global_locale>) at ../stdlib/strtol_l.c:292
#1 0x00007f2b96193c36 in __strtol (nptr=<optimized out>, endptr=endptr@entry=0x0, base=base@entry=10) at ../stdlib/strtol.c:106
#2 0x00007f2b9618f744 in __GI_atoi (nptr=<optimized out>) at atoi.c:27
#3 0x00007f2b9a4bfdae in ffi_call_unix64 () from /usr/lib/x86_64-linux-gnu/libffi.so.6
#4 0x00007f2b9a4bf71f in ffi_call () from /usr/lib/x86_64-linux-gnu/libffi.so.6
#5 0x0000555f18c6b224 in ffiInvoke (Result=..., TD=<optimized out>, ArgVals=..., F=<optimized out>, Fn=<optimized out>) at /usr/lib/llvm-8/include/llvm/ADT/SmallVector.h:129
#6 llvm::Interpreter::callExternalFunction (this=this@entry=0x555f1ace3880, F=F@entry=0x555f1acc3a78, ArgVals=std::vector of length 94429796831613770, capacity 2932013690047 = {...}) at ExternalFunctions.cpp:322
#7 0x0000555f18c531c1 in llvm::Interpreter::callFunction (this=0x555f1ace3880, F=0x555f1acc3a78, ArgVals=std::vector of length 94429796831613770, capacity 2932013690047 = {...}) at Execution.cpp:4371
#8 0x0000555f18c538ce in llvm::Interpreter::callFunction (ArgVals=std::vector of length 1, capacity 1 = {...}, F=0x555f1acc3a78, this=0x555f1ace3880) at /usr/lib/llvm-8/include/llvm/Support/Casting.h:255
#9 llvm::Interpreter::visitCallInstWrapper (this=0x555f1ace3880, CS=...) at Execution.cpp:1633
#10 0x0000555f18c54497 in llvm::Interpreter::run (this=this@entry=0x555f1ace3880) at Execution.cpp:4484
#11 0x0000555f18bc7d83 in llvm::Interpreter::runFunction (this=0x555f1ace3880, F=0x555f1abf39a8, ArgValues=...) at Interpreter.cpp:750
#12 0x00007f2b9822f9de in llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, char const* const*) () from /usr/lib/x86_64-linux-gnu/libLLVM-8.so.1
#13 0x0000555f18ba72fa in GenMCDriver::explore (this=this@entry=0x555f1acbb730) at GenMCDriver.cpp:633
#14 0x0000555f18ba7469 in GenMCDriver::run (this=0x555f1acbb730) at GenMCDriver.cpp:464
#15 0x0000555f18b83f28 in main (argc=<optimized out>, argv=0x7fffce7476b8) at main.cpp:194
from genmc.
If I don't declare the array on the stack, the program does not crash. It seems to be related to putting arrays on the stack somehow!
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
char buff[10] = {0}; // no crash
int
main(void)
{
printf("%s", buff);
int x = 10;
sprintf(buff, "%d", x);
x = atoi(buff);
return 0;
}
from genmc.
Closing, as this is identical to #10.
from genmc.
Related Issues (20)
- LKMM atomic_andnot and non-returning atomics HOT 1
- Macro `__CONFIG_GENMC_INODE_DATA_SIZE` not defined HOT 1
- Unexpected failure of cmpxchg HOT 1
- Problems with while(x--) HOT 2
- Unexpected behaviour under the unroll option. HOT 1
- genmc vs IMM paper (Remark 2) HOT 3
- BUG: Failure at MOCalculator.cpp:65/getStoreOffset()! HOT 6
- LLVM-6 build is much faster than LLVM-14 build HOT 5
- fprintf(stderr,...) triggers a crash in genmc HOT 1
- Bug with -imm (dependency broken after revisit?) HOT 1
- [missing feature/bug] thread local storage array results into LLVM error HOT 1
- bug: Anomaly with seq_cst and assert HOT 1
- BUG: Failure at PromoteMemIntrinsicPass.cpp:78/promoteMemSet()! HOT 1
- Strange case with compare and swap HOT 1
- Feature Request: support for pthread_rwlock
- BUG: Failure at MOCalculator.cpp:65/getStoreOffset()! HOT 2
- Several issues with one client HOT 1
- Compiling with optimizations disabled results in runtime error HOT 5
- Rust Support HOT 1
- LKMM: failing cmpxchg should have no ordering HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from genmc.