Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Stack overflow" error when GHC option rtsopts is low #9

Open
laurenceisla opened this issue Mar 21, 2024 · 0 comments
Open

"Stack overflow" error when GHC option rtsopts is low #9

laurenceisla opened this issue Mar 21, 2024 · 0 comments

Comments

@laurenceisla
Copy link

When testing our project, we set ghc-options: -with-rtsopts=-1K1 to avoid space leaks. Everything worked correctly for version 0.2.3, but when we upgraded to 0.3.2, we started to get "Stack overflow errors" when replacing getOne with the new findOne and closestMatch functions (discussion for reference: PostgREST/postgrest#3329).

To use a reproducible example. In version 0.2.4:

{-# LANGUAGE OverloadedStrings #-}

module Main where

import qualified Data.FuzzySet as Fuzzy

main :: IO ()
main = do
  putStrLn $ show suggestVal
  where
    fuzzySet = Fuzzy.fromList ["authors_books_number","grandchild_entities","label_screen","authors_have_book_in_decade2","second_1","agents","Escap3e;","materialized_projects","books","tournaments","Foo","client","unit_workdays","datarep_todos","job","students_info","car_models_car_dealers","organizations","articleStars","plate","being_part","publishers","car_racers","person","sponsors","family_tree","datarep_next_two_todos","users_tasks","actors","descendant","simple_pk","capital","big_projects","budget_categories","v2","contract","second","profiles","whatev_sites","limited_article_stars","students_view","authors_have_book_in_decade","suppliers_trade_unions","v1","datarep_todos_computed","baz","has_fk","shop_bles","screens","status","touched_files","alpha_projects","b","users_projects","contract_view","designers","sixties_books","suppliers","group_yard","player_view","projects_view_with_delete_trigger","items","projects_view_with_all_triggers_with_pk","end_2","posters","entities","videogames","projects_view_with_all_triggers_without_pk","being","person_detail","filtered_tasks","table_b","i2459_self_v2","odd_years_publications","schauspieler","products_suppliers","projects_auto_updatable_view_with_pk","contact","authors","janedoe","subscriptions","yards","i2459_composite_v2","departments","activities","ghostBusters","first_1","users","addresses","i2459_composite_v1","consumers_extra_view","bar","items2","unit_workdays_fst_shift","projects_view_with_insert_trigger","user_friend","whatev_projects","tasks","clients","forties_books","projects","zeta_projects","series_popularity","adaptation_notifications","message","child_entities","trade_unions","articles","trash_details","files","consumers_view_view","products","projects_view_alt","schedules","part","view_test","projects_view_with_update_trigger","projects_auto_updatable_view_without_pk","first","test_null_pk_competitors_sponsors","web_content","authors_w_entities","filme","i2459_simple_v2","vb","pages","sites","va","i2459_simple_v1","orders","well","jobs","personnages","plate_plan_step","projects_view_without_triggers","consumers_view","projects_view","foos","i2459_self_v1","child_entities_view","table_a","auto_incrementing_pk","main_jobs","trash","students_info_view","fee","referrals","insertable_view_with_join","competitors","end_1","car_model_sales","bars","budget_expenses","bad_subquery","orders_view","projects_count_grouped_by","shops","project_invoices","whatev_jobs","johnsmith","country","car_models","car_brands","series","films","test","students","fifties_books","a","managers","labels","forties_and_fifties_books","space","clientinfo","groups","comments","zone","car_dealers"]
    suggestVal = Fuzzy.getOne fuzzySet "some_non_existent_value"

With the ghc-options: -with-rtsopts=-1K1 setting, this prints:

Nothing

But, in version 0.3.0, with the same settings:

{-# LANGUAGE OverloadedStrings #-}

module Main where

import qualified Data.FuzzySet.Simple as Fuzzy

main :: IO ()
main = do
  putStrLn $ show suggestVal
  where
    fuzzySet = Fuzzy.fromList ["authors_books_number","grandchild_entities","label_screen","authors_have_book_in_decade2","second_1","agents","Escap3e;","materialized_projects","books","tournaments","Foo","client","unit_workdays","datarep_todos","job","students_info","car_models_car_dealers","organizations","articleStars","plate","being_part","publishers","car_racers","person","sponsors","family_tree","datarep_next_two_todos","users_tasks","actors","descendant","simple_pk","capital","big_projects","budget_categories","v2","contract","second","profiles","whatev_sites","limited_article_stars","students_view","authors_have_book_in_decade","suppliers_trade_unions","v1","datarep_todos_computed","baz","has_fk","shop_bles","screens","status","touched_files","alpha_projects","b","users_projects","contract_view","designers","sixties_books","suppliers","group_yard","player_view","projects_view_with_delete_trigger","items","projects_view_with_all_triggers_with_pk","end_2","posters","entities","videogames","projects_view_with_all_triggers_without_pk","being","person_detail","filtered_tasks","table_b","i2459_self_v2","odd_years_publications","schauspieler","products_suppliers","projects_auto_updatable_view_with_pk","contact","authors","janedoe","subscriptions","yards","i2459_composite_v2","departments","activities","ghostBusters","first_1","users","addresses","i2459_composite_v1","consumers_extra_view","bar","items2","unit_workdays_fst_shift","projects_view_with_insert_trigger","user_friend","whatev_projects","tasks","clients","forties_books","projects","zeta_projects","series_popularity","adaptation_notifications","message","child_entities","trade_unions","articles","trash_details","files","consumers_view_view","products","projects_view_alt","schedules","part","view_test","projects_view_with_update_trigger","projects_auto_updatable_view_without_pk","first","test_null_pk_competitors_sponsors","web_content","authors_w_entities","filme","i2459_simple_v2","vb","pages","sites","va","i2459_simple_v1","orders","well","jobs","personnages","plate_plan_step","projects_view_without_triggers","consumers_view","projects_view","foos","i2459_self_v1","child_entities_view","table_a","auto_incrementing_pk","main_jobs","trash","students_info_view","fee","referrals","insertable_view_with_join","competitors","end_1","car_model_sales","bars","budget_expenses","bad_subquery","orders_view","projects_count_grouped_by","shops","project_invoices","whatev_jobs","johnsmith","country","car_models","car_brands","series","films","test","students","fifties_books","a","managers","labels","forties_and_fifties_books","space","clientinfo","groups","comments","zone","car_dealers"]
    suggestVal = Fuzzy.closestMatch "some_non_existent_value" fuzzySet

It prints:

Stack space overflow: current size 33624 bytes.
Relink with -rtsopts and use `+RTS -Ksize -RTS' to increase it.

In conclusion the library may be having space leaks in the new versions (~33KB) compared to the older ones (less than 1KB).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant