Comments (20)
Hi @rdebath, do you have the source code for your helloworld.b ?
Is it the one located in the tests folder?
I will check it and answer as soon as possible! Thanks!
from brain.
Yes, it's the one in your tests folder, from Wikipedia. However, the problem seems to happen whatever is in the file, even just a newline (an empty file gives "No such file" !?)
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
from brain.
I think I had a linking problem related to that (and I fixed locally), but not cool, will fix it as soon as possible.
This line may be causing it. We are depending currently on C
and math.h
for IO
(must be removed later).
Just to test, try to run the command:
brain ./helloworld.b -c && $(CC) helloworld.o -o hello -lm && rm hello.o
from brain.
I forgot to ask, is it on the dev
branch? Which branch are you using? @rdebath
from brain.
Okay, I've now switched to the dev branch, recomplied and added the -c argument.
Still getting a segfault.
debian-jessie64(robert)brain-labs$ git describe --long --tags
v1.0-84-g7b65871
debian-jessie64(robert)brain-labs$ gdb -args bin/brain tests/helloworld.b -c
GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from bin/brain...done.
(gdb) run
Starting program: /home/robert/brain-labs/bin/brain tests/helloworld.b -c
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x0000000000ea7e52 in llvm::TypeFinder::incorporateType(llvm::Type*) ()
(gdb) bt
#0 0x0000000000ea7e52 in llvm::TypeFinder::incorporateType(llvm::Type*) ()
#1 0x0000000000ea7abb in llvm::TypeFinder::run(llvm::Module const&, bool) ()
#2 0x0000000000e9724b in llvm::Module::getIdentifiedStructTypes() const ()
#3 0x000000000043d20b in llvm::IRMover::move(std::unique_ptr<llvm::Module, std::default_delete<llvm::Module> >, llvm::ArrayRef<llvm::GlobalValue*>, std::function<void (llvm::GlobalValue&, std::function<void (llvm::GlobalValue&)>)>, bool) ()
#4 0x000000000043786b in llvm::Linker::linkInModule(std::unique_ptr<llvm::Module, std::default_delete<llvm::Module> >, unsigned int, std::function<void (llvm::Module&, llvm::StringSet<llvm::MallocAllocator> const&)>) ()
#5 0x0000000000437e7a in llvm::Linker::linkModules(llvm::Module&, std::unique_ptr<llvm::Module, std::default_delete<llvm::Module> >, unsigned int, std::function<void (llvm::Module&, llvm::StringSet<llvm::MallocAllocator> const&)>) ()
#6 0x000000000042e683 in Bootstrap::init (this=0x16a8170, argc=<optimized out>, argv=<optimized out>) at src/utils/Bootstrap.cpp:109
#7 0x00007ffff69ddb45 in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
#8 0x000000000042c7d7 in _start ()
(gdb)
from brain.
I will check that when I get home! Please take a look to it too @rafaelcn.
Will get back soon to you, @rdebath!
from brain.
Sorry @rdebath but I couldn't reproduce your bug. It seems, superficially that something has changed between clang++ version 3.9
and clang++ version 5.0
, but nothing to assure yet.
Here's what I've done:
- Compiled Brain with
make debug
- Tried
gdb -args bin/brain tests/helloworld.b -c
Here's the output. I've removed GNU's copyright notice.
ranu@ranu-laptop ‹ dev ↑● › : ~/Github/brain-labs/brain/bin
[0] % gdb -args brain_debug ../tests/helloworld.b -c
Reading symbols from brain_debug...done.
(gdb) run
Starting program: /home/ranu/Github/brain-labs/brain/bin/brain_debug ../tests/helloworld.b -c
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Inferior 1 (process 30172) exited normally]
(gdb)
Again I tried with brain and I've got the same behavior.
make
- Tried
gdb -args bin/brain tests/helloworld.b -c
ranu@ranu-laptop ‹ dev ↑● › : ~/Github/brain-labs/brain/bin
[0] % gdb -args brain ../tests/helloworld.b -c
Reading symbols from brain...done.
(gdb) run
Starting program: /home/ranu/Github/brain-labs/brain/bin/brain ../tests/helloworld.b -c
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Inferior 1 (process 30488) exited normally]
from brain.
Anyway, gonna inspect that profoundly later!
from brain.
Okay, I set off a build of clang 4.0.1, amd64 and then downgraded from 5.0.0.
Version 4.0.1 works for me.
from brain.
That's quite weird! I was discussing this issue on PR #55. It looks like a problem when linking dwo
files. We are injecting C compiled code inside Brain when it is compiling.
from brain.
We’re actually attaching LLVM IR (we’re compiling .c to .ll and only them attaching) as this is one of the plans of Brain for the future (attach other libraries into the code, so we can use all the power of LLVM), but the IO must go built-in later, the current solution has a lot of problems and is better to avoid them in the future. We already have a couple of issues regarding that and we will give priority to that. Thanks a lot for posting this issue @rdebath!
from brain.
Not so sure if the error above is related to that @rafaelcn. I guess I’ll install clang 5 over the weekend and try to replicate/fix it
from brain.
That was just a guess by the error provided in that SO answer.
from brain.
Yet, we need to discuss the future of the Math and the IO library :v
from brain.
Yeah for sure, #7 and #29 are still open for this reason. Will try to start working on that ASAP
from brain.
WRT the math library the below should work fine.
It depends on the fact that you already have Log base 256 of the maximum integer size (called sizeof) and simply converts that to a log10 by multiplying by 2.41 (log(256)/log(10) --> 2.408239965311849) and adding the necessary padding for sign, nul and the last digit.
diff --git a/libs/io.c b/libs/io.c
index 40dd1ad..3d935b7 100644
--- a/libs/io.c
+++ b/libs/io.c
@@ -5,10 +5,6 @@
// you can overwrite those functions! :)
-int number_size(int number) {
- return floor(log10(abs(number))) + 1 + (number > 0 ? 0 : 1);
-}
-
void b_show_tape(int idx, int *cells, int size) {
// TODO: ellipsize values based on index
size = 12;
@@ -34,9 +30,9 @@ void b_show_tape(int idx, int *cells, int size) {
tape[tape_idx++] = ' ';
// Has a value allocated on register
if (*cells) {
- unsigned int value_size = number_size(*cells);
- char number[value_size];
- sprintf(number, "%d", *cells);
+ unsigned int value_size;
+ char number[sizeof(*cells)*241/100+3];
+ value_size = sprintf(number, "%d", *cells);
// Append each number character
for (j = 0; j < value_size; j++) {
tape[tape_idx++] = number[j];
from brain.
I could finally reproduce that on clang 5
, will check it
from brain.
Hi @rdebath, do you want to open a PR on this change you made on the io.c
? Thanks for the heads up!
BTW, i am trying to run on clang 5
and so far i do not have any idea about what that can be xD
from brain.
I could narrow down this problem. The problem is on the module, not on the engine
from brain.
Hi @rdebath, I am so sorry for the delay to fix this PR! School was killing me! It has been fixed on #59
from brain.
Related Issues (20)
- Makefile rules build and install are mixed and confused HOT 27
- Create .deb package and a ubuntu ppa channel for Brain HOT 4
- Change Docker Directory HOT 1
- Benchmark HOT 5
- Nested if statements HOT 2
- Small mistake on AST Expr.h method HOT 1
- BreakExpr for nested stmts HOT 3
- Fix compiler warnings HOT 1
- Missing the 'armhfp' HOT 9
- Travis file bug HOT 4
- Makefile and bash scripts problems HOT 3
- Uninitialized flag HOT 8
- Create a wiki to make the README.md small and cleaner HOT 3
- Rename expression files (and classes) HOT 5
- Implement linker for binaries
- Make tape cell size custom
- Infinite loop compiler
- Implement mov instruction '&'
- guys, are you still alive? the last commit happened in 2020 HOT 6
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 brain.