![]() |
|
|||||||
| Orbiter SDK Orbiter software developers post your questions and answers about the SDK, the API interface, LUA, meshing, etc. |
![]() |
|
|
Thread Tools |
|
|
#16 |
|
shoemaker without legs
![]() |
Quote:
Quote:
I can only hypothesize that something overwrites the pointer to DetachChild and this happens to coincide with the address of the function the crash then happens in. But I don't know about how classes and their functions are managed in memory, so I don't know if that's even possible... ---------- Post added at 06:57 PM ---------- Previous post was at 06:36 PM ---------- Replaced the char[200] with a stringstream just to make sure. No change. It's almost as if the very path name would cause a bug in SaveScenario...?? ---------- Post added at 07:14 PM ---------- Previous post was at 06:57 PM ---------- Quote:
using strcpy for the operation, now everything works fine. Now, if someone could explain me why, I might even learn something from this whole affair. Thanks everyone for the help anyways. I'll just call the guys with the straightjacket back and tell them they needn't come after all... Last edited by jedidia; 07-23-2012 at 06:39 PM. |
|
|
|
|
|
#17 |
|
Donator
![]() ![]() |
Hmm.. funny one! indeed sprintf SHOULD produce an equivalent string as strcpy, provided you do not have conversion specificators(ie. "%s")in the name.Also, IIRC, there was a difference in the way multi-byte-characters are treated, but that shoudln't matter either.
Anyway, I guess it's water under the bridge now that you got it working, but if you're willing to investigate this further, I'd put some padding arround the local variables(eg.): Code:
char flname[200];
char padding1[100];
char desc[200];
char padding2[100];
string createPath = "Scenarios/IMS/";
char padding3[100];
char VesName[50];
char padding4[100];
Also, try doing a sprintf(VesName,"%s",GetName()); If sprintf is indeed the culprit, this should also crash it. But if it doesn't crash, then you know is a conversion specificator problem in the GetName(); |
|
|
|
|
|
#19 |
|
O-F Administrator
![]() ![]() ![]() |
To expand on Uwrumpe's point, in general it is not safe to copy a string with sprintf(dest, src) because if 'src' has any formatting characters in it sprintf will expect (and try to parse) arguments that were not sent, which would have unpredictable results since it would be reading uninitialized data. The second argument ('src' above) is the format string, so to safely copy a string using sprintf you would need:
Code:
sprintf(VesName, "%s", GetName()); Still, it was a subtle bug -- nobody (including me!) caught it at first.
|
|
|
|
|
|
#20 |
|
shoemaker without legs
![]() |
Sorry guys, wrong diagnosis... turned out the Bug wasn't as 100% reliable as I thought, and it decided to not show at moments that made me conclude all the things I posted here. They weren't correct. In the end I was able to reproduce it even by just calling oapiSaveState with a normal filename.
I finally solved it (this time for real, it looks like) by waiting a frame after autosave before proceeding. The integration process is somewhat involved, creates and deletes attachment points and docking ports etc. It looks like those functions do not like to be called right after oapiSaveState, for whatever exact reason. I now call autosave when the button is pressed, and then wait until poststep to start the integration process, which seems to solve the problem. Quote:
Last edited by jedidia; 07-23-2012 at 09:20 PM. |
|
|
|
| Thanked by: |
![]() |
|
| Thread Tools | |
|
|
|||||
| Quick Links | Need Help? |