Skip to content

pthreads and workers support #56

@shaul-yermol

Description

@shaul-yermol

Hi all,

I have recently encountered several issues with pthreads and workers in crossbridge. It looks like the pthreads/workers support is not 100% stable and becomes a pitfall for any seriouse efforts to port complex C++ code. I am basically a C++ specialist, so although I have a basic understanding of how the threads were implmeented (both from looking at source and forums), it's really hard for me to debug these issues in the crossbridge code.

I'm using Windows 8 64bit, Crossbridge 1.0.1, Flex 4.12.1, Flash debug player standalone 13.

  1. In sample 09, pthread_swc2.swf - pthread_join causes deadlock, when running the main() on the UI wroker with startAsync() - you can try the original sample code.

  2. In sample 09, after changing pthread_swc.as by Console.as (basically just running the main() in background worker) the main() works fine, however trying to call spawnThread() from UI events sometimes causes deadlock in pthread_join

Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
    at flash.concurrent::Condition/wait()
    at global/sample.pthread::threadArbCondWait()
    at global/sample.pthread::F_avm2_msleep()[C:\cygwin\tmp\ccYVhlkk.lto.1.as:6496]
    at global/sample.pthread::F_kmsleep()[C:\cygwin\tmp\ccYVhlkk.lto.1.as:7434]
    at global/sample.pthread__3A__5C_cygwin_5C_tmp_5C_cciMgysi_2E_lto_2E_bc_3A_77d5ac99_2D_8207_2D_44be_2D_990e_2D_0fc9c24978f7::F_do_wait()[C:\cygwin\tmp\ccYVhlkk.lto.1.as:76497]
    at global/sample.pthread__3A__5C_cygwin_5C_tmp_5C_cciMgysi_2E_lto_2E_bc_3A_77d5ac99_2D_8207_2D_44be_2D_990e_2D_0fc9c24978f7::F___umtx_op_wait()[C:\cygwin\tmp\ccYVhlkk.lto.1.as:71533]
    at global/sample.pthread::F_k_umtx_op()[C:\cygwin\tmp\ccYVhlkk.lto.1.as:71338]
    at global/sample.pthread::F__umtx_op()[C:\cygwin\tmp\ccYVhlkk.lto.1.as:2267]
    at global/sample.pthread::F__thr_umtx_wait()[C:\cygwin\tmp\ccYVhlkk.lto.1.as:59107]
    at global/sample.pthread__3A__5C_cygwin_5C_tmp_5C_cciMgysi_2E_lto_2E_bc_3A_77d5ac99_2D_8207_2D_44be_2D_990e_2D_0fc9c24978f7::F_join_common()[C:\cygwin\tmp\ccYVhlkk.lto.1.as:49539]
    at global/sample.pthread::F__pthread_join()[C:\cygwin\tmp\ccYVhlkk.lto.1.as:49319]
    at global/sample.pthread::F_pthread_join_exp()[C:\cygwin\tmp\ccYVhlkk.lto.1.as:66745]
    at global/sample.pthread::spawnThread()[C:\cygwin\tmp\ccYVhlkk.lto.1.as:111]
    at Console/buttonClickHandler()[C:\crossbridge\samples\09_Pthreads\Console.as:132]

And after I've removed the pthread_join(), it sometimes deadlocked in printf().

Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
    at flash.concurrent::Condition/wait()
    at global/sample.pthread::threadArbCondWait()
    at global/sample.pthread::F_avm2_msleep()[C:\cygwin\tmp\cc5PYYGx.lto.1.as:6488]
    at global/sample.pthread::F_kmsleep()[C:\cygwin\tmp\cc5PYYGx.lto.1.as:7426]
    at global/sample.pthread__3A__5C_cygwin_5C_tmp_5C_ccqgHCk8_2E_lto_2E_bc_3A_75e4d886_2D_039d_2D_479d_2D_bd70_2D_fe9c94c1a4e5::F__do_lock_umutex()[C:\cygwin\tmp\cc5PYYGx.lto.1.as:74414]
    at global/sample.pthread__3A__5C_cygwin_5C_tmp_5C_ccqgHCk8_2E_lto_2E_bc_3A_75e4d886_2D_039d_2D_479d_2D_bd70_2D_fe9c94c1a4e5::F_do_lock_umutex()[C:\cygwin\tmp\cc5PYYGx.lto.1.as:76178]
    at global/sample.pthread__3A__5C_cygwin_5C_tmp_5C_ccqgHCk8_2E_lto_2E_bc_3A_75e4d886_2D_039d_2D_479d_2D_bd70_2D_fe9c94c1a4e5::F___umtx_op_wait_umutex()[C:\cygwin\tmp\cc5PYYGx.lto.1.as:73667]
    at global/sample.pthread::F_k_umtx_op()[C:\cygwin\tmp\cc5PYYGx.lto.1.as:71330]
    at global/sample.pthread::F__umtx_op()[C:\cygwin\tmp\cc5PYYGx.lto.1.as:2259]
    at global/sample.pthread::F___thr_umutex_lock()[C:\cygwin\tmp\cc5PYYGx.lto.1.as:59556]
    at global/sample.pthread__3A__5C_cygwin_5C_tmp_5C_ccqgHCk8_2E_lto_2E_bc_3A_75e4d886_2D_039d_2D_479d_2D_bd70_2D_fe9c94c1a4e5::F_mutex_lock_common()[C:\cygwin\tmp\cc5PYYGx.lto.1.as:53582]
    at global/sample.pthread::F__pthread_mutex_lock()[C:\cygwin\tmp\cc5PYYGx.lto.1.as:53961]
    at global/sample.pthread::F__flockfile()[C:\cygwin\tmp\cc5PYYGx.lto.1.as:109241]
    at global/sample.pthread::F_puts()[C:\cygwin\tmp\cc5PYYGx.lto.1.as:97284]
    at global/sample.pthread::spawnThread()[C:\cygwin\tmp\cc5PYYGx.lto.1.as:109]
    at Console/buttonClickHandler()[C:\crossbridge\samples\09_Pthreads\Console.as:132]

Error: Error #1517: Condition cannot notifyAll if associated mutex is not owned.
    at flash.concurrent::Condition/notifyAll()
    at global/sample.pthread::threadArbCondsNotify()
    at global/sample.pthread::F_avm2_wake_one()[C:\cygwin\tmp\ccYVhlkk.lto.1.as:4287]
    at global/sample.pthread__3A__5C_cygwin_5C_tmp_5C_cciMgysi_2E_lto_2E_bc_3A_77d5ac99_2D_8207_2D_44be_2D_990e_2D_0fc9c24978f7::F_uiThunkTickProc()[C:\cygwin\tmp\ccYVhlkk.lto.1.as:7350]
    at sample.pthread::CModule$/callI()
    at sample.pthread::CModule$/serviceUIRequests()
    at Console/enterFrame()[C:\crossbridge\samples\09_Pthreads\Console.as:219]

I will really appritiate any suggestions and will be glad to assist, as right now this is the major pitfall of our porting efforts.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions