After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 132486 - blackjack crashes on startup on powerpc (and probably on most non-x86 architectures)
blackjack crashes on startup on powerpc (and probably on most non-x86 archite...
Status: RESOLVED FIXED
Product: gnome-games-superseded
Classification: Deprecated
Component: general
unspecified
Other other
: Urgent critical
: ---
Assigned To: GNOME Games maintainers
GNOME Games maintainers
Depends on:
Blocks:
 
 
Reported: 2004-01-25 17:09 UTC by frank
Modified: 2012-01-31 23:18 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description frank 2004-01-25 17:10:57 UTC
Distribution: Debian testing/unstable
Package: gnome-games
Severity: normal
Version:  2.4.1.1
Synopsis: blackjack crashes on startup on powerpc (and probably on most non-x86 architectures)
Bugzilla-Product: gnome-games
Bugzilla-Component: blackjack
Bugzilla-Version: 2.4.1.1
BugBuddy-GnomeVersion: 2.0 (2.4.0.1)
Description:
Description of the crash:

blackjack crashes on startup on powerpc (and probably on most non-x86
architectures)

Steps to reproduce the crash:
1. find a powerpc machine
2. run blackjack

Additional Information:
The problem is that Vegas_Strip.rules.dat is a machine dependent file,
which
is read directly into C structs and arrays.
The problems are byte ordering, sizeof(int) on 64 bit architectures, and
maybe the format of float.


Debugging Information:

Backtrace was generated from '/home/fg/install/bin/blackjack'

[New Thread 16384 (LWP 8809)]
0x0f185064 in waitpid () from /lib/libpthread.so.0

Thread 1 (Thread 16384 (LWP 8809))

  • #0 waitpid
    from /lib/libpthread.so.0
  • #1 libgnomeui_module_info_get
    from /usr/lib/libgnomeui-2.so.0
  • #2 __pthread_sighandler
    from /lib/libpthread.so.0
  • #3 <signal handler called>
  • #4 inflate
    from /usr/lib/libz.so.1
  • #5 inflate
    from /usr/lib/libz.so.1
  • #6 LoadablePlayer::load(char const*)
    at player.cpp line 618
  • #7 LoadablePlayer::reset(char const*)
    at player.cpp line 486
  • #8 LoadablePlayer
    at player.cpp line 476
  • #9 bj_game_eval_installed_file
    at game.cpp line 346
  • #10 bj_game_new(char*, unsigned*)
    at game.cpp line 399
  • #11 main_prog
    at blackjack.cpp line 348
  • #12 main
    at blackjack.cpp line 618
  • #0 waitpid
    from /lib/libpthread.so.0




------- Bug moved to this database by unknown@bugzilla.gnome.org 2004-01-25 12:10 -------

Unknown version 2.4.1.1 in product gnome-games. Setting version to the default, "unspecified".
The original reporter (frank@gevaerts.be) of this bug does not have an account here.
Reassigning to the exporter, unknown@bugzilla.gnome.org.
Reassigning to the default owner of the component, gnome-games-maint@bugzilla.gnome.org.

Comment 1 Callum McKenzie 2004-01-27 06:38:54 UTC
I should have noticed this since I do most development on a 64-bit
powerpc machine now :(. I'm going to have to talk to Jon about the
best way to fix it for 2.5 but for 2.4 I have merely disabled use of
the cache. This is very crude, but it is fool-proof, which is all I
want for 2.4. There will be a 2.4.2 release soon with this and other
important bug fixes.

Jon, what do you think is the best solution here ? I'm favouring
machine-independent text-based files. A well-defined binary format is
simpler to parse for integers but there can be problems with floating
point since not quite everyone uses IEEE. Caching machine-specific
files at run-time is possible, but leads to setgid problems and the
results would have to go in /var. Compile time is another option, but
if /usr/share is shared this could be a problem. 

Comment 2 William Jon McCann 2004-01-27 22:08:53 UTC
Ugh.

My first thought is that caching at run time is best.  The files would
have to be stored in /var.  I don't like the idea of storing machine
dependant files in share or home.  What setgid issues would there be
with /var?

Creating the cache at compile time is tricky, especially for
distributions and cross-compiling.  It also adds bloat.
Comment 3 Callum McKenzie 2004-01-28 09:58:20 UTC
The permissions thing is ugly. You can use a setgid system like the
scores, but you don't have the luxury of being able to open the files
and drop privileges right at the beginning, especially if they haven't
been created yet. You could just put them in a world-writable
directory and use really good checking on the input, but this can lead
to all sorts of amusing abuse separate from the game.

There is one nasty problem with a raw dumped structures format:
recompiling with a new compiler (think gcc 2.9x->3.x for a common
example) could effectively render the data file corrupt if the data
structures are packed differently. You could check the time-stamps on
the binary and the data file, but even that isn't perfect.

Maybe the solution is to have a fixed binary format (with a version
number !) with all the games in the one file. That way you can make
the game setgid, open the file when the game starts and immediately
drop pivileges. Because it is a binary format the games can be at
fixed places in the file and then just filled out as necessary. e.g.

+------------------------------------------+
| File header                              |
+------------------------------------------+
| Rule Set Header                          |
| (including offset of next header)        |
+------------------------------------------+
| Data                                     |
|                                          |
|                                          |
+------------------------------------------+
| Rule Set Header                          |
+------------------------------------------+
| Data                                     |
    .
    .
    .


If you don't have the time to do this I can probably give it a go. I'd
like to get major code changes like this out of the way since we are
quite close to the absolute feature freeze and I'd like to get some
testing in before 2.6, otherwise I'm just going to have to bypass the
caching for the 2.6 release like I have for 2.4.2 and that wouldn't be
good.

Comment 4 William Jon McCann 2004-01-28 22:23:20 UTC
I suppose there is another option.  Disable the probabilities stuff by
default.  The game should play normally except that the dealer and
hand probabilities (and hints) would not be available.  This could be
a preference.  If the user really wants to compute probabilities they
would have to deal with waiting for the computation.

This could likely require more significant code changes.  I will have
to look and see.
Comment 5 William Jon McCann 2004-01-28 22:58:43 UTC
Does the connect4 data file work on non-x86 architectures?

Callum, I am starting to think that your suggestion is the best option
for now.  One complication could be that the rule sets are not fixed
and the names are completely arbitrary.  We would have to construct
some kind of unique key from the parameters of each rule set.
Comment 6 frank 2004-01-29 15:59:21 UTC
connect4 (gnect) works on 32bit powerpc. As far as I understand the
source, this means that the data file (white_ob.cn4) can be read
correctly.
Comment 7 Callum McKenzie 2004-01-30 23:05:26 UTC
Indexing based on parameters is not a big problem. In fact it usually
works out to be easier in the long run (the card library does this for
the card styles, originally for backwards compatibility, but it also
helped when it came time to translate the names).

I've been having a look at what is saved. The integers are not a
problem, but the floats and doubles are. I suspect we can just save
them as fixed point values (i.e. integers) but I don't know what range
they have to cover. Any hints ?

gnect's opening book file is byte oriented which is why it gets away
with it.


Comment 8 William Jon McCann 2004-02-02 23:03:07 UTC
It turns out that a gzipped XML cache file is only about 396KiB.  That
is about 50KiB larger than the current binary cache file.  The
precisions used for the floats and doubles are not very high, yet.  So
when we change this the filesize will get a bit larger.

The code for  saving the XML is done.  The loading is mostly done but
I have a small bug to track down.  I should be able to commit this to
CVS tomorrow (not turned on by default).

I now think this is a good way to go.  Using a platform independent
file will avoid other problems in the future.  It should even be
possible to store this XML file in the users home directory at runtime
if we don't want to ship the file by default.
Comment 9 Callum McKenzie 2004-02-02 23:15:11 UTC
Sounds good Jon. I'm looking forward to it (even on a G5 the
calculation is not quick).
Comment 10 William Jon McCann 2004-02-03 18:29:20 UTC
Ok, I committed the changes.  To test writing out the XML file
uncomment the following in game.cpp:
strategy->saveXML ("/tmp/foo.xml.gz");

I think the issues that need to be resolved now are:

1. are we using adequate precision for floats and doubles?
2. is the DTD reasonable?
3. how should we version the DTD?
4. should we generate or distribute the cache file?
Comment 11 Callum McKenzie 2004-02-03 22:13:40 UTC
I'll check it tonight, but I can answer some of the questions now.

1. Only you can really know, but I'm willing to bet it doesn't need
high precision.

2. and 3. For private application use the DTD doesn't really matter.
DTD are for checking validity and letting other people write these
documents. Until such time as either of these things are necesary the
DTD can be ignored. XML can avoid versioning problems to an extent by
just adding new tags for new features (or attributes to tags). 

4. I'm leaning towards generation. Generating it won't take that long
compared to the overall compile time of gnome-games and reducing the
tarball size is always good.
Comment 12 William Jon McCann 2004-02-04 18:08:07 UTC
I checked in a change to activate the XML load/save.  For now the
cache file is generated as needed by the application and saved in
GNOME_DOT_GNOME/blackjack.d.  This is for a few reasons:

1. avoids setgid issues in var or share
2. avoids problems associated with generating cache files during
compilation (like needing a helper app)
3. doesn't make assumptions about which rule set will be played

I wonder if there should be preferences to disable writing cache
files, and to clear cache files.  Might be good.
Comment 13 William Jon McCann 2004-02-09 20:16:02 UTC
Does this seem to be working for you guys?

Callum, any suggestions?
Comment 14 Callum McKenzie 2004-02-10 06:15:58 UTC
It works fine for me. I'm a little worried about dumping data in the
users home directory, but it will add up to only a megabyte assuming
the user plays everything. At this point any changes before 2.6 can
really only be fine tuning and I don't think the current code needs
any. I'm going to mark this bug fixed, but maybe we should keep
possible better solutions in the back of our heads for 2.7 or later.
Comment 15 Richard Hoelscher 2004-02-10 18:38:39 UTC
Jon, as far as ordinary testing goes, it's working fine for me.
Comment 16 William Jon McCann 2004-02-10 18:53:58 UTC
Callum: Completely agree.  

Richard: Good, thanks for testing it.

And for the record, I hate directory names with ".d" at the end. 
Unfortunately, there was already a file in GNOME_DOT_GNOME with the
name blackjack.  So, I am just following precedent.
Comment 17 Robert Ancell 2012-01-31 23:18:53 UTC
This bug is being reassigned to the "general" component so we can close the blackjack bugzilla component.  Apologies for the mass email!