The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: VS on May 28, 2010, 10:15:38 am

Title: [bug] makeobj r3354 - "random" crashes when merging
Post by: VS on May 28, 2010, 10:15:38 am
It seems there is some problem when merging files with wildcard, like this: makeobj merge target.pak *.pak The effects vary.

See first few posts for original description of problem:
http://forum.simutrans.com/index.php?topic=5142.0

After compiling makeobj and some experiments, it seems that there is some problem when merging:
(reply #22) http://forum.simutrans.com/index.php?topic=5142.msg50990#msg50990

I was able to get the Python caller to receive SIGSEGV, as it happens to Werner. Additionally, I had one case where makeobj started copying the file recursively to itself or something - the pak file grew at 100 MB/s.

So far I couldn't get anything to happen on Windows.

edit: This could have something to do with timing or environment, since I wasn't able to reproduce this outside the python script.
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: wernieman on May 31, 2010, 09:15:04 am
Sorry, but did somebody work on this Problem??
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: Dwachs on May 31, 2010, 09:28:37 am
No / not yet.

If this problem happens only with specific paks, then please upload an archive of these paks somewhere.

Edit: small change in rev 3396 (use "delete []"). Maybe this lead to memory corruption?

If the problem is still there, please let me know. Extracting and merging the GUI.128.pak (from pak128 standard) worked fine for me (and valgrind, too).
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: VS on May 31, 2010, 11:26:51 am
Werner: I would say it's a bit hard to debug a problem that is vaguely described and probably exists only outside debugger :P
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: wernieman on May 31, 2010, 11:35:46 am
But .. how we solf the problem?

At now I could use for pak128 an offizial makeobj, but there will be a new version and then .. whe have the problem :o(
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: VS on May 31, 2010, 12:45:56 pm
I looked through documentation for the python library and tried to find something to alter the execution... at least trying, you know ;)

After setting this on, I consistently get only the growing file, no signals.

Quote from: http://docs.python.org/library/subprocess.html
If close_fds is true, all file descriptors except 0, 1 and 2 will be closed before the child process is executed. (Unix only). Or, on Windows, if close_fds is true then no handles will be inherited by the child process. Note that on Windows, you cannot set close_fds to true and also redirect the standard handles by setting stdin, stdout  or stderr.
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: wernieman on May 31, 2010, 01:06:10 pm
So .. there will be a new phyton script?

It would be on the svn too??
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: VS on May 31, 2010, 01:21:37 pm
It does not help... only the problem becomes consistent (for me, anyway).



edit: I can reliably reproduce the hang+infinite file this way:

1) pak128 r974
2) self-compiled makeobj r3397
3) #comment out all FOLDERS in top-level pakmak.tab except for "base" (no need to compile the whole set before)
4) when merging hangars, IT happens
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: wernieman on May 31, 2010, 01:36:28 pm
sch ....

I test to use a spezial makeobj for PAK128...

At now I generate all Pnightly-PAKs with the same makeobj .. then PAK18 use an other makeobj than the other ....
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: Dwachs on May 31, 2010, 02:14:48 pm
@VS: can you upload the offending paks that dont want to be merged?
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: VS on May 31, 2010, 02:50:53 pm
Here goes...

http://anyhub.net/file/premerge.tar.gz
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: prissi on May 31, 2010, 03:13:01 pm
Sounds to me rather that the created pak is found even while enumerating through all other paks. But then the enumeration of paks is done via the shell:

Code: [Select]
		if (!STRICMP(argv[0], "merge")) {
argv++, argc--;
try {
const char* dest = argv[0];
argv++, argc--;
root_writer_t::instance()->copy(dest, argc, argv);
}
...
return 0;

This means that there is already a pak with the tarbet name while adding with a wildcard?

(But a check for identical names would not be too hard to implement.)
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: VS on May 31, 2010, 04:29:34 pm
Well... this is certainly one possibility. But on Windows it does not fail for some reason!



Here's the patch... it seems it fixes that.

Code: [Select]
Index: besch/writer/root_writer.cc
===================================================================
--- besch/writer/root_writer.cc (revision 3397)
+++ besch/writer/root_writer.cc (working copy)
@@ -301,7 +301,11 @@
  } else {
  find.search(argv[i], "pak");
  for (searchfolder_t::const_iterator i = find.begin(), end = find.end(); i != end; ++i) {
- any |= do_copy(outfp, root, *i);
+ if (strcmp(*i, name) != 0) {
+ any |= do_copy(outfp, root, *i);
+ } else {
+ printf("WARNING: skipping reading from output file\n");
+ }
  }
  }
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: prissi on June 01, 2010, 09:06:30 pm
Windows lock open file for writing. Maybe it just fails to be opened?
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: VS on June 01, 2010, 09:33:31 pm
You're right. But that still leaves the question "how could this work before" ???

Werner: does the patch fix this problem for you?
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: wernieman on June 01, 2010, 09:44:31 pm
I must test it tomorow ... at now I must sleep ;o)
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: wernieman on June 02, 2010, 07:13:19 am
It work!

Now the Output is (at example):
Code: [Select]
Executing command: lift symbol.BigLogo.pak
Merging: makeobj QUIET merge GUI.128.pak *.pak
writing file GUI.128.pak
   copying file cursor.Mouse.pak
   copying file misc.Construction.pak
   copying file cursor.Marked.pak
   copying file cursor.GeneralTools.pak
   copying file symbol.Builder.pak
   copying file cursor.Builder.pak
WARNING: skipping reading from output file
My folders:  **none**
At this Part the makeobj without the Patch make an error ....
(But I don“t test the PAK, only the generation)

Edit:
When I count the quantity of the warnung I get 31, so it is Important for PAK128
Code: [Select]
simutrans@hedwig ~ $ grep "WARNING: skipping reading from output file" /home/simutrans/PAK/PAK128/info.txt | wc -l
31
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: wernieman on June 03, 2010, 09:05:01 pm
Dit it go into trunk??
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: VS on June 03, 2010, 09:45:30 pm
Warning will be generated for all folders since it's always merging against wildcard.
Title: Re: [bug] makeobj r3354 - "random" crashes when merging
Post by: wernieman on June 04, 2010, 05:33:13 am
Testet and Solved in 3405

Thanks!!