c++ builder > debug > 和の法則(適当な命名) > 処理Aのみ成功 / 処理Bのみ成功 / 処理A+処理Bの時、処理Bは失敗


動作環境
C++ Builder XE4
  • 処理A: 問題なし
  • 処理B: 問題なし
  • 処理A + 処理B : 処理Bが失敗する

順番に処理しているだけだが、何かをミスしている。

デバッグ情報から、処理Bの対象データ数が0になっているところまでは突き止めた。

どうやって狼を囲い込むか。

  • cnt:0 関連でインスペクタを使って構造体の値を追っていった。

処理Aのみ

デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:1439 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:1439 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:1439 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:0 プロセス someApp.exe (3160)
デバッグ出力: someUtil >somefunc: Line505: cnt:0 プロセス someApp.exe (3160)

処理Bのみ

デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3156)

処理A+処理B

デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:0 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:0 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:0 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:0 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:0 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:0 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:0 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:0 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1439 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1439 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1439 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:1440 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:0 プロセス someApp.exe (3712)
デバッグ出力: someUtil >somefunc: Line505: cnt:0 プロセス someApp.exe (3712)

不具合の原因1

以下の不具合と分かった。

  • あとから追加した機能で不具合
  • 処理Aと処理Bで設定が異なる
  • 設定読込みの不具合
    • 処理Aのみ実行時、処理A用の設定が読込まれる
    • 処理Bのみ実行時、処理B用の設定が読込まれる
    • 処理A+処理Bの実行時、処理A用の設定が読込まれて、処理Bまで実行する
      • 処理B用の設定読込み処理の抜け

余談

FastReportの描画不具合と思ってました。

プログラマーあるある

まずは自分を
疑いましょう。恥ずかしい思いをしたくないのなら。

不具合の原因2

以下の不具合が追加で見つかった。

  • リストを使用
  • リストの項目読み直し時にクリアを忘れている
    • 結果として本来8項目のところが16項目に
    • 先頭から読むため、後から追加したものが使われていない