stack_trace icon indicating copy to clipboard operation
stack_trace copied to clipboard

Stack Trace is wrong in release mode (Flutter/Android)

Open fordcars opened this issue 2 years ago • 2 comments

Calling Trace.current() in debug works perfectly. However, calling Trace.current() in release mode yields a different stack which is definitely wrong (this code path is impossible). Most, if not all stack traces I get in release mode are like this (where one or two function calls are wrong).

Debug stack trace, showing correct GlobalChannelProxyService.createChannel call:

package:poly_scrabble_mobile/room_service/room_service.dart 52:36              RoomService._getCurrentFunctionName
package:poly_scrabble_mobile/room_service/room_service.dart 134:25             RoomService.callServer
package:poly_scrabble_mobile/services/global_channel_proxy_service.dart 17:33  GlobalChannelProxyService.createChannel
package:poly_scrabble_mobile/main_page/chat/create_channel_dialog.dart 14:10   CreateChannelDialog.submit
package:poly_scrabble_mobile/main_page/chat/create_channel_dialog.dart 44:17   CreateChannelDialog.build.<fn>
...

Release stack trace, showing impossible GameServiceProxy.executePlace call:

package:poly_scrabble_mobile/room_service/room_service.dart 52             RoomService._getCurrentFunctionName
package:poly_scrabble_mobile/room_service/room_service.dart 134            RoomService.callServer
package:poly_scrabble_mobile/services/game_proxy_service.dart 84           GameServiceProxy.executePlace
package:poly_scrabble_mobile/main_page/chat/create_channel_dialog.dart 16  CreateChannelDialog.submit.<fn>

Please note GameServiceProxy.executePlace is never even called in the app. It is, however, an async function, which may be related. If I comment the GameServiceProxy.executePlace function, the release stack trace will be different, but still wrong:

Release stack trace with commented GameServiceProxy.executePlace function:

package:poly_scrabble_mobile/room_service/room_service.dart 52              RoomService._getCurrentFunctionName
package:poly_scrabble_mobile/room_service/room_service.dart 111             RoomService.reflectProp
package:poly_scrabble_mobile/services/self_user_proxy_service.dart 12       SelfUserProxyService.user
package:poly_scrabble_mobile/room_service/room_service.dart 165             RoomService._callServerBase
package:poly_scrabble_mobile/room_service/room_service.dart 148             RoomService.callServer
package:poly_scrabble_mobile/services/global_channel_proxy_service.dart 17  GlobalChannelProxyService.createChannel
package:poly_scrabble_mobile/main_page/chat/create_channel_dialog.dart 14   CreateChannelDialog.submit
package:poly_scrabble_mobile/main_page/chat/create_channel_dialog.dart 33   CreateChannelDialog.build.<fn>
...

Please note the SelfUserProxyService.user, which is also an impossible path. It looks like 2 stack traces got mangled in this case.

fordcars avatar Nov 28 '22 21:11 fordcars

We have a similar problem. We use Trace.current(1) and get:

#0 new Trace.current (/Users/builder/.pub-cache/hosted/pub.dev/stack_trace-1.11.0/lib/src/trace.dart:96:39)
#1 Datadog.addErrorInfo (/Users/builder/clone/lib/util/datadog/datadog_service.dart:95:39)

I also wanted to add that the same problem affects both platforms: android and ios.

ios arch: arm64 comp: no sim: no
isolate_dso_base: 1121dc000, vm_dso_base: 1121dc000
isolate_instructions: 1121e7a00, vm_instructions: 1121e1f00
android arch: arm64 comp: yes sim: no
build_id: '349b9003b6bfa1efaf40333affa5f802'
isolate_dso_base: 76b2a1f000, vm_dso_base: 76b2a1f000
isolate_instructions: 76b2d1cd00, vm_instructions: 76b2d17000

Mik77o avatar Aug 04 '23 12:08 Mik77o

To understand whether this is a bug in this package or in SDK, do you also get wrong stack traces if you use StackTrace.current instead of Trace.current?

osa1 avatar Sep 19 '24 09:09 osa1