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

printf segmentation faults on linux #990

Closed
sparky4 opened this issue Nov 6, 2022 · 22 comments
Closed

printf segmentation faults on linux #990

sparky4 opened this issue Nov 6, 2022 · 22 comments

Comments

@sparky4
Copy link

sparky4 commented Nov 6, 2022

i have this code for othello
and the line printf(" %d |", j+1); crashes the program
j is an int inside a for loop

compiled with latest release on 64 bit and 32 bit linux
both times crashes

the linux version of the program crashes while the dos version works perfectly

http://4ch.mooo.com/4/C_code_1.zip
here is the code

@jmalak
Copy link
Member

jmalak commented Nov 6, 2022

Thanks for your report.
Please, what compiler options you use?

@sparky4
Copy link
Author

sparky4 commented Nov 7, 2022

default ones

@jmalak
Copy link
Member

jmalak commented Nov 7, 2022

Thanks

@sparky4
Copy link
Author

sparky4 commented Nov 7, 2022

np <3

@sparky4
Copy link
Author

sparky4 commented Nov 10, 2022

found another issue...
cannot compile johncampbell123's doslib
1.9 can and older versions of 2.0 can

@jmalak
Copy link
Member

jmalak commented Nov 11, 2022

Could you give here more details.

@sparky4
Copy link
Author

sparky4 commented Nov 11, 2022

joncampbell123/doslib#58
i posted some details here

@jmalak
Copy link
Member

jmalak commented Nov 11, 2022

Thanks

@sparky4
Copy link
Author

sparky4 commented Nov 11, 2022

np

@jmalak
Copy link
Member

jmalak commented Nov 23, 2022

Build problem is due to mistake in doslib make files. I created pull request with fix.
joncampbell123/doslib#59

@jmalak
Copy link
Member

jmalak commented Nov 24, 2022

I cannot reproduce your issue.
What command line you use to compile?
I used latest version of OW build (64-bit version) and when run compiled program I got 4 matrices without any problem.

@sparky4
Copy link
Author

sparky4 commented Nov 25, 2022

let me give you the files

@sparky4
Copy link
Author

sparky4 commented Nov 25, 2022

https://4ch.mooo.com/4/C_code_1.zip i just did wcl386 on linux and completed a game and it seg faults
i ran wcl386 Othello.c *.c

@sparky4
Copy link
Author

sparky4 commented Nov 25, 2022

using November 24th version

@jmalak
Copy link
Member

jmalak commented Nov 25, 2022

I tried your last sample and I run game, no any core dump etc.
Please check following Environment variables setup:
WATCOM= it should be root of OW, my setup is /home/jiri/watcom
INCLUDE= it should be OW Linux header path, my setup is /home/jiri/watcom/lh
PATH= it should be OW Linux binaries path, my setup is /home/jiri/watcom/binl64

Mainly INCLUDE directory is important to point to target related subdirectory (lh for Linux)
I am using Ubuntu 22.04 box.
I checked both 32-bit and 64-bit versions of OW with same result.

@jmalak
Copy link
Member

jmalak commented Nov 25, 2022

I enclosed compiled game (Linux version).
Othello.zip

@sparky4
Copy link
Author

sparky4 commented Nov 26, 2022

lets see

@sparky4
Copy link
Author

sparky4 commented Nov 26, 2022

!! it works... okay let me update the thing

@sparky4
Copy link
Author

sparky4 commented Nov 26, 2022

hmmm it works now thanks!
INCLUDE only had $watcom/h not $watcom/lh

@sparky4 sparky4 closed this as completed Nov 26, 2022
@sparky4
Copy link
Author

sparky4 commented Nov 26, 2022

got the old code of the othello program?

@jmalak
Copy link
Member

jmalak commented Nov 26, 2022

Yes, I tested both your samples old and new with same results.
Be careful about INCLUDE environment variable, it must be setup for appropriate target.
Mostly it compiles without problem, but on runtime problems appears.
By example on Linux different structure alignment then on DOS or other platforms (it is defined in header files).
If you compile for multiple platform frequently you can use another trick with OW.
Don't setup INCLUDE environment variable and setup target specific environment variable.
By example for DOS, Windows and Linux you can setup

DOS_INCLUDE=.../h
LINUX_INCLUDE=.../lh
NT_INCLUDE=.../h;.../h/nt

And compiler select appropriate <os>_INCLUDE variable by -bt=<os> compiler option.
Of course this works for the default target (implicit host, if not specified -bt option) as well.
look into section about -bt option in OW documentation

@sparky4
Copy link
Author

sparky4 commented Nov 26, 2022

thanks <3

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

2 participants