Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault upon launch #5

Closed
jmcph4 opened this issue May 31, 2021 · 6 comments
Closed

Segmentation fault upon launch #5

jmcph4 opened this issue May 31, 2021 · 6 comments

Comments

@jmcph4
Copy link

jmcph4 commented May 31, 2021

System Information

Operating System

$ uname --all
Linux foobar 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux

Application

9c03ea4

Actual Behaviour

After successful build, the program crashes with a segmentation fault after (very) briefly rendering a (blank) window:

$ sudo apt-get install libsdl2-dev
$ make
cc -O2 -Wall -Wno-return-type -Wno-misleading-indentation -lSDL2 -o pokegb pokegb.cc
$ ./pokegb
Segmentation fault

Expected Behaviour

No segmentation fault.

@yaakov-h
Copy link

I got the same thing after compiling on macOS:

yaakov@Ilum pokegb % clang++ pokegb.cc -I/opt/homebrew/include -lsdl2 -L/opt/homebrew/lib -o pokegb 
pokegb.cc:20:72: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
                     using z=                                          uint8_t;                                          using Z=
                                                                       ^
pokegb.cc:21:17: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
                uint16_t;using I=                                 int;z o,m,u,x,c,n,                                 *r0,*r1,i[512],v
                ^
pokegb.cc:21:67: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
                uint16_t;using I=                                 int;z o,m,u,x,c,n,                                 *r0,*r1,i[512],v
                                                                  ^
pokegb.cc:31:45: warning: non-void function does not return a value in all control paths [-Wreturn-type]
    12 ...14:a&=16383;if(w)r4[a]=x;K r4[a];}}z        r(Z a=H){K me(a,0,0);}void w(z x,Z a=H){me        (a,x,1);}void f(z M,I Z,I N,I H,I C){F=(F&
                                            ^
4 warnings generated.
yaakov@Ilum pokegb % ./pokegb 
zsh: segmentation fault  ./pokegb

I would assume that it is the same segmentation fault, though I have no way to tell.

@binji
Copy link
Owner

binji commented May 31, 2021

Did you put the pokemon rom in a file called rom.gb in the same directory? Without that it won't work.

@LF-Lin
Copy link

LF-Lin commented Jun 2, 2021

Maybe you can try this:
Google Pokemon blue version rom, and download a file with .gb, then rename it to rom.gb

@yaakov-h
Copy link

yaakov-h commented Jun 2, 2021

ah, I had the filename wrong.

After fixing that it now segfaults about 15 seconds in, right after the Jigglypuff headbutts Gengar and the screen fades to white.

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   pokegb                        	0x0000000102a019f0 me(unsigned short, unsigned char, int) + 240
1   pokegb                        	0x0000000102a02788 main + 2888
2   pokegb                        	0x0000000102a02788 main + 2888
3   libdyld.dylib                 	0x000000019ff2d450 start + 4

@binji
Copy link
Owner

binji commented Jun 2, 2021

@yaakov-h yeah, that's the same issue as #1. Seems like the simplest workaround is to create an empty 32768 byte file called rom.sav, but it'd be nice to fix.

@jmcph4
Copy link
Author

jmcph4 commented Jun 3, 2021

Did you put the pokemon rom in a file called rom.gb in the same directory? Without that it won't work.

That would help! Solved this issue for me, so I'm willing to mark as closed.

@jmcph4 jmcph4 closed this as completed Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants